Fixes #14704
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/14882)
if (iv != NULL) {
if (!ossl_cipher_generic_initiv(ctx, iv, ivlen))
return 0;
+ } else if (ctx->iv_set) {
+ /* reset IV to keep compatibility with 1.1.1 */
+ memcpy(ctx->iv, ctx->oiv, ctx->ivlen);
}
if (key != NULL) {
if (iv != NULL) {
if (!ossl_cipher_generic_initiv(ctx, iv, ivlen))
return 0;
+ } else if (ctx->iv_set
+ && (ctx->mode == EVP_CIPH_CBC_MODE
+ || ctx->mode == EVP_CIPH_CFB_MODE
+ || ctx->mode == EVP_CIPH_OFB_MODE)) {
+ /* reset IV to keep compatibility with 1.1.1 */
+ memcpy(ctx->iv, ctx->oiv, ctx->ivlen);
}
if (key != NULL) {