Mercurial > dropbear
comparison libtomcrypt/src/mac/poly1305/poly1305_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 /* The implementation is based on: | |
11 * Public Domain poly1305 from Andrew Moon | |
12 * https://github.com/floodyberry/poly1305-donna | |
13 */ | |
14 | |
15 #include "tomcrypt.h" | |
16 | |
17 #ifdef LTC_POLY1305 | |
18 | |
19 /** | |
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 | |
28 */ | |
29 int poly1305_memory(const unsigned char *key, unsigned long keylen, const unsigned char *in, unsigned long inlen, unsigned char *mac, unsigned long *maclen) | |
30 { | |
31 poly1305_state st; | |
32 int err; | |
33 | |
34 LTC_ARGCHK(key != NULL); | |
35 LTC_ARGCHK(in != NULL); | |
36 LTC_ARGCHK(mac != NULL); | |
37 LTC_ARGCHK(maclen != NULL); | |
38 | |
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); | |
42 LBL_ERR: | |
43 #ifdef LTC_CLEAN_STACK | |
44 zeromem(&st, sizeof(poly1305_state)); | |
45 #endif | |
46 return err; | |
47 } | |
48 | |
49 #endif | |
50 | |
51 /* ref: $Format:%D$ */ | |
52 /* git commit: $Format:%H$ */ | |
53 /* commit time: $Format:%ai$ */ |