[multiple changes]

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.

From-SVN: r154819
This commit is contained in:
Arnaud Charlet 2009-11-30 16:16:49 +01:00
parent 40513dd30b
commit eaf180889e
9 changed files with 70 additions and 9 deletions

View File

@ -1,3 +1,13 @@
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> 2009-11-30 Robert Dewar <dewar@adacore.com>
* g-sha256.ads, s-sehamd.ads, s-sehamd.adb, g-sha512.ads, g-sha224.ads, * g-sha256.ads, s-sehamd.ads, s-sehamd.adb, g-sha512.ads, g-sha224.ads,

View File

@ -31,9 +31,15 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- 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; with System.Secure_Hashes.MD5;
package GNAT.MD5 is new System.Secure_Hashes.H package GNAT.MD5 is new System.Secure_Hashes.H
(Block_Words => System.Secure_Hashes.MD5.Block_Words, (Block_Words => System.Secure_Hashes.MD5.Block_Words,
State_Words => 4, State_Words => 4,

View File

@ -31,9 +31,15 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- 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; with System.Secure_Hashes.SHA1;
package GNAT.SHA1 is new System.Secure_Hashes.H package GNAT.SHA1 is new System.Secure_Hashes.H
(Block_Words => System.Secure_Hashes.SHA1.Block_Words, (Block_Words => System.Secure_Hashes.SHA1.Block_Words,
State_Words => 5, State_Words => 5,

View File

@ -29,6 +29,13 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- 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_Common;
with System.Secure_Hashes.SHA2_32; with System.Secure_Hashes.SHA2_32;

View File

@ -29,6 +29,13 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- 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_Common;
with System.Secure_Hashes.SHA2_32; with System.Secure_Hashes.SHA2_32;

View File

@ -29,6 +29,13 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- 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_Common;
with System.Secure_Hashes.SHA2_64; with System.Secure_Hashes.SHA2_64;

View File

@ -29,6 +29,13 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- 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_Common;
with System.Secure_Hashes.SHA2_64; with System.Secure_Hashes.SHA2_64;

View File

@ -737,9 +737,11 @@ private
File_Attributes_Size : constant Natural := 24; File_Attributes_Size : constant Natural := 24;
-- This should be big enough to fit a "struct file_attributes" on any -- 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 -- system. It doesn't cause any malfunction if it is too big (which avoids
-- either mapping the struct exactly or importing the sizeof from C, which -- the need for either mapping the struct exactly or importing the sizeof
-- would result in dynamic code) -- 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 type File_Attributes is
array (1 .. File_Attributes_Size) array (1 .. File_Attributes_Size)

View File

@ -46,8 +46,9 @@ package body System.Secure_Hashes is
S : String; S : String;
First : Natural; First : Natural;
Last : out Natural); Last : out Natural);
-- A procedure to transfer data from S into M's block buffer until either -- A procedure to transfer data from S, starting at First, into M's block
-- the block buffer is full or all data from S has been consumed. -- buffer until either the block buffer is full or all data from S has been
-- consumed.
procedure Fill_Buffer_Copy procedure Fill_Buffer_Copy
(M : in out Message_State; (M : in out Message_State;
@ -61,7 +62,12 @@ package body System.Secure_Hashes is
S : String; S : String;
First : Natural; First : Natural;
Last : out 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); procedure To_String (SEA : Stream_Element_Array; S : out String);
-- Return the hexadecimal representation of SEA -- Return the hexadecimal representation of SEA
@ -102,13 +108,16 @@ package body System.Secure_Hashes is
First : Natural; First : Natural;
Last : out Natural) Last : out Natural)
is is
pragma Assert (S'Length mod 2 = 0);
Length : constant Natural := Length : constant Natural :=
Natural'Min (M.Block_Length - M.Last, S'Last - First + 1); Natural'Min (M.Block_Length - M.Last, S'Last - First + 1);
begin begin
Last := First; Last := First;
while Last - First < Length loop while Last - First < Length loop
M.Buffer (M.Last + 1 + Last - First) := 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; Last := Last + 1;
end loop; end loop;
M.Last := M.Last + Length; M.Last := M.Last + Length;