summaryrefslogtreecommitdiff
path: root/lib/libcrypto/ec/ec_ameth.c
diff options
context:
space:
mode:
authorKinichiro Inoguchi <inoguchi@cvs.openbsd.org>2018-03-12 13:14:22 +0000
committerKinichiro Inoguchi <inoguchi@cvs.openbsd.org>2018-03-12 13:14:22 +0000
commit7bd86ab52752834955470ebc5fe27a3b7987d9e5 (patch)
tree8c5b7d173b7350456075a10bda87dd0dce27264a /lib/libcrypto/ec/ec_ameth.c
parent6394c01daaa86a1fcd902da410ccc529e246225d (diff)
Fix for processing of EC public key
Prevents segmentation fault while reading EC private key without public key. Generates missing EC public key when reading EC private key. Refer to these OpenSSL commits: 1f2b943254ce590867717375e4f364860a9b7154 2083f7c465d07867dd9867b8742bb71c03d1f203 Reported on GitHub https://github.com/libressl-portable/portable/issues/395 by Anton Bukov (@k06a) . ok beck@
Diffstat (limited to 'lib/libcrypto/ec/ec_ameth.c')
-rw-r--r--lib/libcrypto/ec/ec_ameth.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/libcrypto/ec/ec_ameth.c b/lib/libcrypto/ec/ec_ameth.c
index 8d0cdb733b0..0932f1e3c91 100644
--- a/lib/libcrypto/ec/ec_ameth.c
+++ b/lib/libcrypto/ec/ec_ameth.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ec_ameth.c,v 1.18 2017/01/29 17:49:23 beck Exp $ */
+/* $OpenBSD: ec_ameth.c,v 1.19 2018/03/12 13:14:21 inoguchi Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
*/
@@ -433,13 +433,15 @@ do_EC_KEY_print(BIO * bp, const EC_KEY * x, int off, int ktype)
}
if (ktype > 0) {
public_key = EC_KEY_get0_public_key(x);
- if ((pub_key = EC_POINT_point2bn(group, public_key,
+ if (public_key != NULL) {
+ if ((pub_key = EC_POINT_point2bn(group, public_key,
EC_KEY_get_conv_form(x), NULL, ctx)) == NULL) {
- reason = ERR_R_EC_LIB;
- goto err;
+ reason = ERR_R_EC_LIB;
+ goto err;
+ }
+ if (pub_key)
+ buf_len = (size_t) BN_num_bytes(pub_key);
}
- if (pub_key)
- buf_len = (size_t) BN_num_bytes(pub_key);
}
if (ktype == 2) {
priv_key = EC_KEY_get0_private_key(x);