[PATCH] serpent-avx512-x86: fix CBC and CFB decryption with clang-18

Jussi Kivilinna <[email protected]>
Newsgroups gmane.comp.encryption.gpg.libgcrypt.devel
Message-ID <[email protected]>
* cipher/serpent-avx512-x86.c (serpent_avx512_blk32): Avoid
'_mm512_castsi128_si512' usage to prevent non-initialized
vector register parts getting XOR into calculations for
CBC and CFB decryption.
--

Signed-off-by: Jussi Kivilinna <[email protected]>
---
 cipher/serpent-avx512-x86.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/cipher/serpent-avx512-x86.c b/cipher/serpent-avx512-x86.c
index 762c09e1..5b5c2483 100644
--- a/cipher/serpent-avx512-x86.c
+++ b/cipher/serpent-avx512-x86.c
@@ -758,10 +758,10 @@ serpent_avx512_blk32(const void *c, unsigned char *output,
 
       case CFB_DEC:
       {
-	__m128i viv = _mm_loadu_si128((const void *)iv);
+	__m128i viv;
 	vin[0] = _mm512_maskz_loadu_epi32(_cvtu32_mask16(0xfff0),
 					  input - 1 * 64 + 48)
-		  ^ _mm512_castsi128_si512(viv);
+		  ^ _mm512_maskz_loadu_epi32(_cvtu32_mask16(0x000f), iv);
 	vin[1] = _mm512_loadu_epi32(input + 0 * 64 + 48);
 	vin[2] = _mm512_loadu_epi32(input + 1 * 64 + 48);
 	vin[3] = _mm512_loadu_epi32(input + 2 * 64 + 48);
@@ -852,10 +852,10 @@ serpent_avx512_blk32(const void *c, unsigned char *output,
 
       case CBC_DEC:
       {
-	__m128i viv = _mm_loadu_si128((const void *)iv);
+	__m128i viv;
 	vout[0] ^= _mm512_maskz_loadu_epi32(_cvtu32_mask16(0xfff0),
 					    input - 1 * 64 + 48)
-		    ^ _mm512_castsi128_si512(viv);
+		    ^ _mm512_maskz_loadu_epi32(_cvtu32_mask16(0x000f), iv);
 	vout[1] ^= _mm512_loadu_epi32(input + 0 * 64 + 48);
 	vout[2] ^= _mm512_loadu_epi32(input + 1 * 64 + 48);
 	vout[3] ^= _mm512_loadu_epi32(input + 2 * 64 + 48);
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.