summaryrefslogtreecommitdiffstats
path: root/crypto/sm2
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2020-03-10 23:00:45 +0100
committerRichard Levitte <levitte@openssl.org>2020-03-15 19:42:04 +0100
commit123c2fef14b80f26f5a8504ccf7b819c2975a6fa (patch)
tree766b01c65215a03bb2473a606d556f3b4dd1f065 /crypto/sm2
parentX509: Rename X509_set0_sm2_id() and friends (diff)
downloadopenssl-123c2fef14b80f26f5a8504ccf7b819c2975a6fa.tar.xz
openssl-123c2fef14b80f26f5a8504ccf7b819c2975a6fa.zip
SM2: Make the EVP_PKEY_METHOD ctrl_str function listen to distid
Because we start using Distinguished ID, we also define the key name "distid", possibly prefixed with "hex", but keep "sm2_id" and "sm2_hex_id" for compatibility with GmSSL. Fixes #11293 Reviewed-by: Paul Yang <kaishen.yy@antfin.com> (Merged from https://github.com/openssl/openssl/pull/11302)
Diffstat (limited to 'crypto/sm2')
-rw-r--r--crypto/sm2/sm2_pmeth.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/crypto/sm2/sm2_pmeth.c b/crypto/sm2/sm2_pmeth.c
index c3ba9280c5..9830fb8234 100644
--- a/crypto/sm2/sm2_pmeth.c
+++ b/crypto/sm2/sm2_pmeth.c
@@ -26,7 +26,7 @@
typedef struct {
/* message digest */
const EVP_MD *md;
- /* Distinguishing Identifier, ISO/IEC 15946-3 */
+ /* Distinguishing Identifier, ISO/IEC 15946-3, FIPS 196 */
uint8_t *id;
size_t id_len;
/* id_set indicates if the 'id' field is set (1) or not (0) */
@@ -247,14 +247,10 @@ static int pkey_sm2_ctrl_str(EVP_PKEY_CTX *ctx,
else
return -2;
return EVP_PKEY_CTX_set_ec_param_enc(ctx, param_enc);
- } else if (strcmp(type, "sm2_id") == 0) {
+ } else if (strcmp(type, "distid") == 0) {
return pkey_sm2_ctrl(ctx, EVP_PKEY_CTRL_SET1_ID,
(int)strlen(value), (void *)value);
- } else if (strcmp(type, "sm2_hex_id") == 0) {
- /*
- * TODO(3.0): reconsider the name "sm2_hex_id", OR change
- * OSSL_PARAM_allocate_from_text() to handle infix "_hex_"
- */
+ } else if (strcmp(type, "hexdistid") == 0) {
hex_id = OPENSSL_hexstr2buf((const char *)value, &hex_len);
if (hex_id == NULL) {
SM2err(SM2_F_PKEY_SM2_CTRL_STR, ERR_R_PASSED_INVALID_ARGUMENT);