1
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
3
* LibTomCrypt is a library that provides various cryptographic
4
* algorithms in a highly modular and flexible manner.
6
* The library is free for all purposes without any express
9
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
15
@file hmac_memory_multi.c
16
HMAC support, process multiple blocks of memory, Tom St Denis/Dobes Vandermeer
22
HMAC multiple blocks of memory to produce the authentication tag
23
@param hash The index of the hash to use
24
@param key The secret key
25
@param keylen The length of the secret key (octets)
26
@param out [out] Destination of the authentication tag
27
@param outlen [in/out] Max size and resulting size of authentication tag
28
@param in The data to HMAC
29
@param inlen The length of the data to HMAC (octets)
30
@param ... tuples of (data,len) pairs to HMAC, terminated with a (NULL,x) (x=don't care)
31
@return CRYPT_OK if successful
33
int hmac_memory_multi(int hash,
34
const unsigned char *key, unsigned long keylen,
35
unsigned char *out, unsigned long *outlen,
36
const unsigned char *in, unsigned long inlen, ...)
42
const unsigned char *curptr;
45
LTC_ARGCHK(key != NULL);
46
LTC_ARGCHK(in != NULL);
47
LTC_ARGCHK(out != NULL);
48
LTC_ARGCHK(outlen != NULL);
50
/* allocate ram for hmac state */
51
hmac = XMALLOC(sizeof(hmac_state));
56
if ((err = hmac_init(hmac, hash, key, keylen)) != CRYPT_OK) {
60
va_start(args, inlen);
65
if ((err = hmac_process(hmac, curptr, curlen)) != CRYPT_OK) {
69
curptr = va_arg(args, const unsigned char*);
73
curlen = va_arg(args, unsigned long);
75
if ((err = hmac_done(hmac, out, outlen)) != CRYPT_OK) {
79
#ifdef LTC_CLEAN_STACK
80
zeromem(hmac, sizeof(hmac_state));
90
/* $Source: /cvs/libtom/libtomcrypt/src/mac/hmac/hmac_memory_multi.c,v $ */
91
/* $Revision: 1.3 $ */
92
/* $Date: 2005/05/05 14:35:58 $ */