Set a verify tag while decrypting (which must succeed) before
attempting the read, so the test asserts that a tag cannot be read
back while decrypting even when one is _actually_ present.
This isolates direction logic from tag present logic.
Follow-up to #31734
Assisted-by: Claude:claude-opus-4-8
Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Wed Jul 8 18:06:40 2026
(Merged from https://github.com/openssl/openssl/pull/31826)
tagparams[0] = OSSL_PARAM_construct_octet_string(OSSL_CIPHER_PARAM_AEAD_TAG,
tag, info->taglen);
tagparams[1] = OSSL_PARAM_construct_end();
+
+ /* set a tag so the get below is exercised with one present */
+ if (!TEST_true(EVP_CIPHER_CTX_set_params(ctx_dec, tagparams))) {
+ errmsg = "DEC_SET_TAG_REJECTED";
+ goto err;
+ }
+
+ /* but a tag must never be readable back while decrypting */
ERR_set_mark();
if (!TEST_false(EVP_CIPHER_CTX_get_params(ctx_dec, tagparams))) {
ERR_clear_last_mark();