From fbe2c92f0d61d03d8e030ca3d22e922110ef07a7 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Tue, 4 Jan 2022 16:06:44 +0100 Subject: [PATCH] AEGIS: rename constants to match the draft --- .../aegis128l/aesni/aead_aegis128l_aesni.c | 16 ++++++++-------- .../armcrypto/aead_aegis128l_armcrypto.c | 18 +++++++++--------- .../aegis256/aesni/aead_aegis256_aesni.c | 12 ++++++------ .../armcrypto/aead_aegis256_armcrypto.c | 14 +++++++------- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/libsodium/crypto_aead/aegis128l/aesni/aead_aegis128l_aesni.c b/src/libsodium/crypto_aead/aegis128l/aesni/aead_aegis128l_aesni.c index 4f95f73b..c8213949 100644 --- a/src/libsodium/crypto_aead/aegis128l/aesni/aead_aegis128l_aesni.c +++ b/src/libsodium/crypto_aead/aegis128l/aesni/aead_aegis128l_aesni.c @@ -49,9 +49,9 @@ crypto_aead_aegis128l_update(__m128i *const state, const __m128i d1, const __m12 static void crypto_aead_aegis128l_init(const unsigned char *key, const unsigned char *nonce, __m128i *const state) { - const __m128i c1 = _mm_set_epi8(0xdd, 0x28, 0xb5, 0x73, 0x42, 0x31, 0x11, 0x20, 0xf1, 0x2f, 0xc2, 0x6d, + const __m128i c0 = _mm_set_epi8(0xdd, 0x28, 0xb5, 0x73, 0x42, 0x31, 0x11, 0x20, 0xf1, 0x2f, 0xc2, 0x6d, 0x55, 0x18, 0x3d, 0xdb); - const __m128i c2 = _mm_set_epi8(0x62, 0x79, 0xe9, 0x90, 0x59, 0x37, 0x22, 0x15, 0x0d, 0x08, 0x05, 0x03, + const __m128i c1 = _mm_set_epi8(0x62, 0x79, 0xe9, 0x90, 0x59, 0x37, 0x22, 0x15, 0x0d, 0x08, 0x05, 0x03, 0x02, 0x01, 0x01, 0x00); __m128i k; __m128i n; @@ -61,13 +61,13 @@ crypto_aead_aegis128l_init(const unsigned char *key, const unsigned char *nonce, n = _mm_loadu_si128((const __m128i *) (const void *) nonce); state[0] = _mm_xor_si128(k, n); - state[1] = c1; - state[2] = c2; - state[3] = c1; + state[1] = c0; + state[2] = c1; + state[3] = c0; state[4] = _mm_xor_si128(k, n); - state[5] = _mm_xor_si128(k, c2); - state[6] = _mm_xor_si128(k, c1); - state[7] = _mm_xor_si128(k, c2); + state[5] = _mm_xor_si128(k, c1); + state[6] = _mm_xor_si128(k, c0); + state[7] = _mm_xor_si128(k, c1); for (i = 0; i < 10; i++) { crypto_aead_aegis128l_update(state, n, k); } diff --git a/src/libsodium/crypto_aead/aegis128l/armcrypto/aead_aegis128l_armcrypto.c b/src/libsodium/crypto_aead/aegis128l/armcrypto/aead_aegis128l_armcrypto.c index 76f3cee9..d823930e 100644 --- a/src/libsodium/crypto_aead/aegis128l/armcrypto/aead_aegis128l_armcrypto.c +++ b/src/libsodium/crypto_aead/aegis128l/armcrypto/aead_aegis128l_armcrypto.c @@ -41,16 +41,16 @@ static void crypto_aead_aegis128l_init(const unsigned char *key, const unsigned char *nonce, uint8x16_t *const state) { - static CRYPTO_ALIGN(16) const unsigned char c1_[] = { + static CRYPTO_ALIGN(16) const unsigned char c0_[] = { 0xdb, 0x3d, 0x18, 0x55, 0x6d, 0xc2, 0x2f, 0xf1, 0x20, 0x11, 0x31, 0x42, 0x73, 0xb5, 0x28, 0xdd }; - static CRYPTO_ALIGN(16) const unsigned char c2_[] = { + static CRYPTO_ALIGN(16) const unsigned char c1_[] = { 0x00, 0x01, 0x01, 0x02, 0x03, 0x05, 0x08, 0x0d, 0x15, 0x22, 0x37, 0x59, 0x90, 0xe9, 0x79, 0x62 }; + const uint8x16_t c0 = vld1q_u8(c0_); const uint8x16_t c1 = vld1q_u8(c1_); - const uint8x16_t c2 = vld1q_u8(c2_); uint8x16_t k; uint8x16_t n; int i; @@ -59,13 +59,13 @@ crypto_aead_aegis128l_init(const unsigned char *key, const unsigned char *nonce, n = vld1q_u8(nonce); state[0] = veorq_u8(k, n); - state[1] = c1; - state[2] = c2; - state[3] = c1; + state[1] = c0; + state[2] = c1; + state[3] = c0; state[4] = veorq_u8(k, n); - state[5] = veorq_u8(k, c2); - state[6] = veorq_u8(k, c1); - state[7] = veorq_u8(k, c2); + state[5] = veorq_u8(k, c1); + state[6] = veorq_u8(k, c0); + state[7] = veorq_u8(k, c1); for (i = 0; i < 10; i++) { crypto_aead_aegis128l_update(state, n, k); } diff --git a/src/libsodium/crypto_aead/aegis256/aesni/aead_aegis256_aesni.c b/src/libsodium/crypto_aead/aegis256/aesni/aead_aegis256_aesni.c index 528fa5fb..4569f8c6 100644 --- a/src/libsodium/crypto_aead/aegis256/aesni/aead_aegis256_aesni.c +++ b/src/libsodium/crypto_aead/aegis256/aesni/aead_aegis256_aesni.c @@ -44,9 +44,9 @@ crypto_aead_aegis256_update(__m128i *const state, const __m128i data) static void crypto_aead_aegis256_init(const unsigned char *key, const unsigned char *nonce, __m128i *const state) { - const __m128i c1 = _mm_set_epi8(0xdd, 0x28, 0xb5, 0x73, 0x42, 0x31, 0x11, 0x20, 0xf1, 0x2f, 0xc2, 0x6d, + const __m128i c0 = _mm_set_epi8(0xdd, 0x28, 0xb5, 0x73, 0x42, 0x31, 0x11, 0x20, 0xf1, 0x2f, 0xc2, 0x6d, 0x55, 0x18, 0x3d, 0xdb); - const __m128i c2 = _mm_set_epi8(0x62, 0x79, 0xe9, 0x90, 0x59, 0x37, 0x22, 0x15, 0x0d, 0x08, 0x05, 0x03, + const __m128i c1 = _mm_set_epi8(0x62, 0x79, 0xe9, 0x90, 0x59, 0x37, 0x22, 0x15, 0x0d, 0x08, 0x05, 0x03, 0x02, 0x01, 0x01, 0x00); __m128i k1, k2; __m128i kxn1, kxn2; @@ -59,10 +59,10 @@ crypto_aead_aegis256_init(const unsigned char *key, const unsigned char *nonce, state[0] = kxn1; state[1] = kxn2; - state[2] = c1; - state[3] = c2; - state[4] = _mm_xor_si128(k1, c2); - state[5] = _mm_xor_si128(k2, c1); + state[2] = c0; + state[3] = c1; + state[4] = _mm_xor_si128(k1, c1); + state[5] = _mm_xor_si128(k2, c0); for (i = 0; i < 4; i++) { crypto_aead_aegis256_update(state, k1); diff --git a/src/libsodium/crypto_aead/aegis256/armcrypto/aead_aegis256_armcrypto.c b/src/libsodium/crypto_aead/aegis256/armcrypto/aead_aegis256_armcrypto.c index 325c1e0c..e5cd054f 100644 --- a/src/libsodium/crypto_aead/aegis256/armcrypto/aead_aegis256_armcrypto.c +++ b/src/libsodium/crypto_aead/aegis256/armcrypto/aead_aegis256_armcrypto.c @@ -35,16 +35,16 @@ static void crypto_aead_aegis256_init(const unsigned char *key, const unsigned char *nonce, uint8x16_t *const state) { - static CRYPTO_ALIGN(16) const unsigned char c1_[] = { + static CRYPTO_ALIGN(16) const unsigned char c0_[] = { 0xdb, 0x3d, 0x18, 0x55, 0x6d, 0xc2, 0x2f, 0xf1, 0x20, 0x11, 0x31, 0x42, 0x73, 0xb5, 0x28, 0xdd }; - static CRYPTO_ALIGN(16) const unsigned char c2_[] = { + static CRYPTO_ALIGN(16) const unsigned char c1_[] = { 0x00, 0x01, 0x01, 0x02, 0x03, 0x05, 0x08, 0x0d, 0x15, 0x22, 0x37, 0x59, 0x90, 0xe9, 0x79, 0x62 }; + const uint8x16_t c0 = vld1q_u8(c0_); const uint8x16_t c1 = vld1q_u8(c1_); - const uint8x16_t c2 = vld1q_u8(c2_); uint8x16_t k1, k2; uint8x16_t kxn1, kxn2; int i; @@ -56,10 +56,10 @@ crypto_aead_aegis256_init(const unsigned char *key, const unsigned char *nonce, state[0] = kxn1; state[1] = kxn2; - state[2] = c1; - state[3] = c2; - state[4] = veorq_u8(k1, c2); - state[5] = veorq_u8(k2, c1); + state[2] = c0; + state[3] = c1; + state[4] = veorq_u8(k1, c1); + state[5] = veorq_u8(k2, c0); for (i = 0; i < 4; i++) { crypto_aead_aegis256_update(state, k1);