Skip to content

Commit 8719df2

Browse files
committed
wolfcrypt/src/aes.c: in wc_AesGcmSetKey(), don't VECTOR_REGISTERS_POP() until after GCM_generate_m0_*().
1 parent e486632 commit 8719df2

1 file changed

Lines changed: 27 additions & 24 deletions

File tree

wolfcrypt/src/aes.c

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7460,37 +7460,40 @@ int wc_AesGcmSetKey(Aes* aes, const byte* key, word32 len)
74607460
* assure pure-C fallback is always usable.
74617461
*/
74627462
ret = wc_AesEncrypt(aes, iv, aes->gcm.H);
7463-
VECTOR_REGISTERS_POP;
7464-
}
7465-
if (ret == 0) {
7466-
#if defined(GCM_TABLE) || defined(GCM_TABLE_4BIT)
7467-
#if defined(WOLFSSL_AESNI) && defined(GCM_TABLE_4BIT)
7468-
if (aes->use_aesni) {
7469-
#if defined(WC_C_DYNAMIC_FALLBACK)
7470-
#ifdef HAVE_INTEL_AVX2
7471-
if (IS_INTEL_AVX2(intel_flags)) {
7472-
GCM_generate_m0_avx2(aes->gcm.H, (byte*)aes->gcm.M0);
7473-
}
7474-
else
7463+
7464+
if (ret == 0) {
7465+
#if defined(GCM_TABLE) || defined(GCM_TABLE_4BIT)
7466+
#if defined(WOLFSSL_AESNI) && defined(GCM_TABLE_4BIT)
7467+
if (aes->use_aesni) {
7468+
#if defined(WC_C_DYNAMIC_FALLBACK)
7469+
#ifdef HAVE_INTEL_AVX2
7470+
if (IS_INTEL_AVX2(intel_flags)) {
7471+
GCM_generate_m0_avx2(aes->gcm.H, (byte*)aes->gcm.M0);
7472+
}
7473+
else
7474+
#endif
7475+
#if defined(HAVE_INTEL_AVX1)
7476+
if (IS_INTEL_AVX1(intel_flags)) {
7477+
GCM_generate_m0_avx1(aes->gcm.H, (byte*)aes->gcm.M0);
7478+
}
7479+
else
7480+
#endif
7481+
{
7482+
GCM_generate_m0_aesni(aes->gcm.H, (byte*)aes->gcm.M0);
7483+
}
74757484
#endif
7476-
#if defined(HAVE_INTEL_AVX1)
7477-
if (IS_INTEL_AVX1(intel_flags)) {
7478-
GCM_generate_m0_avx1(aes->gcm.H, (byte*)aes->gcm.M0);
74797485
}
74807486
else
7481-
#endif
7487+
#endif
74827488
{
7483-
GCM_generate_m0_aesni(aes->gcm.H, (byte*)aes->gcm.M0);
7489+
GenerateM0(&aes->gcm);
74847490
}
7485-
#endif
7491+
#endif /* GCM_TABLE || GCM_TABLE_4BIT */
74867492
}
7487-
else
7488-
#endif
7489-
{
7490-
GenerateM0(&aes->gcm);
7491-
}
7492-
#endif /* GCM_TABLE || GCM_TABLE_4BIT */
7493+
7494+
VECTOR_REGISTERS_POP;
74937495
}
7496+
74947497
#endif /* !FREESCALE_LTC_AES_GCM && !WOLFSSL_PSOC6_CRYPTO */
74957498
#endif
74967499

0 commit comments

Comments
 (0)