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
15 BLAKE2B MAC a block of memory to produce the authentication tag
16 @param key The secret key
17 @param keylen The length of the secret key (octets)
18 @param in The data to BLAKE2B MAC
19 @param inlen The length of the data to BLAKE2B MAC (octets)
20 @param mac [out] Destination of the authentication tag
21 @param maclen [in/out] Max size and resulting size of authentication tag
22 @return CRYPT_OK if successful
24 int blake2bmac_memory(const unsigned char *key, unsigned long keylen, const unsigned char *in, unsigned long inlen, unsigned char *mac, unsigned long *maclen)
29 LTC_ARGCHK(key != NULL);
30 LTC_ARGCHK(in != NULL);
31 LTC_ARGCHK(mac != NULL);
32 LTC_ARGCHK(maclen != NULL);
34 if ((err = blake2bmac_init(&st, *maclen, key, keylen)) != CRYPT_OK) { goto LBL_ERR; }
35 if ((err = blake2bmac_process(&st, in, inlen)) != CRYPT_OK) { goto LBL_ERR; }
36 err = blake2bmac_done(&st, mac, maclen);
38 #ifdef LTC_CLEAN_STACK
39 zeromem(&st, sizeof(blake2bmac_state));
46 /* ref: $Format:%D$ */
47 /* git commit: $Format:%H$ */
48 /* commit time: $Format:%ai$ */