提交 82a46200 编写于 作者: T Tomas Mraz

Add checks for NULL return from EC_KEY_get0_group()

Reviewed-by: NMatt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/13139)
上级 f468e2f9
...@@ -172,6 +172,9 @@ static int pkey_ec_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen) ...@@ -172,6 +172,9 @@ static int pkey_ec_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen)
if (!key) { if (!key) {
const EC_GROUP *group; const EC_GROUP *group;
group = EC_KEY_get0_group(eckey); group = EC_KEY_get0_group(eckey);
if (group == NULL)
return 0;
*keylen = (EC_GROUP_get_degree(group) + 7) / 8; *keylen = (EC_GROUP_get_degree(group) + 7) / 8;
return 1; return 1;
} }
......
...@@ -1221,9 +1221,11 @@ int EVP_PKEY_get_group_name(const EVP_PKEY *pkey, char *gname, size_t gname_sz, ...@@ -1221,9 +1221,11 @@ int EVP_PKEY_get_group_name(const EVP_PKEY *pkey, char *gname, size_t gname_sz,
#ifndef OPENSSL_NO_EC #ifndef OPENSSL_NO_EC
case EVP_PKEY_EC: case EVP_PKEY_EC:
{ {
EC_KEY *ec = EVP_PKEY_get0_EC_KEY(pkey); const EC_GROUP *grp = EC_KEY_get0_group(EVP_PKEY_get0_EC_KEY(pkey));
int nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(ec)); int nid = NID_undef;
if (grp != NULL)
nid = EC_GROUP_get_curve_name(grp);
if (nid != NID_undef) if (nid != NID_undef)
name = ec_curve_nid2name(nid); name = ec_curve_nid2name(nid);
} }
...@@ -2271,6 +2273,8 @@ int EVP_PKEY_get_field_type(const EVP_PKEY *pkey) ...@@ -2271,6 +2273,8 @@ int EVP_PKEY_get_field_type(const EVP_PKEY *pkey)
if (ec == NULL) if (ec == NULL)
return 0; return 0;
grp = EC_KEY_get0_group(ec); grp = EC_KEY_get0_group(ec);
if (grp == NULL)
return 0;
return EC_GROUP_get_field_type(grp); return EC_GROUP_get_field_type(grp);
#else #else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册