forked from wolfSSL/wolfssl
EVP_Cipher: correct parameter checking
EVP_Cipher(ctx, NULL, NULL, 0) is a valid call for all algorithms. For none-AEAD it results in a no-op.
This commit is contained in:
@ -8118,8 +8118,12 @@ void wolfSSL_EVP_init(void)
|
||||
|
||||
WOLFSSL_ENTER("wolfSSL_EVP_Cipher");
|
||||
|
||||
if (ctx == NULL || ((src == NULL || dst == NULL) &&
|
||||
(TRUE
|
||||
if (ctx == NULL) {
|
||||
WOLFSSL_MSG("Bad argument.");
|
||||
return WOLFSSL_FATAL_ERROR;
|
||||
}
|
||||
|
||||
if (TRUE
|
||||
#ifdef HAVE_AESGCM
|
||||
&& ctx->cipherType != AES_128_GCM_TYPE &&
|
||||
ctx->cipherType != AES_192_GCM_TYPE &&
|
||||
@ -8141,10 +8145,16 @@ void wolfSSL_EVP_init(void)
|
||||
#ifdef WOLFSSL_SM4_CCM
|
||||
&& ctx->cipherType != SM4_CCM_TYPE
|
||||
#endif
|
||||
))) {
|
||||
) {
|
||||
/* Not an AEAD cipher */
|
||||
/* No-op for none AEAD ciphers */
|
||||
if (src == NULL && dst == NULL && len == 0)
|
||||
return 0;
|
||||
if (src == NULL || dst == NULL) {
|
||||
WOLFSSL_MSG("Bad argument.");
|
||||
return WOLFSSL_FATAL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->cipherType == WOLFSSL_EVP_CIPH_TYPE_INIT) {
|
||||
WOLFSSL_MSG("Cipher operation not initialized. Call "
|
||||
|
Reference in New Issue
Block a user