This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Support for hash based message authentication codes


This change introduces a new subprogram in the GNAT secure hash
framework to allow computing HMACs based on the secure hash functions.
This is achieved by initializing a context with a (non-empty) key.

The following example shows how to compute the first HMAC-MD5 test from
RFC2104:

$ gnatmake -q rfc2104_test1.adb
$ ./rfc2104_test1 
9294727a3638bb1c13f48ef8158bfc9d

with Ada.Text_IO; use Ada.Text_IO;
with GNAT.MD5;    use GNAT.MD5;
procedure RFC2104_Test1 is
   C : Context := HMAC_Initial_Context ((1 .. 16 => Character'Val (16#0b#)));
begin
   Update (C, "Hi There");
   Put_Line (Digest (C));
end RFC2104_Test1;

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-08-04  Thomas Quinot  <quinot@adacore.com>

	* g-sechas.ads, g-sechas.adb (HMAC_Initial_Context): New subprogram.
	* gnat_rm.texi (GNAT.MD5/SHA1/SHA224/SHA256/SHA512): Document support
	for HMAC.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]