summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ec/ec_ameth.c
diff options
context:
space:
mode:
authorinoguchi <>2018-03-12 13:14:21 +0000
committerinoguchi <>2018-03-12 13:14:21 +0000
commitb4ddb0f51fc8a6934ca72ca243bd2e1237e3db44 (patch)
tree70fcd8bdcb756233389e3bf8967307f6b2d3072c /src/lib/libcrypto/ec/ec_ameth.c
parent6eca2d8d7b6a897175b9334bc65767f168e61b76 (diff)
downloadopenbsd-b4ddb0f51fc8a6934ca72ca243bd2e1237e3db44.tar.gz
openbsd-b4ddb0f51fc8a6934ca72ca243bd2e1237e3db44.tar.bz2
openbsd-b4ddb0f51fc8a6934ca72ca243bd2e1237e3db44.zip
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 'src/lib/libcrypto/ec/ec_ameth.c')
-rw-r--r--src/lib/libcrypto/ec/ec_ameth.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/lib/libcrypto/ec/ec_ameth.c b/src/lib/libcrypto/ec/ec_ameth.c
index 8d0cdb733b..0932f1e3c9 100644
--- a/src/lib/libcrypto/ec/ec_ameth.c
+++ b/src/lib/libcrypto/ec/ec_ameth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_ameth.c,v 1.18 2017/01/29 17:49:23 beck Exp $ */ 1/* $OpenBSD: ec_ameth.c,v 1.19 2018/03/12 13:14:21 inoguchi Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -433,13 +433,15 @@ do_EC_KEY_print(BIO * bp, const EC_KEY * x, int off, int ktype)
433 } 433 }
434 if (ktype > 0) { 434 if (ktype > 0) {
435 public_key = EC_KEY_get0_public_key(x); 435 public_key = EC_KEY_get0_public_key(x);
436 if ((pub_key = EC_POINT_point2bn(group, public_key, 436 if (public_key != NULL) {
437 if ((pub_key = EC_POINT_point2bn(group, public_key,
437 EC_KEY_get_conv_form(x), NULL, ctx)) == NULL) { 438 EC_KEY_get_conv_form(x), NULL, ctx)) == NULL) {
438 reason = ERR_R_EC_LIB; 439 reason = ERR_R_EC_LIB;
439 goto err; 440 goto err;
441 }
442 if (pub_key)
443 buf_len = (size_t) BN_num_bytes(pub_key);
440 } 444 }
441 if (pub_key)
442 buf_len = (size_t) BN_num_bytes(pub_key);
443 } 445 }
444 if (ktype == 2) { 446 if (ktype == 2) {
445 priv_key = EC_KEY_get0_private_key(x); 447 priv_key = EC_KEY_get0_private_key(x);