Mercurial > dropbear
comparison src/mac/hmac/hmac_memory.c @ 380:d5faf4814ddb libtomcrypt-orig libtomcrypt-1.16
Update to LibTomCrypt 1.16
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 11 Jan 2007 02:22:00 +0000 |
parents | 59400faa4b44 |
children |
comparison
equal
deleted
inserted
replaced
280:59400faa4b44 | 380:d5faf4814ddb |
---|---|
4 * algorithms in a highly modular and flexible manner. | 4 * algorithms in a highly modular and flexible manner. |
5 * | 5 * |
6 * The library is free for all purposes without any express | 6 * The library is free for all purposes without any express |
7 * guarantee it works. | 7 * guarantee it works. |
8 * | 8 * |
9 * Tom St Denis, [email protected], http://libtomcrypt.org | 9 * Tom St Denis, [email protected], http://libtomcrypt.com |
10 */ | 10 */ |
11 #include "tomcrypt.h" | 11 #include "tomcrypt.h" |
12 | 12 |
13 /** | 13 /** |
14 @file hmac_memory.c | 14 @file hmac_memory.c |
15 HMAC support, process a block of memory, Tom St Denis/Dobes Vandermeer | 15 HMAC support, process a block of memory, Tom St Denis/Dobes Vandermeer |
16 */ | 16 */ |
17 | 17 |
18 #ifdef HMAC | 18 #ifdef LTC_HMAC |
19 | 19 |
20 /** | 20 /** |
21 HMAC a block of memory to produce the authentication tag | 21 HMAC a block of memory to produce the authentication tag |
22 @param hash The index of the hash to use | 22 @param hash The index of the hash to use |
23 @param key The secret key | 23 @param key The secret key |
32 const unsigned char *key, unsigned long keylen, | 32 const unsigned char *key, unsigned long keylen, |
33 const unsigned char *in, unsigned long inlen, | 33 const unsigned char *in, unsigned long inlen, |
34 unsigned char *out, unsigned long *outlen) | 34 unsigned char *out, unsigned long *outlen) |
35 { | 35 { |
36 hmac_state *hmac; | 36 hmac_state *hmac; |
37 int err; | 37 int err; |
38 | 38 |
39 LTC_ARGCHK(key != NULL); | 39 LTC_ARGCHK(key != NULL); |
40 LTC_ARGCHK(in != NULL); | 40 LTC_ARGCHK(in != NULL); |
41 LTC_ARGCHK(out != NULL); | 41 LTC_ARGCHK(out != NULL); |
42 LTC_ARGCHK(outlen != NULL); | 42 LTC_ARGCHK(outlen != NULL); |
43 | 43 |
44 /* make sure hash descriptor is valid */ | |
45 if ((err = hash_is_valid(hash)) != CRYPT_OK) { | |
46 return err; | |
47 } | |
48 | |
49 /* is there a descriptor? */ | |
50 if (hash_descriptor[hash].hmac_block != NULL) { | |
51 return hash_descriptor[hash].hmac_block(key, keylen, in, inlen, out, outlen); | |
52 } | |
53 | |
54 /* nope, so call the hmac functions */ | |
44 /* allocate ram for hmac state */ | 55 /* allocate ram for hmac state */ |
45 hmac = XMALLOC(sizeof(hmac_state)); | 56 hmac = XMALLOC(sizeof(hmac_state)); |
46 if (hmac == NULL) { | 57 if (hmac == NULL) { |
47 return CRYPT_MEM; | 58 return CRYPT_MEM; |
48 } | 59 } |
71 | 82 |
72 #endif | 83 #endif |
73 | 84 |
74 | 85 |
75 /* $Source: /cvs/libtom/libtomcrypt/src/mac/hmac/hmac_memory.c,v $ */ | 86 /* $Source: /cvs/libtom/libtomcrypt/src/mac/hmac/hmac_memory.c,v $ */ |
76 /* $Revision: 1.3 $ */ | 87 /* $Revision: 1.6 $ */ |
77 /* $Date: 2005/05/05 14:35:58 $ */ | 88 /* $Date: 2006/11/03 00:39:49 $ */ |