summaryrefslogtreecommitdiffstats
path: root/crypto/evp/pmeth_gn.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2020-09-02 09:30:42 +0200
committerRichard Levitte <levitte@openssl.org>2020-09-08 06:25:27 +0200
commit509144964ba69b69a90269da52a2dc3acb3149e6 (patch)
tree0dacf1c9eb45dd8bf460288ef08f2b410b1f8ae7 /crypto/evp/pmeth_gn.c
parent884baafba4a5fec6502b828a73188d7133b9179b (diff)
EVP: Preserve the EVP_PKEY id in a few more spots
As long as there are internal legacy keys for EVP_PKEY, we need to preserve the EVP_PKEY numeric identity when generating a key, and when creating the EVP_PKEY_CTX. For added consistency, the EVP_PKEY_CTX contructor tries a little harder to find a EVP_PKEY_METHOD. Otherwise, we may run into situations where the EVP_PKEY_CTX ends up having no associated methods at all. Reviewed-by: Paul Yang <kaishen.yy@antfin.com> (Merged from https://github.com/openssl/openssl/pull/12785)
Diffstat (limited to 'crypto/evp/pmeth_gn.c')
-rw-r--r--crypto/evp/pmeth_gn.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/crypto/evp/pmeth_gn.c b/crypto/evp/pmeth_gn.c
index 3096828678..b8dad20abd 100644
--- a/crypto/evp/pmeth_gn.c
+++ b/crypto/evp/pmeth_gn.c
@@ -212,6 +212,12 @@ int EVP_PKEY_gen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey)
evp_pkey_free_legacy(*ppkey);
#endif
+ /*
+ * Because we still have legacy keys, and evp_pkey_downgrade()
+ * TODO remove this #legacy internal keys are gone
+ */
+ (*ppkey)->type = ctx->legacy_keytype;
+
/* TODO remove when SM2 key have been cleanly separated from EC keys */
#ifdef TMP_SM2_HACK
/*