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