Skip to content

Commit 69be7a7

Browse files
Merge pull request #7431 from lealem47/aes_cfb
Fix for AES-CFB1 encrypt/decrypt on size (8*x-1) bits
2 parents a63ff27 + 2950334 commit 69be7a7

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
@@ -11870,7 +11870,7 @@ static WARN_UNUSED_RESULT int wc_AesFeedbackCFB1(
1187011870
}
1187111871

1187211872
if (ret == 0) {
11873-
if (bit > 0 && bit < 7) {
11873+
if (bit >= 0 && bit < 7) {
1187411874
out[0] = cur;
1187511875
}
1187611876
}

wolfcrypt/test/test.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9209,6 +9209,11 @@ static wc_test_ret_t EVP_test(const WOLFSSL_EVP_CIPHER* type, const byte* key,
92099209
{
92109210
0xC0
92119211
};
9212+
9213+
WOLFSSL_SMALL_STACK_STATIC const byte cipher1_7bit[] =
9214+
{
9215+
0x1C
9216+
};
92129217
#endif /* WOLFSSL_AES_128 */
92139218
#ifdef WOLFSSL_AES_192
92149219
WOLFSSL_SMALL_STACK_STATIC const byte iv2[] = {
@@ -9309,6 +9314,15 @@ static wc_test_ret_t EVP_test(const WOLFSSL_EVP_CIPHER* type, const byte* key,
93099314
ERROR_OUT(WC_TEST_RET_ENC_NC, out);
93109315
#endif /* HAVE_AES_DECRYPT */
93119316

9317+
XMEMSET(cipher, 0, sizeof(cipher));
9318+
ret = wc_AesCfb1Encrypt(enc, cipher, msg1, 7);
9319+
9320+
if (ret != 0)
9321+
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
9322+
9323+
if (cipher[0] != cipher1_7bit[0])
9324+
ERROR_OUT(WC_TEST_RET_ENC_NC, out);
9325+
93129326
#ifdef OPENSSL_EXTRA
93139327
ret = wc_AesSetKey(enc, key1, AES_BLOCK_SIZE, iv, AES_ENCRYPTION);
93149328
if (ret != 0)

0 commit comments

Comments
 (0)