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
10 /* The implementation is based on:
11 * Public Domain poly1305 from Andrew Moon
12 * https://github.com/floodyberry/poly1305-donna
20 POLY1305 a block of memory to produce the authentication tag
21 @param key The secret key
22 @param keylen The length of the secret key (octets)
23 @param in The data to POLY1305
24 @param inlen The length of the data to POLY1305 (octets)
25 @param mac [out] Destination of the authentication tag
26 @param maclen [in/out] Max size and resulting size of authentication tag
27 @return CRYPT_OK if successful
29 int poly1305_memory(const unsigned char *key, unsigned long keylen, const unsigned char *in, unsigned long inlen, unsigned char *mac, unsigned long *maclen)
34 LTC_ARGCHK(key != NULL);
35 LTC_ARGCHK(in != NULL);
36 LTC_ARGCHK(mac != NULL);
37 LTC_ARGCHK(maclen != NULL);
39 if ((err = poly1305_init(&st, key, keylen)) != CRYPT_OK) { goto LBL_ERR; }
40 if ((err = poly1305_process(&st, in, inlen)) != CRYPT_OK) { goto LBL_ERR; }
41 err = poly1305_done(&st, mac, maclen);
43 #ifdef LTC_CLEAN_STACK
44 zeromem(&st, sizeof(poly1305_state));
51 /* ref: $Format:%D$ */
52 /* git commit: $Format:%H$ */
53 /* commit time: $Format:%ai$ */