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
-- --
------------------------------------------------------------------------------
--- 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,
-- --
------------------------------------------------------------------------------
--- 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,
-- --
------------------------------------------------------------------------------
+-- 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;
-- --
------------------------------------------------------------------------------
+-- 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;
-- --
------------------------------------------------------------------------------
+-- 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;
-- --
------------------------------------------------------------------------------
+-- 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;
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)
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;
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
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;