-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Description
In 1.1.1 SM2 would work with any curve. You just had to remember to call EVP_PKEY_set_alias_type() with your key to make sure that it is handled as SM2 and not standard EC.
However if you have a key saved in a PEM file based that is intended to be used with SM2 but is based on some non-SM2 curve then it no longer seems to be possible to load it.
For example to load an SM2 key saved in SubjectPublicKeyInfo format then you might have used PEM_read_bio_PUBKEY to load it. The result would have been an EC key that you convert to SM2 using EVP_PKEY_set_alias_type(). However since the loaded key is now a provider side key the call to EVP_PKEY_set_alias_type() fails.
I thought it would be possible to load it another way using a DECODER directly, e.g.
dctx = OSSL_DECODER_CTX_new_for_pkey(&pkey, "PEM", "SubjectPublicKeyInfo",
"SM2",
OSSL_KEYMGMT_SELECT_PUBLIC_KEY
| OSSL_KEYMGMT_SELECT_ALL_PARAMETERS,
NULL, NULL);
Here I am telling the decoder directly to expect an SM2 key. However this still fails. Internally it loads the key as an EC key and then fails because it was expecting SM2.
This is related to but slightly different to the issue described in #14379.