summaryrefslogtreecommitdiffstats
path: root/providers/implementations/encode_decode/encode_key2text.c
diff options
context:
space:
mode:
authorK1 <dongbeiouba@gmail.com>2022-07-19 01:18:12 +0800
committerPauli <pauli@openssl.org>2022-08-23 11:08:11 +1000
commit08ae9fa627e858b9f8e96e0c6d3cf84422a11d75 (patch)
tree5292239db11fb2586ceb1b56ed1125e95cd760fc /providers/implementations/encode_decode/encode_key2text.c
parentc92c3dfb99485eb2cfb840e92bd0ece8cdd72d0c (diff)
Support decode SM2 parameters
Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18819)
Diffstat (limited to 'providers/implementations/encode_decode/encode_key2text.c')
-rw-r--r--providers/implementations/encode_decode/encode_key2text.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/providers/implementations/encode_decode/encode_key2text.c b/providers/implementations/encode_decode/encode_key2text.c
index 7d983f5e51..a92e04a89d 100644
--- a/providers/implementations/encode_decode/encode_key2text.c
+++ b/providers/implementations/encode_decode/encode_key2text.c
@@ -512,7 +512,8 @@ static int ec_to_text(BIO *out, const void *key, int selection)
else if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0)
type_label = "Public-Key";
else if ((selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0)
- type_label = "EC-Parameters";
+ if (EC_GROUP_get_curve_name(group) != NID_sm2)
+ type_label = "EC-Parameters";
if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {
const BIGNUM *priv_key = EC_KEY_get0_private_key(ec);
@@ -538,8 +539,9 @@ static int ec_to_text(BIO *out, const void *key, int selection)
goto err;
}
- if (BIO_printf(out, "%s: (%d bit)\n", type_label,
- EC_GROUP_order_bits(group)) <= 0)
+ if (type_label != NULL
+ && BIO_printf(out, "%s: (%d bit)\n", type_label,
+ EC_GROUP_order_bits(group)) <= 0)
goto err;
if (priv != NULL
&& !print_labeled_buf(out, "priv:", priv, priv_len))