From cc0c6261fdc9fe35aff060204164d57f94e79d16 Mon Sep 17 00:00:00 2001 From: Iakov Polyak Date: Tue, 30 Sep 2025 16:25:01 +0100 Subject: [PATCH] Enabled vpsm4_(ex)_cbc back on decryption. --- providers/implementations/ciphers/cipher_sm4_hw.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/providers/implementations/ciphers/cipher_sm4_hw.c b/providers/implementations/ciphers/cipher_sm4_hw.c index 0ad3cee298..d9c585b27d 100644 --- a/providers/implementations/ciphers/cipher_sm4_hw.c +++ b/providers/implementations/ciphers/cipher_sm4_hw.c @@ -85,19 +85,23 @@ static int cipher_hw_sm4_initkey(PROV_CIPHER_CTX *ctx, } else #endif #ifdef VPSM4_EX_CAPABLE - if (VPSM4_EX_CAPABLE && (ctx->mode != EVP_CIPH_CBC_MODE)) { + if (VPSM4_EX_CAPABLE) { vpsm4_ex_set_decrypt_key(key, ks); ctx->block = (block128_f)vpsm4_ex_decrypt; ctx->stream.cbc = NULL; + if (ctx->mode == EVP_CIPH_CBC_MODE) + ctx->stream.cbc = (cbc128_f)vpsm4_ex_cbc_encrypt; if (ctx->mode == EVP_CIPH_ECB_MODE) ctx->stream.ecb = (ecb128_f)vpsm4_ex_ecb_encrypt; } else #endif #ifdef VPSM4_CAPABLE - if (VPSM4_CAPABLE && (ctx->mode != EVP_CIPH_CBC_MODE)) { + if (VPSM4_CAPABLE) { vpsm4_set_decrypt_key(key, ks); ctx->block = (block128_f)vpsm4_decrypt; ctx->stream.cbc = NULL; + if (ctx->mode == EVP_CIPH_CBC_MODE) + ctx->stream.cbc = (cbc128_f)vpsm4_cbc_encrypt; if (ctx->mode == EVP_CIPH_ECB_MODE) ctx->stream.ecb = (ecb128_f)vpsm4_ecb_encrypt; } else