mirror of https://github.com/openssl/openssl.git
fix SM2 privatekey decode(PEM format, ECPrivateKey).
Reviewed-by: Paul Dale <ppzgs1@gmail.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/27963)
This commit is contained in:
parent
e7d5398aa1
commit
bd172dd0e1
|
@ -57,6 +57,7 @@ extern "C" {
|
|||
# define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY"
|
||||
# define PEM_STRING_PARAMETERS "PARAMETERS"
|
||||
# define PEM_STRING_CMS "CMS"
|
||||
# define PEM_STRING_SM2PRIVATEKEY "SM2 PRIVATE KEY"
|
||||
# define PEM_STRING_SM2PARAMETERS "SM2 PARAMETERS"
|
||||
# define PEM_STRING_ACERT "ATTRIBUTE CERTIFICATE"
|
||||
|
||||
|
|
|
@ -151,6 +151,7 @@ static int pem2der_decode(void *vctx, OSSL_CORE_BIO *cin, int selection,
|
|||
{ PEM_STRING_DSAPARAMS, OSSL_OBJECT_PKEY, "DSA", "type-specific" },
|
||||
{ PEM_STRING_ECPRIVATEKEY, OSSL_OBJECT_PKEY, "EC", "type-specific" },
|
||||
{ PEM_STRING_ECPARAMETERS, OSSL_OBJECT_PKEY, "EC", "type-specific" },
|
||||
{ PEM_STRING_SM2PRIVATEKEY, OSSL_OBJECT_PKEY, "SM2", "type-specific" },
|
||||
{ PEM_STRING_SM2PARAMETERS, OSSL_OBJECT_PKEY, "SM2", "type-specific" },
|
||||
{ PEM_STRING_RSA, OSSL_OBJECT_PKEY, "RSA", "type-specific" },
|
||||
{ PEM_STRING_RSA_PUBLIC, OSSL_OBJECT_PKEY, "RSA", "type-specific" },
|
||||
|
|
|
@ -18,7 +18,7 @@ setup("test_ec");
|
|||
|
||||
plan skip_all => 'EC is not supported in this build' if disabled('ec');
|
||||
|
||||
plan tests => 15;
|
||||
plan tests => 16;
|
||||
|
||||
my $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0);
|
||||
|
||||
|
@ -33,6 +33,10 @@ subtest 'EC conversions -- private key' => sub {
|
|||
tconversion( -type => 'ec', -prefix => 'ec-priv',
|
||||
-in => srctop_file("test","testec-p256.pem") );
|
||||
};
|
||||
subtest 'EC conversions -- private key' => sub {
|
||||
tconversion( -type => 'ec', -prefix => 'sm2-priv',
|
||||
-in => srctop_file("test","testec-sm2.pem") );
|
||||
};
|
||||
subtest 'EC conversions -- private key PKCS#8' => sub {
|
||||
tconversion( -type => 'ec', -prefix => 'ec-pkcs8',
|
||||
-in => srctop_file("test","testec-p256.pem"),
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
-----BEGIN SM2 PRIVATE KEY-----
|
||||
MHcCAQEEIKPB7gEYKGAwAkz0MfGwQm0BXclgzvSTxQG9bm4RCAxXoAoGCCqBHM9V
|
||||
AYItoUQDQgAE+FuibOpfjVfj716O3LglhK4HzjUR82mgn8kTZinQsEafw3FFZzZJ
|
||||
vwHIGHUsSKxVTRIEs+BICQDBg99OA3VU/Q==
|
||||
-----END SM2 PRIVATE KEY-----
|
Loading…
Reference in New Issue