@@ -1846,10 +1846,7 @@ _test_sm2_sign(bool rnd_secret)
/* Setup asym xform */
xform.next = NULL;
xform.xform_type = RTE_CRYPTO_ASYM_XFORM_SM2;
- if (rte_cryptodev_asym_xform_capability_check_hash(capa, RTE_CRYPTO_AUTH_SM3))
- xform.sm2.hash = RTE_CRYPTO_AUTH_SM3;
- else
- xform.sm2.hash = RTE_CRYPTO_AUTH_NULL;
+ xform.ec.curve_id = input_params.curve;
ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
if (ret < 0) {
@@ -1867,6 +1864,11 @@ _test_sm2_sign(bool rnd_secret)
/* Populate op with operational details */
asym_op->sm2.op_type = RTE_CRYPTO_ASYM_OP_SIGN;
+ if (rte_cryptodev_asym_xform_capability_check_hash(capa, RTE_CRYPTO_AUTH_SM3))
+ asym_op->sm2.hash = RTE_CRYPTO_AUTH_SM3;
+ else
+ asym_op->sm2.hash = RTE_CRYPTO_AUTH_NULL;
+
asym_op->sm2.message.data = input_params.message.data;
asym_op->sm2.message.length = input_params.message.length;
asym_op->sm2.pkey.data = input_params.pkey.data;
@@ -2038,10 +2040,7 @@ test_sm2_verify(void)
/* Setup asym xform */
xform.next = NULL;
xform.xform_type = RTE_CRYPTO_ASYM_XFORM_SM2;
- if (rte_cryptodev_asym_xform_capability_check_hash(capa, RTE_CRYPTO_AUTH_SM3))
- xform.sm2.hash = RTE_CRYPTO_AUTH_SM3;
- else
- xform.sm2.hash = RTE_CRYPTO_AUTH_NULL;
+ xform.ec.curve_id = input_params.curve;
ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
if (ret < 0) {
@@ -2059,6 +2058,11 @@ test_sm2_verify(void)
/* Populate op with operational details */
asym_op->sm2.op_type = RTE_CRYPTO_ASYM_OP_VERIFY;
+ if (rte_cryptodev_asym_xform_capability_check_hash(capa, RTE_CRYPTO_AUTH_SM3))
+ asym_op->sm2.hash = RTE_CRYPTO_AUTH_SM3;
+ else
+ asym_op->sm2.hash = RTE_CRYPTO_AUTH_NULL;
+
asym_op->sm2.message.data = input_params.message.data;
asym_op->sm2.message.length = input_params.message.length;
asym_op->sm2.pkey.data = input_params.pkey.data;
@@ -2150,10 +2154,7 @@ _test_sm2_enc(bool rnd_secret)
/* Setup asym xform */
xform.next = NULL;
xform.xform_type = RTE_CRYPTO_ASYM_XFORM_SM2;
- if (rte_cryptodev_asym_xform_capability_check_hash(capa, RTE_CRYPTO_AUTH_SM3))
- xform.sm2.hash = RTE_CRYPTO_AUTH_SM3;
- else
- xform.sm2.hash = RTE_CRYPTO_AUTH_NULL;
+ xform.ec.curve_id = input_params.curve;
ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
if (ret < 0) {
@@ -2171,6 +2172,11 @@ _test_sm2_enc(bool rnd_secret)
/* Populate op with operational details */
asym_op->sm2.op_type = RTE_CRYPTO_ASYM_OP_ENCRYPT;
+ if (rte_cryptodev_asym_xform_capability_check_hash(capa, RTE_CRYPTO_AUTH_SM3))
+ asym_op->sm2.hash = RTE_CRYPTO_AUTH_SM3;
+ else
+ asym_op->sm2.hash = RTE_CRYPTO_AUTH_NULL;
+
asym_op->sm2.message.data = input_params.message.data;
asym_op->sm2.message.length = input_params.message.length;
asym_op->sm2.pkey.data = input_params.pkey.data;
@@ -2340,10 +2346,7 @@ test_sm2_dec(void)
/* Setup asym xform */
xform.next = NULL;
xform.xform_type = RTE_CRYPTO_ASYM_XFORM_SM2;
- if (rte_cryptodev_asym_xform_capability_check_hash(capa, RTE_CRYPTO_AUTH_SM3))
- xform.sm2.hash = RTE_CRYPTO_AUTH_SM3;
- else
- xform.sm2.hash = RTE_CRYPTO_AUTH_NULL;
+ xform.ec.curve_id = input_params.curve;
ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
if (ret < 0) {
@@ -2361,6 +2364,11 @@ test_sm2_dec(void)
/* Populate op with operational details */
asym_op->sm2.op_type = RTE_CRYPTO_ASYM_OP_DECRYPT;
+ if (rte_cryptodev_asym_xform_capability_check_hash(capa, RTE_CRYPTO_AUTH_SM3))
+ asym_op->sm2.hash = RTE_CRYPTO_AUTH_SM3;
+ else
+ asym_op->sm2.hash = RTE_CRYPTO_AUTH_NULL;
+
asym_op->sm2.cipher.data = input_params.cipher.data;
asym_op->sm2.cipher.length = input_params.cipher.length;
asym_op->sm2.pkey.data = input_params.pkey.data;
@@ -17,6 +17,7 @@ struct crypto_testsuite_sm2_params {
rte_crypto_param id;
rte_crypto_param cipher;
rte_crypto_param message;
+ int curve;
};
static uint8_t fp256_pkey[] = {
@@ -123,7 +124,8 @@ struct crypto_testsuite_sm2_params sm2_param_fp256 = {
.cipher = {
.data = fp256_cipher,
.length = sizeof(fp256_cipher),
- }
+ },
+ .curve = RTE_CRYPTO_EC_GROUP_SM2
};
#endif /* __TEST_CRYPTODEV_SM2_TEST_VECTORS_H__ */
@@ -97,6 +97,8 @@ Removed Items
* kni: Removed the Kernel Network Interface (KNI) library and driver.
+* crypto: Removed SM2 xform parameter in asymmetric xform.
+
API Changes
-----------
@@ -1305,9 +1305,6 @@ static int openssl_set_asym_session_parameters(
OSSL_PARAM *params = NULL;
int ret = -1;
- if (xform->sm2.hash != RTE_CRYPTO_AUTH_SM3)
- return -1;
-
param_bld = OSSL_PARAM_BLD_new();
if (!param_bld) {
OPENSSL_LOG(ERR, "failed to allocate params\n");
@@ -69,7 +69,8 @@ enum rte_crypto_curve_id {
RTE_CRYPTO_EC_GROUP_SECP224R1 = 21,
RTE_CRYPTO_EC_GROUP_SECP256R1 = 23,
RTE_CRYPTO_EC_GROUP_SECP384R1 = 24,
- RTE_CRYPTO_EC_GROUP_SECP521R1 = 25
+ RTE_CRYPTO_EC_GROUP_SECP521R1 = 25,
+ RTE_CRYPTO_EC_GROUP_SM2 = 41,
};
/**
@@ -378,16 +379,6 @@ struct rte_crypto_ec_xform {
/**< Pre-defined ec groups */
};
-/**
- * Asymmetric SM2 transform data.
- *
- * Structure describing SM2 xform params.
- */
-struct rte_crypto_sm2_xform {
- enum rte_crypto_auth_algorithm hash;
- /**< Hash algorithm used in SM2 op. */
-};
-
/**
* Operations params for modular operations:
* exponentiation and multiplicative inverse
@@ -644,9 +635,6 @@ struct rte_crypto_asym_xform {
/**< EC xform parameters, used by elliptic curve based
* operations.
*/
-
- struct rte_crypto_sm2_xform sm2;
- /**< SM2 xform parameters */
};
};
@@ -657,6 +645,9 @@ struct rte_crypto_sm2_op_param {
enum rte_crypto_asym_op_type op_type;
/**< Signature generation or verification. */
+ enum rte_crypto_auth_algorithm hash;
+ /**< Hash algorithm used in EC op. */
+
rte_crypto_uint pkey;
/**< Private key for encryption or sign generation. */