Code was updated for s390 that accidently removed the check inside the final method.
Moving the check up before the final method is called is a better way of handling this.
The oneshot method also calls the final method but doesnt need to do this check.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9945)
goto err;
}
} else {
- /* Finished when in == NULL */
+ /* The tag must be set before actually decrypting data */
+ if (!ctx->enc && ctx->taglen == UNINITIALISED_SIZET)
+ goto err;
if (!hw->cipherfinal(ctx, ctx->buf))
goto err;
ctx->iv_state = IV_STATE_FINISHED; /* Don't reuse the IV */
CRYPTO_gcm128_tag(&ctx->gcm, tag, GCM_TAG_MAX_SIZE);
ctx->taglen = GCM_TAG_MAX_SIZE;
} else {
- if (ctx->taglen == UNINITIALISED_SIZET
- || CRYPTO_gcm128_finish(&ctx->gcm, tag, ctx->taglen) != 0)
+ if (CRYPTO_gcm128_finish(&ctx->gcm, tag, ctx->taglen) != 0)
return 0;
}
return 1;