1 /*
2  * Copyright (c) 2000, 2001, 2002 X-Way Rights BV
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  *
18  */
19 
20 /*!\file hmacmd5.c
21  * \brief HMAC-MD5 message authentication code.
22  *
23  * \see RFC2202 - Test Cases for HMAC-MD5 and HMAC-SHA-1.
24  *                P. Cheng, R. Glenn.
25  *
26  * \author Bob Deblier <bob.deblier@telenet.be>
27  * \ingroup HMAC_m HMAC_md5_m
28  */
29 
30 #define BEECRYPT_DLL_EXPORT
31 
32 #if HAVE_CONFIG_H
33 # include "config.h"
34 #endif
35 
36 #include "beecrypt/hmacmd5.h"
37 
38 /*!\addtogroup HMAC_md5_m
39  * \{
40  */
41 
42 const keyedHashFunction hmacmd5 = {
43 	"HMAC-MD5",
44 	sizeof(hmacmd5Param),
45 	64,
46 	16,
47 	64,
48 	512,
49 	32,
50 	(keyedHashFunctionSetup) hmacmd5Setup,
51 	(keyedHashFunctionReset) hmacmd5Reset,
52 	(keyedHashFunctionUpdate) hmacmd5Update,
53 	(keyedHashFunctionDigest) hmacmd5Digest
54 };
55 
hmacmd5Setup(hmacmd5Param * sp,const byte * key,size_t keybits)56 int hmacmd5Setup (hmacmd5Param* sp, const byte* key, size_t keybits)
57 {
58 	return hmacSetup(sp->kxi, sp->kxo, &md5, &sp->mparam, key, keybits);
59 }
60 
hmacmd5Reset(hmacmd5Param * sp)61 int hmacmd5Reset (hmacmd5Param* sp)
62 {
63 	return hmacReset(sp->kxi, &md5, &sp->mparam);
64 }
65 
hmacmd5Update(hmacmd5Param * sp,const byte * data,size_t size)66 int hmacmd5Update(hmacmd5Param* sp, const byte* data, size_t size)
67 {
68 	return hmacUpdate(&md5, &sp->mparam, data, size);
69 }
70 
hmacmd5Digest(hmacmd5Param * sp,byte * data)71 int hmacmd5Digest(hmacmd5Param* sp, byte* data)
72 {
73 	return hmacDigest(sp->kxo, &md5, &sp->mparam, data);
74 }
75 
76 /*!\}
77  */
78