poly_state > poly1305_state

This commit is contained in:
Karel Miko 2017-03-30 20:26:44 +02:00
parent 39028bbeed
commit 11a9dc50b3
6 changed files with 16 additions and 16 deletions

View File

@ -104,11 +104,11 @@ typedef struct {
unsigned long leftover;
unsigned char buffer[16];
int final;
} poly_state;
} poly1305_state;
int poly1305_init(poly_state *st, const unsigned char *key, unsigned long keylen);
int poly1305_process(poly_state *st, const unsigned char *in, unsigned long inlen);
int poly1305_done(poly_state *st, unsigned char *mac, unsigned long *maclen);
int poly1305_init(poly1305_state *st, const unsigned char *key, unsigned long keylen);
int poly1305_process(poly1305_state *st, const unsigned char *in, unsigned long inlen);
int poly1305_done(poly1305_state *st, unsigned char *mac, unsigned long *maclen);
int poly1305_test(void);
int poly1305_memory(const unsigned char *key, unsigned long keylen, const unsigned char *in, unsigned long inlen, unsigned char *mac, unsigned long *maclen);
int poly1305_memory_multi(const unsigned char *key, unsigned long keylen, unsigned char *mac, unsigned long *maclen, const unsigned char *in, unsigned long inlen, ...);
@ -500,7 +500,7 @@ int f9_test(void);
#ifdef LTC_CHACHA20POLY1305_MODE
typedef struct {
poly_state poly;
poly1305_state poly;
chacha_state chacha;
ulong64 aadlen;
ulong64 ctlen;

View File

@ -17,7 +17,7 @@
#ifdef LTC_POLY1305
/* internal only */
static void _poly1305_block(poly_state *st, const unsigned char *in, unsigned long inlen)
static void _poly1305_block(poly1305_state *st, const unsigned char *in, unsigned long inlen)
{
const unsigned long hibit = (st->final) ? 0 : (1UL << 24); /* 1 << 128 */
ulong32 r0,r1,r2,r3,r4;
@ -86,7 +86,7 @@ static void _poly1305_block(poly_state *st, const unsigned char *in, unsigned lo
@param keylen The length of the secret key (octets)
@return CRYPT_OK if successful
*/
int poly1305_init(poly_state *st, const unsigned char *key, unsigned long keylen)
int poly1305_init(poly1305_state *st, const unsigned char *key, unsigned long keylen)
{
LTC_ARGCHK(st != NULL);
LTC_ARGCHK(key != NULL);
@ -124,7 +124,7 @@ int poly1305_init(poly_state *st, const unsigned char *key, unsigned long keylen
@param inlen The length of the data to HMAC (octets)
@return CRYPT_OK if successful
*/
int poly1305_process(poly_state *st, const unsigned char *in, unsigned long inlen)
int poly1305_process(poly1305_state *st, const unsigned char *in, unsigned long inlen)
{
unsigned long i;
@ -168,7 +168,7 @@ int poly1305_process(poly_state *st, const unsigned char *in, unsigned long inle
@param outlen [in/out] The max size and resulting size of the POLY1305 authentication tag
@return CRYPT_OK if successful
*/
int poly1305_done(poly_state *st, unsigned char *mac, unsigned long *maclen)
int poly1305_done(poly1305_state *st, unsigned char *mac, unsigned long *maclen)
{
ulong32 h0,h1,h2,h3,h4,c;
ulong32 g0,g1,g2,g3,g4;

View File

@ -30,7 +30,7 @@ int poly1305_file(const char *fname, const unsigned char *key, unsigned long key
#ifdef LTC_NO_FILE
return CRYPT_NOP;
#else
poly_state st;
poly1305_state st;
FILE *in;
unsigned char *buf;
size_t x;
@ -60,7 +60,7 @@ int poly1305_file(const char *fname, const unsigned char *key, unsigned long key
LBL_ERR:
#ifdef LTC_CLEAN_STACK
zeromem(&st, sizeof(poly_state));
zeromem(&st, sizeof(poly1305_state));
#endif
XFREE(buf);
return err;

View File

@ -28,7 +28,7 @@
*/
int poly1305_memory(const unsigned char *key, unsigned long keylen, const unsigned char *in, unsigned long inlen, unsigned char *mac, unsigned long *maclen)
{
poly_state st;
poly1305_state st;
int err;
LTC_ARGCHK(key != NULL);
@ -41,7 +41,7 @@ int poly1305_memory(const unsigned char *key, unsigned long keylen, const unsign
err = poly1305_done(&st, mac, maclen);
LBL_ERR:
#ifdef LTC_CLEAN_STACK
zeromem(&st, sizeof(poly_state));
zeromem(&st, sizeof(poly1305_state));
#endif
return err;
};

View File

@ -30,7 +30,7 @@
*/
int poly1305_memory_multi(const unsigned char *key, unsigned long keylen, unsigned char *mac, unsigned long *maclen, const unsigned char *in, unsigned long inlen, ...)
{
poly_state st;
poly1305_state st;
int err;
va_list args;
const unsigned char *curptr;
@ -54,7 +54,7 @@ int poly1305_memory_multi(const unsigned char *key, unsigned long keylen, unsign
err = poly1305_done(&st, mac, maclen);
LBL_ERR:
#ifdef LTC_CLEAN_STACK
zeromem(&st, sizeof(poly_state));
zeromem(&st, sizeof(poly1305_state));
#endif
va_end(args);
return err;

View File

@ -27,7 +27,7 @@ int poly1305_test(void)
char m[] = "Cryptographic Forum Research Group";
unsigned long len = 16, mlen = strlen(m);
unsigned char out[1000];
poly_state st;
poly1305_state st;
/* process piece by piece */
poly1305_init(&st, k, 32);
poly1305_process(&st, (unsigned char*)m, 5);