Skip to content

Commit 6bfb522

Browse files
committed
Allow we_aes_cbc_init to be called with NULL IV and key.
Previously, if the IV and key were both NULL, we treated it as an error. However, now that we're using `EVP_CIPH_ALWAYS_CALL_INIT`, this function can potentially be called with both parameters NULL. OpenSSL handles this case fine, so wolfEngine should, too. It's a no-op.
1 parent 8309c37 commit 6bfb522

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

src/we_aes_block.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@ static int we_aes_cbc_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
7171
WOLFENGINE_MSG_VERBOSE(WE_LOG_CIPHER, "ARGS [ctx = %p, key = %p, "
7272
"iv = %p, enc = %d]", ctx, key, iv, enc);
7373

74-
if ((iv == NULL) && (key == NULL)) {
75-
WOLFENGINE_ERROR_MSG(WE_LOG_CIPHER, "iv == NULL && key == NULL");
76-
ret = 0;
77-
}
78-
7974
if (ret == 1) {
8075
aes = (we_AesBlock *)EVP_CIPHER_CTX_get_cipher_data(ctx);
8176
if (aes == NULL) {
@@ -289,12 +284,7 @@ static int we_aes_cbc_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
289284
return ret;
290285
}
291286

292-
/** Flags for AES-CBC method.
293-
*
294-
* NOTE: EVP_CIPH_ALWAYS_CALL_INIT is deliberately not added. This flag
295-
* causes the AES init method to be called even if key is NULL. Currently
296-
* wolfEngine does not need to initialize until a key is available.
297-
*/
287+
/* Flags for AES-CBC method. */
298288
#define AES_CBC_FLAGS \
299289
(EVP_CIPH_FLAG_DEFAULT_ASN1 | \
300290
EVP_CIPH_CBC_MODE | \

0 commit comments

Comments
 (0)