Skip to content

Commit 43fe46c

Browse files
Merge pull request #8099 from dgarske/armasm_aes
Fix issue with ARM ASM with AES CFB/OFB not initializing the "left" member
2 parents 846ef15 + 5a0bb3a commit 43fe46c

File tree

7 files changed

+33
-26
lines changed

7 files changed

+33
-26
lines changed

wolfcrypt/src/aes.c

+14-13
Original file line numberDiff line numberDiff line change
@@ -3726,8 +3726,8 @@ static WARN_UNUSED_RESULT int wc_AesDecrypt(
37263726
#if !defined(WOLFSSL_STM32_CUBEMX) || defined(STM32_HAL_V2)
37273727
ByteReverseWords(rk, rk, keylen);
37283728
#endif
3729-
#if defined(WOLFSSL_AES_CFB) || defined(WOLFSSL_AES_COUNTER) || \
3730-
defined(WOLFSSL_AES_OFB)
3729+
#if defined(WOLFSSL_AES_COUNTER) || defined(WOLFSSL_AES_CFB) || \
3730+
defined(WOLFSSL_AES_OFB) || defined(WOLFSSL_AES_XTS)
37313731
aes->left = 0;
37323732
#endif
37333733
return wc_AesSetIV(aes, iv);
@@ -3807,8 +3807,8 @@ static WARN_UNUSED_RESULT int wc_AesDecrypt(
38073807
if (iv)
38083808
XMEMCPY(aes->reg, iv, AES_BLOCK_SIZE);
38093809

3810-
#if defined(WOLFSSL_AES_CFB) || defined(WOLFSSL_AES_COUNTER) || \
3811-
defined(WOLFSSL_AES_OFB)
3810+
#if defined(WOLFSSL_AES_COUNTER) || defined(WOLFSSL_AES_CFB) || \
3811+
defined(WOLFSSL_AES_OFB) || defined(WOLFSSL_AES_XTS)
38123812
aes->left = 0;
38133813
#endif
38143814

@@ -3838,8 +3838,8 @@ static WARN_UNUSED_RESULT int wc_AesDecrypt(
38383838
aes->rounds = keylen/4 + 6;
38393839
XMEMCPY(aes->key, userKey, keylen);
38403840

3841-
#if defined(WOLFSSL_AES_CFB) || defined(WOLFSSL_AES_COUNTER) || \
3842-
defined(WOLFSSL_AES_OFB)
3841+
#if defined(WOLFSSL_AES_COUNTER) || defined(WOLFSSL_AES_CFB) || \
3842+
defined(WOLFSSL_AES_OFB) || defined(WOLFSSL_AES_XTS)
38433843
aes->left = 0;
38443844
#endif
38453845

@@ -3890,8 +3890,8 @@ static WARN_UNUSED_RESULT int wc_AesDecrypt(
38903890
if (rk == NULL)
38913891
return BAD_FUNC_ARG;
38923892

3893-
#if defined(WOLFSSL_AES_CFB) || defined(WOLFSSL_AES_COUNTER) || \
3894-
defined(WOLFSSL_AES_OFB)
3893+
#if defined(WOLFSSL_AES_COUNTER) || defined(WOLFSSL_AES_CFB) || \
3894+
defined(WOLFSSL_AES_OFB) || defined(WOLFSSL_AES_XTS)
38953895
aes->left = 0;
38963896
#endif
38973897

@@ -3971,8 +3971,8 @@ static WARN_UNUSED_RESULT int wc_AesDecrypt(
39713971
XMEMCPY(aes->key, userKey, keylen);
39723972
ret = nrf51_aes_set_key(userKey);
39733973

3974-
#if defined(WOLFSSL_AES_CFB) || defined(WOLFSSL_AES_COUNTER) || \
3975-
defined(WOLFSSL_AES_OFB)
3974+
#if defined(WOLFSSL_AES_COUNTER) || defined(WOLFSSL_AES_CFB) || \
3975+
defined(WOLFSSL_AES_OFB) || defined(WOLFSSL_AES_XTS)
39763976
aes->left = 0;
39773977
#endif
39783978

@@ -4028,7 +4028,8 @@ static WARN_UNUSED_RESULT int wc_AesDecrypt(
40284028
aes->rounds = keylen/4 + 6;
40294029

40304030
XMEMCPY(aes->key, userKey, keylen);
4031-
#if defined(WOLFSSL_AES_COUNTER)
4031+
#if defined(WOLFSSL_AES_COUNTER) || defined(WOLFSSL_AES_CFB) || \
4032+
defined(WOLFSSL_AES_OFB) || defined(WOLFSSL_AES_XTS)
40324033
aes->left = 0;
40334034
#endif
40344035
return wc_AesSetIV(aes, iv);
@@ -4520,8 +4521,8 @@ static void AesSetKey_C(Aes* aes, const byte* key, word32 keySz, int dir)
45204521
#endif
45214522
}
45224523

4523-
#if defined(WOLFSSL_AES_CFB) || defined(WOLFSSL_AES_COUNTER) || \
4524-
defined(WOLFSSL_AES_OFB)
4524+
#if defined(WOLFSSL_AES_COUNTER) || defined(WOLFSSL_AES_CFB) || \
4525+
defined(WOLFSSL_AES_OFB) || defined(WOLFSSL_AES_XTS)
45254526
aes->left = 0;
45264527
#endif
45274528

wolfcrypt/src/port/Renesas/renesas_fspsm_aes.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,8 @@ int wc_AesSetKey(Aes* aes, const byte* userKey, word32 keylen,
795795
return BAD_FUNC_ARG;
796796
}
797797

798-
#ifdef WOLFSSL_AES_COUNTER
798+
#if defined(WOLFSSL_AES_COUNTER) || defined(WOLFSSL_AES_CFB) || \
799+
defined(WOLFSSL_AES_OFB) || defined(WOLFSSL_AES_XTS)
799800
aes->left = 0;
800801
#endif
801802

wolfcrypt/src/port/arm/armv8-aes.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ int wc_AesSetKey(Aes* aes, const byte* userKey, word32 keylen,
201201
}
202202
#endif
203203

204-
#ifdef WOLFSSL_AES_COUNTER
204+
#if defined(WOLFSSL_AES_COUNTER) || defined(WOLFSSL_AES_CFB) || \
205+
defined(WOLFSSL_AES_OFB) || defined(WOLFSSL_AES_XTS)
205206
aes->left = 0;
206207
#endif /* WOLFSSL_AES_COUNTER */
207208

@@ -16581,9 +16582,10 @@ int wc_AesSetKey(Aes* aes, const byte* userKey, word32 keylen,
1658116582
XMEMCPY(aes->devKey, userKey, keylen);
1658216583
}
1658316584
#endif
16584-
#ifdef WOLFSSL_AES_COUNTER
16585+
#if defined(WOLFSSL_AES_COUNTER) || defined(WOLFSSL_AES_CFB) || \
16586+
defined(WOLFSSL_AES_OFB) || defined(WOLFSSL_AES_XTS)
1658516587
aes->left = 0;
16586-
#endif /* WOLFSSL_AES_COUNTER */
16588+
#endif
1658716589

1658816590
aes->keylen = keylen;
1658916591
aes->rounds = keylen/4 + 6;

wolfcrypt/src/port/caam/caam_aes.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ int wc_AesSetKey(Aes* aes, const byte* key, word32 len,
9393
return ret;
9494
}
9595

96-
#ifdef WOLFSSL_AES_COUNTER
96+
#if defined(WOLFSSL_AES_COUNTER) || defined(WOLFSSL_AES_CFB) || \
97+
defined(WOLFSSL_AES_OFB) || defined(WOLFSSL_AES_XTS)
9798
aes->left = 0;
9899
#endif
99100

wolfcrypt/src/port/devcrypto/devcrypto_aes.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ int wc_AesSetKey(Aes* aes, const byte* userKey, word32 keylen,
125125
aes->keylen = keylen;
126126
aes->rounds = keylen/4 + 6;
127127

128-
#ifdef WOLFSSL_AES_COUNTER
128+
#if defined(WOLFSSL_AES_COUNTER) || defined(WOLFSSL_AES_CFB) || \
129+
defined(WOLFSSL_AES_OFB) || defined(WOLFSSL_AES_XTS)
129130
aes->left = 0;
130131
#endif
131132
aes->ctx.cfd = -1;

wolfcrypt/src/port/riscv/riscv-64-aes.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,8 @@ int wc_AesSetKey(Aes* aes, const byte* key, word32 keyLen, const byte* iv,
498498
if (ret == 0) {
499499
/* Finish setting the AES object. */
500500
aes->keylen = keyLen;
501-
#if defined(WOLFSSL_AES_CFB) || defined(WOLFSSL_AES_COUNTER) || \
502-
defined(WOLFSSL_AES_OFB)
501+
#if defined(WOLFSSL_AES_COUNTER) || defined(WOLFSSL_AES_CFB) || \
502+
defined(WOLFSSL_AES_OFB) || defined(WOLFSSL_AES_XTS)
503503
aes->left = 0;
504504
#endif
505505
}
@@ -1770,8 +1770,8 @@ int wc_AesSetKey(Aes* aes, const byte* key, word32 keyLen, const byte* iv,
17701770
if (ret == 0) {
17711771
/* Finish setting the AES object. */
17721772
aes->keylen = keyLen;
1773-
#if defined(WOLFSSL_AES_CFB) || defined(WOLFSSL_AES_COUNTER) || \
1774-
defined(WOLFSSL_AES_OFB)
1773+
#if defined(WOLFSSL_AES_COUNTER) || defined(WOLFSSL_AES_CFB) || \
1774+
defined(WOLFSSL_AES_OFB) || defined(WOLFSSL_AES_XTS)
17751775
aes->left = 0;
17761776
#endif
17771777
}
@@ -2978,8 +2978,8 @@ int wc_AesSetKey(Aes* aes, const byte* key, word32 keyLen, const byte* iv,
29782978

29792979
if (ret == 0) {
29802980
/* Initialize fields. */
2981-
#if defined(WOLFSSL_AES_CFB) || defined(WOLFSSL_AES_COUNTER) || \
2982-
defined(WOLFSSL_AES_OFB)
2981+
#if defined(WOLFSSL_AES_COUNTER) || defined(WOLFSSL_AES_CFB) || \
2982+
defined(WOLFSSL_AES_OFB) || defined(WOLFSSL_AES_XTS)
29832983
aes->left = 0;
29842984
#endif
29852985
aes->keylen = (int)keyLen;

wolfcrypt/src/port/ti/ti-aes.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ int wc_AesSetKey(Aes* aes, const byte* key, word32 len, const byte* iv, int dir)
9999
aes->rounds = len / 4 + 6;
100100

101101
XMEMCPY(aes->key, key, len);
102-
#ifdef WOLFSSL_AES_COUNTER
102+
#if defined(WOLFSSL_AES_COUNTER) || defined(WOLFSSL_AES_CFB) || \
103+
defined(WOLFSSL_AES_OFB) || defined(WOLFSSL_AES_XTS)
103104
aes->left = 0;
104105
#endif
105106
return AesSetIV(aes, iv);

0 commit comments

Comments
 (0)