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
21 POLY1305 multiple blocks of memory to produce the authentication tag
22 @param key The secret key
23 @param keylen The length of the secret key (octets)
24 @param mac [out] Destination of the authentication tag
25 @param maclen [in/out] Max size and resulting size of authentication tag
26 @param in The data to POLY1305
27 @param inlen The length of the data to POLY1305 (octets)
28 @param ... tuples of (data,len) pairs to POLY1305, terminated with a (NULL,x) (x=don't care)
29 @return CRYPT_OK if successful
31 int poly1305_memory_multi(const unsigned char *key, unsigned long keylen, unsigned char *mac, unsigned long *maclen, const unsigned char *in, unsigned long inlen, ...)
36 const unsigned char *curptr;
39 LTC_ARGCHK(key != NULL);
40 LTC_ARGCHK(in != NULL);
41 LTC_ARGCHK(mac != NULL);
42 LTC_ARGCHK(maclen != NULL);
44 va_start(args, inlen);
47 if ((err = poly1305_init(&st, key, keylen)) != CRYPT_OK) { goto LBL_ERR; }
49 if ((err = poly1305_process(&st, curptr, curlen)) != CRYPT_OK) { goto LBL_ERR; }
50 curptr = va_arg(args, const unsigned char*);
51 if (curptr == NULL) break;
52 curlen = va_arg(args, unsigned long);
54 err = poly1305_done(&st, mac, maclen);
56 #ifdef LTC_CLEAN_STACK
57 zeromem(&st, sizeof(poly1305_state));
65 /* ref: $Format:%D$ */
66 /* git commit: $Format:%H$ */
67 /* commit time: $Format:%ai$ */