comparison libtomcrypt/src/mac/blake2/blake2smac_memory.c @ 1471:6dba84798cd5

Update to libtomcrypt 1.18.1, merged with Dropbear changes
author Matt Johnston <matt@ucc.asn.au>
date Fri, 09 Feb 2018 21:44:05 +0800
parents
children
comparison
equal deleted inserted replaced
1470:8bba51a55704 1471:6dba84798cd5
1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
2 *
3 * LibTomCrypt is a library that provides various cryptographic
4 * algorithms in a highly modular and flexible manner.
5 *
6 * The library is free for all purposes without any express
7 * guarantee it works.
8 */
9
10 #include "tomcrypt.h"
11
12 #ifdef LTC_BLAKE2SMAC
13
14 /**
15 BLAKE2S 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 BLAKE2S MAC
19 @param inlen The length of the data to BLAKE2S 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
23 */
24 int blake2smac_memory(const unsigned char *key, unsigned long keylen, const unsigned char *in, unsigned long inlen, unsigned char *mac, unsigned long *maclen)
25 {
26 blake2smac_state st;
27 int err;
28
29 LTC_ARGCHK(key != NULL);
30 LTC_ARGCHK(in != NULL);
31 LTC_ARGCHK(mac != NULL);
32 LTC_ARGCHK(maclen != NULL);
33
34 if ((err = blake2smac_init(&st, *maclen, key, keylen)) != CRYPT_OK) { goto LBL_ERR; }
35 if ((err = blake2smac_process(&st, in, inlen)) != CRYPT_OK) { goto LBL_ERR; }
36 err = blake2smac_done(&st, mac, maclen);
37 LBL_ERR:
38 #ifdef LTC_CLEAN_STACK
39 zeromem(&st, sizeof(blake2smac_state));
40 #endif
41 return err;
42 }
43
44 #endif
45
46 /* ref: $Format:%D$ */
47 /* git commit: $Format:%H$ */
48 /* commit time: $Format:%ai$ */