Mercurial > dropbear
comparison libtomcrypt/src/mac/hmac/hmac_memory.c @ 1471:6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 09 Feb 2018 21:44:05 +0800 |
parents | f849a5ca2efc |
children |
comparison
equal
deleted
inserted
replaced
1470:8bba51a55704 | 1471:6dba84798cd5 |
---|---|
3 * LibTomCrypt is a library that provides various cryptographic | 3 * LibTomCrypt is a library that provides various cryptographic |
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 * | |
9 * Tom St Denis, [email protected], http://libtom.org | |
10 */ | 8 */ |
11 #include "tomcrypt.h" | 9 #include "tomcrypt.h" |
12 | 10 |
13 /** | 11 /** |
14 @file hmac_memory.c | 12 @file hmac_memory.c |
15 LTC_HMAC support, process a block of memory, Tom St Denis/Dobes Vandermeer | 13 HMAC support, process a block of memory, Tom St Denis/Dobes Vandermeer |
16 */ | 14 */ |
17 | 15 |
18 #ifdef LTC_HMAC | 16 #ifdef LTC_HMAC |
19 | 17 |
20 /** | 18 /** |
21 LTC_HMAC a block of memory to produce the authentication tag | 19 HMAC a block of memory to produce the authentication tag |
22 @param hash The index of the hash to use | 20 @param hash The index of the hash to use |
23 @param key The secret key | 21 @param key The secret key |
24 @param keylen The length of the secret key (octets) | 22 @param keylen The length of the secret key (octets) |
25 @param in The data to LTC_HMAC | 23 @param in The data to HMAC |
26 @param inlen The length of the data to LTC_HMAC (octets) | 24 @param inlen The length of the data to HMAC (octets) |
27 @param out [out] Destination of the authentication tag | 25 @param out [out] Destination of the authentication tag |
28 @param outlen [in/out] Max size and resulting size of authentication tag | 26 @param outlen [in/out] Max size and resulting size of authentication tag |
29 @return CRYPT_OK if successful | 27 @return CRYPT_OK if successful |
30 */ | 28 */ |
31 int hmac_memory(int hash, | 29 int hmac_memory(int hash, |
32 const unsigned char *key, unsigned long keylen, | 30 const unsigned char *key, unsigned long keylen, |
33 const unsigned char *in, unsigned long inlen, | 31 const unsigned char *in, unsigned long inlen, |
34 unsigned char *out, unsigned long *outlen) | 32 unsigned char *out, unsigned long *outlen) |
35 { | 33 { |
36 hmac_state *hmac; | 34 hmac_state *hmac; |
37 int err; | 35 int err; |
38 | 36 |
39 LTC_ARGCHK(key != NULL); | 37 LTC_ARGCHK(key != NULL); |
40 LTC_ARGCHK(in != NULL); | 38 LTC_ARGCHK(in != NULL); |
41 LTC_ARGCHK(out != NULL); | 39 LTC_ARGCHK(out != NULL); |
42 LTC_ARGCHK(outlen != NULL); | 40 LTC_ARGCHK(outlen != NULL); |
43 | 41 |
44 /* make sure hash descriptor is valid */ | 42 /* make sure hash descriptor is valid */ |
45 if ((err = hash_is_valid(hash)) != CRYPT_OK) { | 43 if ((err = hash_is_valid(hash)) != CRYPT_OK) { |
46 return err; | 44 return err; |
75 #ifdef LTC_CLEAN_STACK | 73 #ifdef LTC_CLEAN_STACK |
76 zeromem(hmac, sizeof(hmac_state)); | 74 zeromem(hmac, sizeof(hmac_state)); |
77 #endif | 75 #endif |
78 | 76 |
79 XFREE(hmac); | 77 XFREE(hmac); |
80 return err; | 78 return err; |
81 } | 79 } |
82 | 80 |
83 #endif | 81 #endif |
84 | 82 |
85 | 83 |
86 /* $Source$ */ | 84 /* ref: $Format:%D$ */ |
87 /* $Revision$ */ | 85 /* git commit: $Format:%H$ */ |
88 /* $Date$ */ | 86 /* commit time: $Format:%ai$ */ |