Skip to content

Commit 2950334

Browse files
author
Lealem Amedie
committed
Fix for AES-CFB1 encrypt/decrypt on size (8*x-1) bits
1 parent d1efccd commit 2950334

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

wolfcrypt/src/aes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11863,7 +11863,7 @@ static WARN_UNUSED_RESULT int wc_AesFeedbackCFB1(
1186311863
}
1186411864

1186511865
if (ret == 0) {
11866-
if (bit > 0 && bit < 7) {
11866+
if (bit >= 0 && bit < 7) {
1186711867
out[0] = cur;
1186811868
}
1186911869
}

wolfcrypt/test/test.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9152,6 +9152,11 @@ static wc_test_ret_t EVP_test(const WOLFSSL_EVP_CIPHER* type, const byte* key,
91529152
{
91539153
0xC0
91549154
};
9155+
9156+
WOLFSSL_SMALL_STACK_STATIC const byte cipher1_7bit[] =
9157+
{
9158+
0x1C
9159+
};
91559160
#endif /* WOLFSSL_AES_128 */
91569161
#ifdef WOLFSSL_AES_192
91579162
WOLFSSL_SMALL_STACK_STATIC const byte iv2[] = {
@@ -9252,6 +9257,15 @@ static wc_test_ret_t EVP_test(const WOLFSSL_EVP_CIPHER* type, const byte* key,
92529257
ERROR_OUT(WC_TEST_RET_ENC_NC, out);
92539258
#endif /* HAVE_AES_DECRYPT */
92549259

9260+
XMEMSET(cipher, 0, sizeof(cipher));
9261+
ret = wc_AesCfb1Encrypt(enc, cipher, msg1, 7);
9262+
9263+
if (ret != 0)
9264+
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
9265+
9266+
if (cipher[0] != cipher1_7bit[0])
9267+
ERROR_OUT(WC_TEST_RET_ENC_NC, out);
9268+
92559269
#ifdef OPENSSL_EXTRA
92569270
ret = wc_AesSetKey(enc, key1, AES_BLOCK_SIZE, iv, AES_ENCRYPTION);
92579271
if (ret != 0)

0 commit comments

Comments
 (0)