Skip to content

Commit a6ddc11

Browse files
committed
Enabled runtime detection of VPSM4_EX_CAPABLE in cipher_sm4_hw.c.
1 parent 7e080da commit a6ddc11

1 file changed

Lines changed: 24 additions & 24 deletions

File tree

providers/implementations/ciphers/cipher_sm4_hw.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,19 @@ static int cipher_hw_sm4_initkey(PROV_CIPHER_CTX *ctx,
4242
(void)0; /* terminate potentially open 'else' */
4343
} else
4444
#endif
45-
//#ifdef VPSM4_EX_CAPABLE
46-
// if (VPSM4_EX_CAPABLE) {
47-
// vpsm4_ex_set_encrypt_key(key, ks);
48-
// ctx->block = (block128_f)vpsm4_ex_encrypt;
49-
// ctx->stream.cbc = NULL;
50-
// if (ctx->mode == EVP_CIPH_CBC_MODE)
51-
// ctx->stream.cbc = (cbc128_f)vpsm4_ex_cbc_encrypt;
52-
// else if (ctx->mode == EVP_CIPH_ECB_MODE)
53-
// ctx->stream.ecb = (ecb128_f)vpsm4_ex_ecb_encrypt;
54-
// else if (ctx->mode == EVP_CIPH_CTR_MODE)
55-
// ctx->stream.ctr = (ctr128_f)vpsm4_ex_ctr32_encrypt_blocks;
56-
// } else
57-
//#endif
45+
#ifdef VPSM4_EX_CAPABLE
46+
if (VPSM4_EX_CAPABLE) {
47+
vpsm4_ex_set_encrypt_key(key, ks);
48+
ctx->block = (block128_f)vpsm4_ex_encrypt;
49+
ctx->stream.cbc = NULL;
50+
if (ctx->mode == EVP_CIPH_CBC_MODE)
51+
ctx->stream.cbc = (cbc128_f)vpsm4_ex_cbc_encrypt;
52+
else if (ctx->mode == EVP_CIPH_ECB_MODE)
53+
ctx->stream.ecb = (ecb128_f)vpsm4_ex_ecb_encrypt;
54+
else if (ctx->mode == EVP_CIPH_CTR_MODE)
55+
ctx->stream.ctr = (ctr128_f)vpsm4_ex_ctr32_encrypt_blocks;
56+
} else
57+
#endif
5858
#ifdef VPSM4_CAPABLE
5959
if (VPSM4_CAPABLE) {
6060
vpsm4_set_encrypt_key(key, ks);
@@ -88,17 +88,17 @@ static int cipher_hw_sm4_initkey(PROV_CIPHER_CTX *ctx,
8888
#endif
8989
} else
9090
#endif
91-
//#ifdef VPSM4_EX_CAPABLE
92-
// if (VPSM4_EX_CAPABLE) {
93-
// vpsm4_ex_set_decrypt_key(key, ks);
94-
// ctx->block = (block128_f)vpsm4_ex_decrypt;
95-
// ctx->stream.cbc = NULL;
96-
// if (ctx->mode == EVP_CIPH_CBC_MODE)
97-
// ctx->stream.cbc = (cbc128_f)vpsm4_ex_cbc_encrypt;
98-
// else if (ctx->mode == EVP_CIPH_ECB_MODE)
99-
// ctx->stream.ecb = (ecb128_f)vpsm4_ex_ecb_encrypt;
100-
// } else
101-
//#endif
91+
#ifdef VPSM4_EX_CAPABLE
92+
if (VPSM4_EX_CAPABLE) {
93+
vpsm4_ex_set_decrypt_key(key, ks);
94+
ctx->block = (block128_f)vpsm4_ex_decrypt;
95+
ctx->stream.cbc = NULL;
96+
if (ctx->mode == EVP_CIPH_CBC_MODE)
97+
ctx->stream.cbc = (cbc128_f)vpsm4_ex_cbc_encrypt;
98+
else if (ctx->mode == EVP_CIPH_ECB_MODE)
99+
ctx->stream.ecb = (ecb128_f)vpsm4_ex_ecb_encrypt;
100+
} else
101+
#endif
102102
#ifdef VPSM4_CAPABLE
103103
if (VPSM4_CAPABLE) {
104104
vpsm4_set_decrypt_key(key, ks);

0 commit comments

Comments
 (0)