OSDN Git Service

2009-11-30 Robert Dewar <dewar@adacore.com>
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 30 Nov 2009 15:16:49 +0000 (15:16 +0000)
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 30 Nov 2009 15:16:49 +0000 (15:16 +0000)
* osint.ads: Minor comment update.

2009-11-30  Thomas Quinot  <quinot@adacore.com>

* s-sechas.adb: Fix swapping error in previous checkin.
* g-md5.ads, g-sha256.ads, g-sha512.ads, g-sha1.ads, g-sha224.ads,
g-sha384.ads: Add missing documentation.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154819 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/g-md5.ads
gcc/ada/g-sha1.ads
gcc/ada/g-sha224.ads
gcc/ada/g-sha256.ads
gcc/ada/g-sha384.ads
gcc/ada/g-sha512.ads
gcc/ada/osint.ads
gcc/ada/s-sechas.adb

index dbb8057..86e754b 100644 (file)
@@ -1,5 +1,15 @@
 2009-11-30  Robert Dewar  <dewar@adacore.com>
 
+       * osint.ads: Minor comment update.
+
+2009-11-30  Thomas Quinot  <quinot@adacore.com>
+
+       * s-sechas.adb: Fix swapping error in previous checkin.
+       * g-md5.ads, g-sha256.ads, g-sha512.ads, g-sha1.ads, g-sha224.ads,
+       g-sha384.ads: Add missing documentation.
+
+2009-11-30  Robert Dewar  <dewar@adacore.com>
+
        * g-sha256.ads, s-sehamd.ads, s-sehamd.adb, g-sha512.ads, g-sha224.ads,
        g-sha384.ads: Minor reformatting
 
index ec37642..0f2d283 100644 (file)
 --                                                                          --
 ------------------------------------------------------------------------------
 
---  Why is this package undocumented ???
+--  This package implements the MD5 Message-Digest Algorithm as described in
+--  RFC 1321. The complete text of RFC 1321 can be found at:
+--          http://www.ietf.org/rfc/rfc1321.txt
+
+--  See the declaration of System.Secure_Hashes.H in s-sechas.ads for complete
+--  documentation.
 
 with System.Secure_Hashes.MD5;
+
 package GNAT.MD5 is new System.Secure_Hashes.H
   (Block_Words    => System.Secure_Hashes.MD5.Block_Words,
    State_Words    => 4,
index a7d8e4c..8570923 100644 (file)
 --                                                                          --
 ------------------------------------------------------------------------------
 
---  Why no documentation ???
+--  This package implaments the SHA-1 secure hash function as decsribed in
+--  FIPS PUB 180-3. The complete text of FIPS PUB 180-3 can be found at:
+--    http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf
+
+--  See the declaration of System.Secure_Hashes.H in s-sechas.ads for complete
+--  documentation.
 
 with System.Secure_Hashes.SHA1;
+
 package GNAT.SHA1 is new System.Secure_Hashes.H
   (Block_Words    => System.Secure_Hashes.SHA1.Block_Words,
    State_Words    => 5,
index 9b93a19..c79f87f 100644 (file)
 --                                                                          --
 ------------------------------------------------------------------------------
 
+--  This package implaments the SHA-224 secure hash function as decsribed in
+--  FIPS PUB 180-3. The complete text of FIPS PUB 180-3 can be found at:
+--    http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf
+
+--  See the declaration of System.Secure_Hashes.H in s-sechas.ads for complete
+--  documentation.
+
 with System.Secure_Hashes.SHA2_Common;
 with System.Secure_Hashes.SHA2_32;
 
index ee8177f..a45e057 100644 (file)
 --                                                                          --
 ------------------------------------------------------------------------------
 
+--  This package implaments the SHA-256 secure hash function as decsribed in
+--  FIPS PUB 180-3. The complete text of FIPS PUB 180-3 can be found at:
+--    http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf
+
+--  See the declaration of System.Secure_Hashes.H in s-sechas.ads for complete
+--  documentation.
+
 with System.Secure_Hashes.SHA2_Common;
 with System.Secure_Hashes.SHA2_32;
 
index 4c1b8b5..262fb92 100644 (file)
 --                                                                          --
 ------------------------------------------------------------------------------
 
+--  This package implaments the SHA-384 secure hash function as decsribed in
+--  FIPS PUB 180-3. The complete text of FIPS PUB 180-3 can be found at:
+--    http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf
+
+--  See the declaration of System.Secure_Hashes.H in s-sechas.ads for complete
+--  documentation.
+
 with System.Secure_Hashes.SHA2_Common;
 with System.Secure_Hashes.SHA2_64;
 
index c8ebd32..dad8079 100644 (file)
 --                                                                          --
 ------------------------------------------------------------------------------
 
+--  This package implaments the SHA-512 secure hash function as decsribed in
+--  FIPS PUB 180-3. The complete text of FIPS PUB 180-3 can be found at:
+--    http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf
+
+--  See the declaration of System.Secure_Hashes.H in s-sechas.ads for complete
+--  documentation.
+
 with System.Secure_Hashes.SHA2_Common;
 with System.Secure_Hashes.SHA2_64;
 
index eeba801..ae827ba 100644 (file)
@@ -737,9 +737,11 @@ private
 
    File_Attributes_Size : constant Natural := 24;
    --  This should be big enough to fit a "struct file_attributes" on any
-   --  system. It doesn't matter if it is too big (which avoids the need for
-   --  either mapping the struct exactly or importing the sizeof from C, which
-   --  would result in dynamic code)
+   --  system. It doesn't cause any malfunction if it is too big (which avoids
+   --  the need for either mapping the struct exactly or importing the sizeof
+   --  from C, which would result in dynamic code). However, it does waste
+   --  space (e.g. when a component of this type appears in a record, if it is
+   --  unnecessarily large.
 
    type File_Attributes is
      array (1 .. File_Attributes_Size)
index 0b1fab3..d34f049 100644 (file)
@@ -46,8 +46,9 @@ package body System.Secure_Hashes is
         S     : String;
         First : Natural;
         Last  : out Natural);
-   --  A procedure to transfer data from S into M's block buffer until either
-   --  the block buffer is full or all data from S has been consumed.
+   --  A procedure to transfer data from S, starting at First, into M's block
+   --  buffer until either the block buffer is full or all data from S has been
+   --  consumed.
 
    procedure Fill_Buffer_Copy
      (M     : in out Message_State;
@@ -61,7 +62,12 @@ package body System.Secure_Hashes is
       S     : String;
       First : Natural;
       Last  : out Natural);
-   --  Transfer procedure which swaps bytes from S when copying into M
+   --  Transfer procedure which swaps bytes from S when copying into M. S must
+   --  have even length. Note that the swapping is performed considering pairs
+   --  starting at S'First, even if S'First /= First (that is, if
+   --  First = S'First then the first copied byte is always S (S'First + 1),
+   --  and if First = S'First + 1 then the first copied byte is always
+   --  S (S'First).
 
    procedure To_String (SEA : Stream_Element_Array; S : out String);
    --  Return the hexadecimal representation of SEA
@@ -102,13 +108,16 @@ package body System.Secure_Hashes is
       First : Natural;
       Last  : out Natural)
    is
+      pragma Assert (S'Length mod 2 = 0);
       Length : constant Natural :=
                   Natural'Min (M.Block_Length - M.Last, S'Last - First + 1);
    begin
       Last := First;
       while Last - First < Length loop
          M.Buffer (M.Last + 1 + Last - First) :=
-            (if (Last - First) mod 2 = 0 then S (Last + 1) else S (Last - 1));
+           (if (Last - S'First) mod 2 = 0
+            then S (Last + 1)
+            else S (Last - 1));
          Last := Last + 1;
       end loop;
       M.Last := M.Last + Length;