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 Initialize an BLAKE2B MAC context.
16 @param st The BLAKE2B MAC state
17 @param outlen The size of the MAC output (octets)
18 @param key The secret key
19 @param keylen The length of the secret key (octets)
20 @return CRYPT_OK if successful
22 int blake2bmac_init(blake2bmac_state *st, unsigned long outlen, const unsigned char *key, unsigned long keylen)
24 LTC_ARGCHK(st != NULL);
25 LTC_ARGCHK(key != NULL);
26 return blake2b_init(st, outlen, key, keylen);
30 Process data through BLAKE2B MAC
31 @param st The BLAKE2B MAC state
32 @param in The data to send through HMAC
33 @param inlen The length of the data to HMAC (octets)
34 @return CRYPT_OK if successful
36 int blake2bmac_process(blake2bmac_state *st, const unsigned char *in, unsigned long inlen)
38 if (inlen == 0) return CRYPT_OK; /* nothing to do */
39 LTC_ARGCHK(st != NULL);
40 LTC_ARGCHK(in != NULL);
41 return blake2b_process(st, in, inlen);
45 Terminate a BLAKE2B MAC session
46 @param st The BLAKE2B MAC state
47 @param mac [out] The destination of the BLAKE2B MAC authentication tag
48 @param maclen [in/out] The max size and resulting size of the BLAKE2B MAC authentication tag
49 @return CRYPT_OK if successful
51 int blake2bmac_done(blake2bmac_state *st, unsigned char *mac, unsigned long *maclen)
53 LTC_ARGCHK(st != NULL);
54 LTC_ARGCHK(mac != NULL);
55 LTC_ARGCHK(maclen != NULL);
56 LTC_ARGCHK(*maclen >= st->blake2b.outlen);
58 *maclen = st->blake2b.outlen;
59 return blake2b_done(st, mac);
64 /* ref: $Format:%D$ */
65 /* git commit: $Format:%H$ */
66 /* commit time: $Format:%ai$ */