comparison libtomcrypt/src/mac/hmac/hmac_memory.c @ 382:0cbe8f6dbf9e

propagate from branch 'au.asn.ucc.matt.ltc.dropbear' (head 2af22fb4e878750b88f80f90d439b316d229796f) to branch 'au.asn.ucc.matt.dropbear' (head 02c413252c90e9de8e03d91e9939dde3029f5c0a)
author Matt Johnston <matt@ucc.asn.au>
date Thu, 11 Jan 2007 02:41:05 +0000
parents 1b9e69c058d2
children f849a5ca2efc
comparison
equal deleted inserted replaced
379:b66a00272a90 382:0cbe8f6dbf9e
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 $ */