From: Simon Josefsson Date: Fri, 21 Oct 2005 12:49:28 +0000 (+0000) Subject: * hmac-md5.c (hmac_md5): Add comments, suggested by Bruno Haible X-Git-Tag: cvs-readonly~2776 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=1db596967564cad38c222f82e6fad0b117a6dbc5;p=gnulib.git * hmac-md5.c (hmac_md5): Add comments, suggested by Bruno Haible . * hmac-sha1.c (hmac_sha1): Likewise. --- diff --git a/lib/ChangeLog b/lib/ChangeLog index ae05d1b5a..5206f03a3 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,5 +1,10 @@ 2005-10-21 Simon Josefsson + * hmac-md5.c (hmac_md5): Add comments, suggested by Bruno Haible + . + + * hmac-sha1.c (hmac_sha1): Likewise. + * crc.c (crc32_update): Actually use crc parameter, suggested by Bruno Haible . diff --git a/lib/hmac-md5.c b/lib/hmac-md5.c index ecd071496..816762b79 100644 --- a/lib/hmac-md5.c +++ b/lib/hmac-md5.c @@ -41,6 +41,8 @@ hmac_md5 (const void *key, size_t keylen, char block[64]; char innerhash[16]; + /* Reduce the key's size, so that it becomes <= 64 bytes large. */ + if (keylen > 64) { struct md5_ctx keyhash; @@ -53,6 +55,8 @@ hmac_md5 (const void *key, size_t keylen, keylen = 16; } + /* Compute INNERHASH from KEY and IN. */ + md5_init_ctx (&inner); memset (block, IPAD, sizeof (block)); @@ -63,6 +67,8 @@ hmac_md5 (const void *key, size_t keylen, md5_finish_ctx (&inner, innerhash); + /* Compute result from KEY and INNERHASH. */ + md5_init_ctx (&outer); memset (block, OPAD, sizeof (block)); diff --git a/lib/hmac-sha1.c b/lib/hmac-sha1.c index 9c9579129..f7a3fda43 100644 --- a/lib/hmac-sha1.c +++ b/lib/hmac-sha1.c @@ -41,6 +41,8 @@ hmac_sha1 (const void *key, size_t keylen, char block[64]; char innerhash[20]; + /* Reduce the key's size, so that it becomes <= 64 bytes large. */ + if (keylen > 64) { struct sha1_ctx keyhash; @@ -53,6 +55,8 @@ hmac_sha1 (const void *key, size_t keylen, keylen = 20; } + /* Compute INNERHASH from KEY and IN. */ + sha1_init_ctx (&inner); memset (block, IPAD, sizeof (block)); @@ -63,6 +67,8 @@ hmac_sha1 (const void *key, size_t keylen, sha1_finish_ctx (&inner, innerhash); + /* Compute result from KEY and INNERHASH. */ + sha1_init_ctx (&outer); memset (block, OPAD, sizeof (block));