openssl/crypto/asn1
Todd Short 3dbec21b46 Fix d2i_PublicKey() for EC keys
o2i_ECPublicKey() requires an EC_KEY structure filled with an EC_GROUP.

o2i_ECPublicKey() is called by d2i_PublicKey(). In order to fulfill the
o2i_ECPublicKey()'s requirement, d2i_PublicKey() needs to be called with
an EVP_PKEY with an EC_KEY containing an EC_GROUP.

However, the call to EVP_PKEY_set_type() frees any existing key structure
inside the EVP_PKEY, thus freeing the EC_KEY with the EC_GROUP that
o2i_ECPublicKey() needs.

This means you can't d2i_PublicKey() for an EC key...

The fix is to check to see if the type is already set appropriately, and
if so, not call EVP_PKEY_set_type().

Reviewed-by: Paul Yang <yang.yang@baishancloud.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8168)

(cherry picked from commit 2aa2beb06c)
2019-02-08 10:04:13 +00:00
..
a_bitstr.c Remove parentheses of return. 2017-10-18 16:05:06 +01:00
a_d2i_fp.c Remove parentheses of return. 2017-10-18 16:05:06 +01:00
a_digest.c Coverity fix in some crypto/asn1 code 2018-12-22 18:13:56 +01:00
a_dup.c Remove parentheses of return. 2017-10-18 16:05:06 +01:00
a_gentm.c This has been added to avoid the situation where some host ctype.h functions 2017-08-22 09:45:25 +10:00
a_i2d_fp.c Add error handling in dsa_main and ASN1_i2d_bio. 2017-11-03 15:46:51 +01:00
a_int.c Remove parentheses of return. 2017-10-18 16:05:06 +01:00
a_mbstr.c This has been added to avoid the situation where some host ctype.h functions 2017-08-22 09:45:25 +10:00
a_object.c i2d_ASN1_OBJECT(): allocate memory if the user didn't provide a buffer 2018-08-11 12:27:02 +02:00
a_octet.c
a_print.c Remove parentheses of return. 2017-10-18 16:05:06 +01:00
a_sign.c Coverity fix in some crypto/asn1 code 2018-12-22 18:13:56 +01:00
a_strex.c Limit scope of CN name constraints 2018-05-23 11:12:13 -04:00
a_strnid.c Update copyright year 2018-04-17 15:18:40 +02:00
a_time.c Fix return value of ASN1_TIME_compare 2017-08-30 11:24:02 -04:00
a_type.c Remove parentheses of return. 2017-10-18 16:05:06 +01:00
a_utctm.c This has been added to avoid the situation where some host ctype.h functions 2017-08-22 09:45:25 +10:00
a_utf8.c
a_verify.c Coverity fix in some crypto/asn1 code 2018-12-22 18:13:56 +01:00
ameth_lib.c Make EVP_PKEY_asn1_add0() stricter about its input 2018-12-07 11:59:11 +01:00
asn1_err.c i2d_ASN1_OBJECT(): allocate memory if the user didn't provide a buffer 2018-08-11 12:27:02 +02:00
asn1_gen.c
asn1_item_list.c
asn1_item_list.h make scrypt ASN.1 parameter functions public 2017-07-26 15:04:54 -04:00
asn1_lib.c Change return (x) to return x 2017-07-14 07:32:58 +10:00
asn1_locl.h asn1_item_embed_new(): don't free an embedded item 2017-10-24 20:52:12 +02:00
asn1_par.c Memory bounds checking in asn1 code. 2017-07-06 12:59:51 +10:00
asn_mime.c Harmonize use of sk_TYPE_find's return value. 2018-08-07 08:56:54 +02:00
asn_moid.c asn1/asn_moid.c: overhaul do_create. 2018-08-22 21:35:27 +02:00
asn_mstbl.c This has been added to avoid the situation where some host ctype.h functions 2017-08-22 09:45:25 +10:00
asn_pack.c
bio_asn1.c Update copyright year 2018-04-17 15:18:40 +02:00
bio_ndef.c Update copyright year 2018-04-17 15:18:40 +02:00
build.info
charmap.h make update 2019-01-03 09:26:34 +00:00
charmap.pl Update generator copyright year. 2019-01-07 13:53:24 -05:00
d2i_pr.c Remove parentheses of return. 2017-10-18 16:05:06 +01:00
d2i_pu.c Fix d2i_PublicKey() for EC keys 2019-02-08 10:04:13 +00:00
evp_asn1.c Remove parentheses of return. 2017-10-18 16:05:06 +01:00
f_int.c Remove parentheses of return. 2017-10-18 16:05:06 +01:00
f_string.c Remove parentheses of return. 2017-10-18 16:05:06 +01:00
i2d_pr.c
i2d_pu.c
n_pkey.c ASN.1: adapt our use of INTxx et al by making them explicitely embedded 2017-04-13 10:23:31 +02:00
nsseq.c
p5_pbe.c
p5_pbev2.c Update copyright year 2018-06-20 15:29:23 +01:00
p5_scrypt.c add 'unsupported cipher mode' diagnostics to evp_lib.c and genpkey.c 2018-06-18 10:45:35 +01:00
p8_pkey.c
standard_methods.h Move SM2 algos to SM2 specific PKEY method 2018-06-19 11:29:44 +01:00
t_bitst.c
t_pkey.c
t_spki.c
tasn_dec.c Update copyright year 2018-04-03 13:57:12 +01:00
tasn_enc.c Set error code on alloc failures 2018-04-03 11:31:16 -04:00
tasn_fre.c asn1_item_embed_new(): don't free an embedded item 2017-10-24 20:52:12 +02:00
tasn_new.c Update copyright year 2018-04-17 15:18:40 +02:00
tasn_prn.c Consistent formatting for sizeof(foo) 2017-12-07 19:11:49 -05:00
tasn_scn.c
tasn_typ.c
tasn_utl.c asn1/tasn_utl.c: fix logical error in and overhaul asn1_do_lock. 2018-08-01 16:07:24 +02:00
tbl_standard.h Add some OID's from X.520 2017-05-31 13:33:20 -04:00
x_algor.c Address some code-analysis issues. 2017-12-08 10:49:41 -05:00
x_bignum.c
x_info.c
x_int64.c ASN.1 DER: Make INT32 / INT64 types read badly encoded LONG zeroes 2018-09-09 03:39:37 +02:00
x_long.c Memory bounds checking in asn1 code. 2017-07-06 12:59:51 +10:00
x_pkey.c
x_sig.c
x_spki.c Cleanup some copyright stuff 2017-06-30 21:56:44 -04:00
x_val.c