From 3a05f0331d86b60e27e8600e6a1673f7ce38215f Mon Sep 17 00:00:00 2001 From: Karel Miko Date: Thu, 30 Mar 2017 20:29:41 +0200 Subject: [PATCH] chachapoly_state > chacha20poly1305_state --- .../chachapoly/chacha20poly1305_add_aad.c | 2 +- .../chachapoly/chacha20poly1305_decrypt.c | 2 +- src/encauth/chachapoly/chacha20poly1305_done.c | 2 +- .../chachapoly/chacha20poly1305_encrypt.c | 2 +- src/encauth/chachapoly/chacha20poly1305_init.c | 2 +- src/encauth/chachapoly/chacha20poly1305_memory.c | 4 ++-- src/encauth/chachapoly/chacha20poly1305_setiv.c | 2 +- .../chachapoly/chacha20poly1305_setiv_rfc7905.c | 2 +- src/encauth/chachapoly/chacha20poly1305_test.c | 2 +- src/headers/tomcrypt_mac.h | 16 ++++++++-------- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/encauth/chachapoly/chacha20poly1305_add_aad.c b/src/encauth/chachapoly/chacha20poly1305_add_aad.c index f840d28..8d530a1 100644 --- a/src/encauth/chachapoly/chacha20poly1305_add_aad.c +++ b/src/encauth/chachapoly/chacha20poly1305_add_aad.c @@ -18,7 +18,7 @@ @param inlen The length of the ChaCha20Poly1305 data. @return CRYPT_OK on success */ -int chacha20poly1305_add_aad(chachapoly_state *st, const unsigned char *in, unsigned long inlen) +int chacha20poly1305_add_aad(chacha20poly1305_state *st, const unsigned char *in, unsigned long inlen) { int err; diff --git a/src/encauth/chachapoly/chacha20poly1305_decrypt.c b/src/encauth/chachapoly/chacha20poly1305_decrypt.c index bc8b6c1..2677aff 100644 --- a/src/encauth/chachapoly/chacha20poly1305_decrypt.c +++ b/src/encauth/chachapoly/chacha20poly1305_decrypt.c @@ -19,7 +19,7 @@ @param out [out] The plaintext (length inlen) @return CRYPT_OK if successful */ -int chacha20poly1305_decrypt(chachapoly_state *st, const unsigned char *in, unsigned long inlen, unsigned char *out) +int chacha20poly1305_decrypt(chacha20poly1305_state *st, const unsigned char *in, unsigned long inlen, unsigned char *out) { unsigned char padzero[16] = { 0 }; unsigned long padlen; diff --git a/src/encauth/chachapoly/chacha20poly1305_done.c b/src/encauth/chachapoly/chacha20poly1305_done.c index efe98b9..1b41589 100644 --- a/src/encauth/chachapoly/chacha20poly1305_done.c +++ b/src/encauth/chachapoly/chacha20poly1305_done.c @@ -18,7 +18,7 @@ @param taglen [in/out] The length of the MAC tag @return CRYPT_OK on success */ -int chacha20poly1305_done(chachapoly_state *st, unsigned char *tag, unsigned long *taglen) +int chacha20poly1305_done(chacha20poly1305_state *st, unsigned char *tag, unsigned long *taglen) { unsigned char padzero[16] = { 0 }; unsigned long padlen; diff --git a/src/encauth/chachapoly/chacha20poly1305_encrypt.c b/src/encauth/chachapoly/chacha20poly1305_encrypt.c index b1c1adc..511f24b 100644 --- a/src/encauth/chachapoly/chacha20poly1305_encrypt.c +++ b/src/encauth/chachapoly/chacha20poly1305_encrypt.c @@ -19,7 +19,7 @@ @param out [out] The ciphertext (length inlen) @return CRYPT_OK if successful */ -int chacha20poly1305_encrypt(chachapoly_state *st, const unsigned char *in, unsigned long inlen, unsigned char *out) +int chacha20poly1305_encrypt(chacha20poly1305_state *st, const unsigned char *in, unsigned long inlen, unsigned char *out) { unsigned char padzero[16] = { 0 }; unsigned long padlen; diff --git a/src/encauth/chachapoly/chacha20poly1305_init.c b/src/encauth/chachapoly/chacha20poly1305_init.c index 7cea6aa..5195d12 100644 --- a/src/encauth/chachapoly/chacha20poly1305_init.c +++ b/src/encauth/chachapoly/chacha20poly1305_init.c @@ -18,7 +18,7 @@ @param keylen The length of the secret key (octets) @return CRYPT_OK if successful */ -int chacha20poly1305_init(chachapoly_state *st, const unsigned char *key, unsigned long keylen) +int chacha20poly1305_init(chacha20poly1305_state *st, const unsigned char *key, unsigned long keylen) { return chacha_setup(&st->chacha, key, keylen, 20); } diff --git a/src/encauth/chachapoly/chacha20poly1305_memory.c b/src/encauth/chachapoly/chacha20poly1305_memory.c index 09ee01f..759e704 100644 --- a/src/encauth/chachapoly/chacha20poly1305_memory.c +++ b/src/encauth/chachapoly/chacha20poly1305_memory.c @@ -35,7 +35,7 @@ int chacha20poly1305_memory(const unsigned char *key, unsigned long keylen, unsigned char *tag, unsigned long *taglen, int direction) { - chachapoly_state st; + chacha20poly1305_state st; int err; LTC_ARGCHK(key != NULL); @@ -62,7 +62,7 @@ int chacha20poly1305_memory(const unsigned char *key, unsigned long keylen, err = chacha20poly1305_done(&st, tag, taglen); LBL_ERR: #ifdef LTC_CLEAN_STACK - zeromem(&st, sizeof(chachapoly_state)); + zeromem(&st, sizeof(chacha20poly1305_state)); #endif return err; } diff --git a/src/encauth/chachapoly/chacha20poly1305_setiv.c b/src/encauth/chachapoly/chacha20poly1305_setiv.c index 43c116b..e5d41c9 100644 --- a/src/encauth/chachapoly/chacha20poly1305_setiv.c +++ b/src/encauth/chachapoly/chacha20poly1305_setiv.c @@ -18,7 +18,7 @@ @param inlen The length of the IV (must be 12 or 8) @return CRYPT_OK on success */ -int chacha20poly1305_setiv(chachapoly_state *st, const unsigned char *iv, unsigned long ivlen) +int chacha20poly1305_setiv(chacha20poly1305_state *st, const unsigned char *iv, unsigned long ivlen) { chacha_state tmp_st; int i, err; diff --git a/src/encauth/chachapoly/chacha20poly1305_setiv_rfc7905.c b/src/encauth/chachapoly/chacha20poly1305_setiv_rfc7905.c index 5bb2156..6bb4e58 100644 --- a/src/encauth/chachapoly/chacha20poly1305_setiv_rfc7905.c +++ b/src/encauth/chachapoly/chacha20poly1305_setiv_rfc7905.c @@ -19,7 +19,7 @@ @param sequence_number 64bit sequence number which is incorporated into IV as described in RFC7905 @return CRYPT_OK on success */ -int chacha20poly1305_setiv_rfc7905(chachapoly_state *st, const unsigned char *iv, unsigned long ivlen, ulong64 sequence_number) +int chacha20poly1305_setiv_rfc7905(chacha20poly1305_state *st, const unsigned char *iv, unsigned long ivlen, ulong64 sequence_number) { int i; unsigned char combined_iv[12] = { 0 }; diff --git a/src/encauth/chachapoly/chacha20poly1305_test.c b/src/encauth/chachapoly/chacha20poly1305_test.c index 006c096..4d53d26 100644 --- a/src/encauth/chachapoly/chacha20poly1305_test.c +++ b/src/encauth/chachapoly/chacha20poly1305_test.c @@ -16,7 +16,7 @@ int chacha20poly1305_test(void) #ifndef LTC_TEST return CRYPT_NOP; #else - chachapoly_state st1, st2; + chacha20poly1305_state st1, st2; unsigned char k[] = { 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f }; unsigned char iv[] = { 0x07, 0x00, 0x00, 0x00, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47 }; unsigned char aad[] = { 0x50, 0x51, 0x52, 0x53, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7 }; diff --git a/src/headers/tomcrypt_mac.h b/src/headers/tomcrypt_mac.h index 4adc7c0..2feefba 100644 --- a/src/headers/tomcrypt_mac.h +++ b/src/headers/tomcrypt_mac.h @@ -505,18 +505,18 @@ typedef struct { ulong64 aadlen; ulong64 ctlen; int aadflg; -} chachapoly_state; +} chacha20poly1305_state; #define CHCHA20POLY1305_ENCRYPT 0 #define CHCHA20POLY1305_DECRYPT 1 -int chacha20poly1305_init(chachapoly_state *st, const unsigned char *key, unsigned long keylen); -int chacha20poly1305_setiv(chachapoly_state *st, const unsigned char *iv, unsigned long ivlen); -int chacha20poly1305_setiv_rfc7905(chachapoly_state *st, const unsigned char *iv, unsigned long ivlen, ulong64 sequence_number); -int chacha20poly1305_add_aad(chachapoly_state *st, const unsigned char *in, unsigned long inlen); -int chacha20poly1305_encrypt(chachapoly_state *st, const unsigned char *in, unsigned long inlen, unsigned char *out); -int chacha20poly1305_decrypt(chachapoly_state *st, const unsigned char *in, unsigned long inlen, unsigned char *out); -int chacha20poly1305_done(chachapoly_state *st, unsigned char *tag, unsigned long *taglen); +int chacha20poly1305_init(chacha20poly1305_state *st, const unsigned char *key, unsigned long keylen); +int chacha20poly1305_setiv(chacha20poly1305_state *st, const unsigned char *iv, unsigned long ivlen); +int chacha20poly1305_setiv_rfc7905(chacha20poly1305_state *st, const unsigned char *iv, unsigned long ivlen, ulong64 sequence_number); +int chacha20poly1305_add_aad(chacha20poly1305_state *st, const unsigned char *in, unsigned long inlen); +int chacha20poly1305_encrypt(chacha20poly1305_state *st, const unsigned char *in, unsigned long inlen, unsigned char *out); +int chacha20poly1305_decrypt(chacha20poly1305_state *st, const unsigned char *in, unsigned long inlen, unsigned char *out); +int chacha20poly1305_done(chacha20poly1305_state *st, unsigned char *tag, unsigned long *taglen); int chacha20poly1305_memory(const unsigned char *key, unsigned long keylen, const unsigned char *iv, unsigned long ivlen, const unsigned char *aad, unsigned long aadlen,