[PATCH 04/10] Clear xmm5 after use in AES-NI CTR mode
Jussi Kivilinna
jussi.kivilinna at mbnet.fi
Fri Nov 23 18:22:09 CET 2012
* cipher/rijndael.c [USE_AESNI]: Rename aesni_cleanup_2_4 to
aesni_cleanup_2_5.
[USE_AESNI] (aesni_cleanup_2_5): Clear xmm5 register.
(_gcry_aes_ctr_enc, _gcry_aes_cbc_dec) [USE_AESNI]: Use
aesni_cleanup_2_5 instead of aesni_cleanup_2_4.
--
xmm5 register is used by parallelized AES-NI CTR mode, so it should be cleaned
up after use too.
Signed-off-by: Jussi Kivilinna <jussi.kivilinna at mbnet.fi>
---
cipher/rijndael.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/cipher/rijndael.c b/cipher/rijndael.c
index 982c54e..69e1df1 100644
--- a/cipher/rijndael.c
+++ b/cipher/rijndael.c
@@ -144,10 +144,11 @@ typedef struct
do { asm volatile ("pxor %%xmm0, %%xmm0\n\t" \
"pxor %%xmm1, %%xmm1\n" :: ); \
} while (0)
-# define aesni_cleanup_2_4() \
+# define aesni_cleanup_2_5() \
do { asm volatile ("pxor %%xmm2, %%xmm2\n\t" \
"pxor %%xmm3, %%xmm3\n" \
- "pxor %%xmm4, %%xmm4\n":: ); \
+ "pxor %%xmm4, %%xmm4\n" \
+ "pxor %%xmm5, %%xmm5\n":: ); \
} while (0)
#else
# define aesni_prepare() do { } while (0)
@@ -1338,7 +1339,7 @@ _gcry_aes_ctr_enc (void *context, unsigned char *ctr,
inbuf += BLOCKSIZE;
}
aesni_cleanup ();
- aesni_cleanup_2_4 ();
+ aesni_cleanup_2_5 ();
}
#endif /*USE_AESNI*/
else
@@ -1664,7 +1665,7 @@ _gcry_aes_cbc_dec (void *context, unsigned char *iv,
: "memory");
aesni_cleanup ();
- aesni_cleanup_2_4 ();
+ aesni_cleanup_2_5 ();
}
#endif /*USE_AESNI*/
else
More information about the Gcrypt-devel
mailing list