Skip to content

Commit af2c6cc

Browse files
committed
AES-GCM ARM32/Thumb2 ASM: don't change aes->reg in decrypt
OpenSSL compatability layer expects aes->reg to be unmodified by AES-GCM decrypt call. ARM32/Thumb2 assembly implementation modifies buffer. Keep a copy and restore aes->reg after call.
1 parent b42e9a9 commit af2c6cc

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

wolfcrypt/src/aes.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10561,9 +10561,18 @@ int wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz,
1056110561
#if defined(WOLFSSL_ARMASM)
1056210562
#ifndef WOLFSSL_ARMASM_NO_HW_CRYPTO
1056310563
#ifndef __aarch64__
10564-
ret = AES_GCM_decrypt_AARCH32(in, out, sz, iv, ivSz, authTag, authTagSz,
10565-
authIn, authInSz, (byte*)aes->key, aes->gcm.H, (byte*)aes->tmp,
10566-
(byte*)aes->reg, aes->rounds);
10564+
{
10565+
#ifdef OPENSSL_EXTRA
10566+
word32 reg[WC_AES_BLOCK_SIZE / sizeof(word32)];
10567+
XMEMCPY(reg, aes->reg, sizeof(reg));
10568+
#endif
10569+
ret = AES_GCM_decrypt_AARCH32(in, out, sz, iv, ivSz, authTag, authTagSz,
10570+
authIn, authInSz, (byte*)aes->key, aes->gcm.H, (byte*)aes->tmp,
10571+
(byte*)aes->reg, aes->rounds);
10572+
#ifdef OPENSSL_EXTRA
10573+
XMEMCPY(aes->reg, reg, sizeof(reg));
10574+
#endif
10575+
}
1056710576
#else
1056810577
if (aes->use_aes_hw_crypto && aes->use_pmull_hw_crypto) {
1056910578
#ifdef WOLFSSL_ARMASM_CRYPTO_SHA3

0 commit comments

Comments
 (0)