summaryrefslogtreecommitdiff
path: root/providers/implementations/ciphers/cipher_sm4_hw.c
diff options
context:
space:
mode:
Diffstat (limited to 'providers/implementations/ciphers/cipher_sm4_hw.c')
-rw-r--r--providers/implementations/ciphers/cipher_sm4_hw.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/providers/implementations/ciphers/cipher_sm4_hw.c b/providers/implementations/ciphers/cipher_sm4_hw.c
index 1fd916a565..d8bc5a1e85 100644
--- a/providers/implementations/ciphers/cipher_sm4_hw.c
+++ b/providers/implementations/ciphers/cipher_sm4_hw.c
@@ -42,6 +42,19 @@ static int cipher_hw_sm4_initkey(PROV_CIPHER_CTX *ctx,
(void)0; /* terminate potentially open 'else' */
} else
#endif
+#ifdef VPSM4_EX_CAPABLE
+ if (VPSM4_EX_CAPABLE) {
+ vpsm4_ex_set_encrypt_key(key, ks);
+ ctx->block = (block128_f)vpsm4_ex_encrypt;
+ ctx->stream.cbc = NULL;
+ if (ctx->mode == EVP_CIPH_CBC_MODE)
+ ctx->stream.cbc = (cbc128_f)vpsm4_ex_cbc_encrypt;
+ else if (ctx->mode == EVP_CIPH_ECB_MODE)
+ ctx->stream.ecb = (ecb128_f)vpsm4_ex_ecb_encrypt;
+ else if (ctx->mode == EVP_CIPH_CTR_MODE)
+ ctx->stream.ctr = (ctr128_f)vpsm4_ex_ctr32_encrypt_blocks;
+ } else
+#endif
#ifdef VPSM4_CAPABLE
if (VPSM4_CAPABLE) {
vpsm4_set_encrypt_key(key, ks);
@@ -75,6 +88,17 @@ static int cipher_hw_sm4_initkey(PROV_CIPHER_CTX *ctx,
#endif
} else
#endif
+#ifdef VPSM4_EX_CAPABLE
+ 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;
+ else if (ctx->mode == EVP_CIPH_ECB_MODE)
+ ctx->stream.ecb = (ecb128_f)vpsm4_ex_ecb_encrypt;
+ } else
+#endif
#ifdef VPSM4_CAPABLE
if (VPSM4_CAPABLE) {
vpsm4_set_decrypt_key(key, ks);
@@ -82,7 +106,7 @@ static int cipher_hw_sm4_initkey(PROV_CIPHER_CTX *ctx,
ctx->stream.cbc = NULL;
if (ctx->mode == EVP_CIPH_CBC_MODE)
ctx->stream.cbc = (cbc128_f)vpsm4_cbc_encrypt;
- else if (ctx->mode == EVP_CIPH_ECB_MODE)
+ else if (ctx->mode == EVP_CIPH_ECB_MODE)
ctx->stream.ecb = (ecb128_f)vpsm4_ecb_encrypt;
} else
#endif