1 /*
2  * Copyright (c) 2009 Bob Deblier
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 hmacsha224.c
21  * \brief HMAC-SHA-224 message digest algorithm.
22  * \author Bob Deblier <bob.deblier@telenet.be>
23  * \ingroup HMAC_m HMAC_sha224_m
24  */
25 
26 #define BEECRYPT_DLL_EXPORT
27 
28 #if HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31 
32 #include "beecrypt/hmacsha224.h"
33 
34 /*!\addtogroup HMAC_sha224_m
35  * \{
36  */
37 
38 const keyedHashFunction hmacsha224 = {
39 	"HMAC-SHA-224",
40 	sizeof(hmacsha224Param),
41 	64,
42 	28,
43 	64,
44 	512,
45 	32,
46 	(keyedHashFunctionSetup) hmacsha224Setup,
47 	(keyedHashFunctionReset) hmacsha224Reset,
48 	(keyedHashFunctionUpdate) hmacsha224Update,
49 	(keyedHashFunctionDigest) hmacsha224Digest
50 };
51 
hmacsha224Setup(hmacsha224Param * sp,const byte * key,size_t keybits)52 int hmacsha224Setup (hmacsha224Param* sp, const byte* key, size_t keybits)
53 {
54 	return hmacSetup(sp->kxi, sp->kxo, &sha224, &sp->sparam, key, keybits);
55 }
56 
hmacsha224Reset(hmacsha224Param * sp)57 int hmacsha224Reset (hmacsha224Param* sp)
58 {
59 	return hmacReset(sp->kxi, &sha224, &sp->sparam);
60 }
61 
hmacsha224Update(hmacsha224Param * sp,const byte * data,size_t size)62 int hmacsha224Update(hmacsha224Param* sp, const byte* data, size_t size)
63 {
64 	return hmacUpdate(&sha224, &sp->sparam, data, size);
65 }
66 
hmacsha224Digest(hmacsha224Param * sp,byte * data)67 int hmacsha224Digest(hmacsha224Param* sp, byte* data)
68 {
69 	return hmacDigest(sp->kxo, &sha224, &sp->sparam, data);
70 }
71 
72 /*!\}
73  */
74