diff options
author | Pascal Obry <obry@adacore.com> | 2012-10-29 10:26:36 +0000 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2012-10-29 11:26:36 +0100 |
commit | 59a9c170156ef6279a16711b3f74cc8e3ae42420 (patch) | |
tree | 81ffb9eac36cb733ac621833a4fdd6fe31665ad9 /gcc | |
parent | 63d0d1a376737338f737587dbe0efb98a7a8101d (diff) | |
download | gcc-59a9c170156ef6279a16711b3f74cc8e3ae42420.zip gcc-59a9c170156ef6279a16711b3f74cc8e3ae42420.tar.gz gcc-59a9c170156ef6279a16711b3f74cc8e3ae42420.tar.bz2 |
g-sechas.adb, [...]: (Binary_Message_Digest): New subtype.
2012-10-29 Pascal Obry <obry@adacore.com>
* g-sechas.adb, g-sechas.ads: (Binary_Message_Digest): New subtype.
(Digest): New versions returning a Binary_Message_Digest.
(Wide_Digest): Likewise.
From-SVN: r192921
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/ada/g-sechas.adb | 31 | ||||
-rw-r--r-- | gcc/ada/g-sechas.ads | 16 |
3 files changed, 53 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index f148bc8..b830454 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2012-10-29 Pascal Obry <obry@adacore.com> + + * g-sechas.adb, g-sechas.ads: (Binary_Message_Digest): New subtype. + (Digest): New versions returning a Binary_Message_Digest. + (Wide_Digest): Likewise. + 2012-10-29 Robert Dewar <dewar@adacore.com> * warnsw.adb: Complete previous change. diff --git a/gcc/ada/g-sechas.adb b/gcc/ada/g-sechas.adb index 921ef3e..87531a1 100644 --- a/gcc/ada/g-sechas.adb +++ b/gcc/ada/g-sechas.adb @@ -184,6 +184,30 @@ package body GNAT.Secure_Hashes is return Digest (C); end Digest; + function Digest (C : Context) return Binary_Message_Digest is + Hash_Bits : Stream_Element_Array + (1 .. Stream_Element_Offset (Hash_Length)); + begin + Final (C, Hash_Bits); + return Hash_Bits; + end Digest; + + function Digest (S : String) return Binary_Message_Digest is + C : Context; + begin + Update (C, S); + return Digest (C); + end Digest; + + function Digest + (A : Stream_Element_Array) return Binary_Message_Digest + is + C : Context; + begin + Update (C, A); + return Digest (C); + end Digest; + ----------- -- Final -- ----------- @@ -325,6 +349,13 @@ package body GNAT.Secure_Hashes is return Digest (C); end Wide_Digest; + function Wide_Digest (W : Wide_String) return Binary_Message_Digest is + C : Context; + begin + Wide_Update (C, W); + return Digest (C); + end Wide_Digest; + end H; ------------------------- diff --git a/gcc/ada/g-sechas.ads b/gcc/ada/g-sechas.ads index 243bd60..55f44c6 100644 --- a/gcc/ada/g-sechas.ads +++ b/gcc/ada/g-sechas.ads @@ -156,6 +156,22 @@ package GNAT.Secure_Hashes is Word_Length : constant Natural := Hash_State.Word'Size / 8; Hash_Length : constant Natural := Hash_Words * Word_Length; + subtype Binary_Message_Digest is + Stream_Element_Array (1 .. Stream_Element_Offset (Hash_Length)); + -- The fixed-length byte array returned by Digest, providing + -- the hash in binary representation. + + function Digest (C : Context) return Binary_Message_Digest; + -- Return hash for the data accumulated with C + + function Digest (S : String) return Binary_Message_Digest; + function Wide_Digest (W : Wide_String) return Binary_Message_Digest; + function Digest + (A : Stream_Element_Array) return Binary_Message_Digest; + -- These functions are equivalent to the corresponding Update (or + -- Wide_Update) on a default initialized Context, followed by Digest + -- on the resulting Context. + subtype Message_Digest is String (1 .. 2 * Hash_Length); -- The fixed-length string returned by Digest, providing the hash in -- hexadecimal representation. |