In AEAD cipher providers raise an error when EVP_DecryptFinal_ex()
is called without the authentication tag being set.
Fixes #28730
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28872)
return 0;
/* The tag must be set before actually decrypting data */
- if (!ctx->base.enc && ctx->tag_len == 0)
+ if (!ctx->base.enc && ctx->tag_len == 0) {
+ ERR_raise(ERR_LIB_PROV, PROV_R_TAG_NOT_SET);
return 0;
+ }
if (hw->aead_cipher((PROV_CIPHER_CTX *)ctx, out, outl, NULL, 0) <= 0)
return 0;
ctx->tag_set = 1;
} else {
/* The tag must be set before actually decrypting data */
- if (!ctx->tag_set)
+ if (!ctx->tag_set) {
+ ERR_raise(ERR_LIB_PROV, PROV_R_TAG_NOT_SET);
goto err;
+ }
if (!hw->auth_decrypt(ctx, in, out, len, ctx->buf, ctx->m))
goto err;
}
} else {
/* The tag must be set before actually decrypting data */
- if (!ctx->enc && ctx->taglen == UNINITIALISED_SIZET)
+ if (!ctx->enc && ctx->taglen == UNINITIALISED_SIZET) {
+ ERR_raise(ERR_LIB_PROV, PROV_R_TAG_NOT_SET);
goto err;
+ }
if (!hw->cipherfinal(ctx, ctx->buf))
goto err;
ctx->iv_state = IV_STATE_FINISHED; /* Don't reuse the IV */