X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fhmac-md5.c;h=d4e807ef0d625fbdc29e512edfdf7134e85f7792;hb=35dda7458879acb367f2cba0aaf7856cd98f5b63;hp=6df653d276ac2465084c89a304e420888e67f6ec;hpb=f6800ee02280d07036209444b32109c54c98ff64;p=gnulib.git diff --git a/lib/hmac-md5.c b/lib/hmac-md5.c index 6df653d27..d4e807ef0 100644 --- a/lib/hmac-md5.c +++ b/lib/hmac-md5.c @@ -1,5 +1,5 @@ /* hmac-md5.c -- hashed message authentication codes - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,12 +17,11 @@ /* Written by Simon Josefsson. */ -#ifdef HAVE_CONFIG_H -# include -#endif +#include #include "hmac.h" +#include "memxor.h" #include "md5.h" #include @@ -40,6 +39,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; @@ -52,6 +53,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)); @@ -62,6 +65,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));