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
16 BLAKE2B MAC multiple blocks of memory to produce the authentication tag
17 @param key The secret key
18 @param keylen The length of the secret key (octets)
19 @param mac [out] Destination of the authentication tag
20 @param maclen [in/out] Max size and resulting size of authentication tag
21 @param in The data to BLAKE2B MAC
22 @param inlen The length of the data to BLAKE2B MAC (octets)
23 @param ... tuples of (data,len) pairs to BLAKE2B MAC, terminated with a (NULL,x) (x=don't care)
24 @return CRYPT_OK if successful
26 int blake2bmac_memory_multi(const unsigned char *key, unsigned long keylen, unsigned char *mac, unsigned long *maclen, const unsigned char *in, unsigned long inlen, ...)
31 const unsigned char *curptr;
34 LTC_ARGCHK(key != NULL);
35 LTC_ARGCHK(in != NULL);
36 LTC_ARGCHK(mac != NULL);
37 LTC_ARGCHK(maclen != NULL);
39 va_start(args, inlen);
42 if ((err = blake2bmac_init(&st, *maclen, key, keylen)) != CRYPT_OK) { goto LBL_ERR; }
44 if ((err = blake2bmac_process(&st, curptr, curlen)) != CRYPT_OK) { goto LBL_ERR; }
45 curptr = va_arg(args, const unsigned char*);
46 if (curptr == NULL) break;
47 curlen = va_arg(args, unsigned long);
49 err = blake2bmac_done(&st, mac, maclen);
51 #ifdef LTC_CLEAN_STACK
52 zeromem(&st, sizeof(blake2bmac_state));
60 /* ref: $Format:%D$ */
61 /* git commit: $Format:%H$ */
62 /* commit time: $Format:%ai$ */