summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--providers/implementations/encode_decode/encode_key2any.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/providers/implementations/encode_decode/encode_key2any.c b/providers/implementations/encode_decode/encode_key2any.c
index f142f2b242..9ee12a9fd4 100644
--- a/providers/implementations/encode_decode/encode_key2any.c
+++ b/providers/implementations/encode_decode/encode_key2any.c
@@ -701,6 +701,10 @@ static int prepare_ec_params(const void *eckey, int nid, int save,
static int ec_spki_pub_to_der(const void *eckey, unsigned char **pder)
{
+ if (EC_KEY_get0_public_key(eckey) == NULL) {
+ ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PUBLIC_KEY);
+ return 0;
+ }
return i2o_ECPublicKey(eckey, pder);
}