From 104de0dcd15740f04f6d8725455d294ea79c09a3 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Wed, 16 Nov 2022 22:51:44 +0100 Subject: [PATCH] clsq128(): simplify squaring --- .../crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c | 5 +---- .../aes256gcm/armcrypto/aead_aes256gcm_armcrypto.c | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c b/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c index e1f3a894..5525fb59 100644 --- a/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c +++ b/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c @@ -191,16 +191,13 @@ static inline void __vectorcall encrypt_xor_wide(const State *st, static inline I256 __vectorcall clsq128(const BlockVec x) { - const BlockVec x_hi = BYTESHR128(x, 8); - const BlockVec mid = XOR128(x, x_hi); const BlockVec r_lo = CLMULLO128(x, x); const BlockVec r_hi = CLMULHI128(x, x); - const BlockVec r_mid = XOR128(CLMULLO128(mid, mid), XOR128(r_lo, r_hi)); return (I256) { SODIUM_C99(.hi =) r_hi, SODIUM_C99(.lo =) r_lo, - SODIUM_C99(.mid =) r_mid, + SODIUM_C99(.mid =) ZERO128, }; } diff --git a/src/libsodium/crypto_aead/aes256gcm/armcrypto/aead_aes256gcm_armcrypto.c b/src/libsodium/crypto_aead/aes256gcm/armcrypto/aead_aes256gcm_armcrypto.c index dd65b599..e345a198 100644 --- a/src/libsodium/crypto_aead/aes256gcm/armcrypto/aead_aes256gcm_armcrypto.c +++ b/src/libsodium/crypto_aead/aes256gcm/armcrypto/aead_aes256gcm_armcrypto.c @@ -205,16 +205,13 @@ static inline void __vectorcall encrypt_xor_wide(const State *st, static inline I256 __vectorcall clsq128(const BlockVec x) { - const BlockVec x_hi = BYTESHR128(x, 8); - const BlockVec mid = XOR128(x, x_hi); const BlockVec r_lo = CLMULLO128(x, x); const BlockVec r_hi = CLMULHI128(x, x); - const BlockVec r_mid = XOR128(CLMULLO128(mid, mid), XOR128(r_lo, r_hi)); return (I256) { SODIUM_C99(.hi =) r_hi, SODIUM_C99(.lo =) r_lo, - SODIUM_C99(.mid =) r_mid, + SODIUM_C99(.mid =) ZERO128, }; }