diff options
author | Paul Yang <kaishen.yy@antfin.com> | 2020-09-13 20:31:13 +0800 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2020-09-22 08:18:09 +0100 |
commit | b3d267caac21dd0a7d7a8cfcc304b253df5e82f4 (patch) | |
tree | 564617e6678615586334c8fdaecc794f06282364 /providers | |
parent | d0b79f8631c0f522c514175be4e4fbe984cf8f6c (diff) |
Address review comments
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/12536)
Diffstat (limited to 'providers')
-rw-r--r-- | providers/common/der/der_sm2_key.c | 2 | ||||
-rw-r--r-- | providers/implementations/signature/sm2sig.c | 36 |
2 files changed, 2 insertions, 36 deletions
diff --git a/providers/common/der/der_sm2_key.c b/providers/common/der/der_sm2_key.c index daf2072c9e..7167088099 100644 --- a/providers/common/der/der_sm2_key.c +++ b/providers/common/der/der_sm2_key.c @@ -16,7 +16,7 @@ int DER_w_algorithmIdentifier_SM2(WPACKET *pkt, int cont, EC_KEY *ec) { return DER_w_begin_sequence(pkt, cont) /* No parameters (yet?) */ - /* It seems SM2 identifier is the same to id_ecPublidKey */ + /* It seems SM2 identifier is the same as id_ecPublidKey */ && DER_w_precompiled(pkt, -1, der_oid_id_ecPublicKey, sizeof(der_oid_id_ecPublicKey)) && DER_w_end_sequence(pkt, cont); diff --git a/providers/implementations/signature/sm2sig.c b/providers/implementations/signature/sm2sig.c index 0e35fb4739..d2a091b89b 100644 --- a/providers/implementations/signature/sm2sig.c +++ b/providers/implementations/signature/sm2sig.c @@ -95,37 +95,6 @@ typedef struct { size_t id_len; } PROV_SM2_CTX; -/* TODO: it seems SM2 doesn't need this */ -static int sm2sig_get_md_nid(const EVP_MD *md) -{ - /* - * Because the EC library deals with NIDs, we need to translate. - * We do so using EVP_MD_is_a(), and therefore need a name to NID - * map. - */ - static const OSSL_ITEM name_to_nid[] = { - { NID_sm3, OSSL_DIGEST_NAME_SM3 }, - }; - size_t i; - int mdnid = NID_undef; - - if (md == NULL) - goto end; - - for (i = 0; i < OSSL_NELEM(name_to_nid); i++) { - if (EVP_MD_is_a(md, name_to_nid[i].ptr)) { - mdnid = (int)name_to_nid[i].id; - break; - } - } - - if (mdnid == NID_undef) - ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_DIGEST); - - end: - return mdnid; -} - static void *sm2sig_newctx(void *provctx, const char *propq) { PROV_SM2_CTX *ctx = OPENSSL_zalloc(sizeof(PROV_SM2_CTX)); @@ -207,7 +176,7 @@ static int sm2sig_digest_signverify_init(void *vpsm2ctx, const char *mdname, void *ec) { PROV_SM2_CTX *ctx = (PROV_SM2_CTX *)vpsm2ctx; - int md_nid = NID_undef; + int md_nid = NID_sm3; WPACKET pkt; int ret = 0; @@ -217,9 +186,6 @@ static int sm2sig_digest_signverify_init(void *vpsm2ctx, const char *mdname, return ret; ctx->md = EVP_MD_fetch(ctx->libctx, mdname, ctx->propq); - if ((md_nid = sm2sig_get_md_nid(ctx->md)) == NID_undef) - goto error; - ctx->mdsize = EVP_MD_size(ctx->md); ctx->mdctx = EVP_MD_CTX_new(); if (ctx->mdctx == NULL) |