New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault during reading EC Private Key DER without optional Public Key #395

Closed
k06a opened this Issue Mar 10, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@k06a
Copy link

k06a commented Mar 10, 2018

$ /usr/local/Cellar/libressl/2.6.4/bin/openssl ec -inform DER -text -noout -in <(cat <(echo -n "302e0201010420") <(echo -n "692b97aa63e919fae7e30d64c7f59e06aa967324f02896c70430a9e1f617a8b2") <(echo -n "a00706052b8104000a") | xxd -r -p)

read EC key
Segmentation fault: 11
$ /usr/local/Cellar/openssl/1.0.2n/bin/openssl ec -inform DER -text -noout -in <(cat <(echo -n "302e0201010420") <(echo -n "692b97aa63e919fae7e30d64c7f59e06aa967324f02896c70430a9e1f617a8b2") <(echo -n "a00706052b8104000a") | xxd -r -p)

read EC key
Private-Key: (256 bit)
priv:
    69:2b:97:aa:63:e9:19:fa:e7:e3:0d:64:c7:f5:9e:
    06:aa:96:73:24:f0:28:96:c7:04:30:a9:e1:f6:17:
    a8:b2
pub: 
    04:29:22:60:c8:64:f7:a0:fe:d7:11:f9:e0:57:6c:
    ca:50:0d:ad:ee:d3:c8:83:1e:00:5c:64:8e:44:db:
    5c:42:87:a3:cf:ad:53:97:84:ff:c2:d6:4a:9a:5f:
    10:e9:66:a7:4e:bd:bb:45:d0:0e:b9:b6:d8:21:4d:
    f4:30:26:62:9d
ASN1 OID: secp256k1

Here is the detailed investigation: https://stackoverflow.com/a/49213805/440168

The core idea is that Public Key field is optional (https://www.ietf.org/rfc/rfc5915.txt) and this can be used to calculate Public Key for Private Key.

@k06a k06a changed the title Segmentation fault during reading private key from DER without optional public key Segmentation fault during reading EC Private Key DER without optional Public Key Mar 10, 2018

@kinichiro

This comment has been minimized.

Copy link
Member

kinichiro commented Mar 11, 2018

commit openssl/openssl@0388ac4 appears to resolve this issue.

@k06a

This comment has been minimized.

Copy link

k06a commented Mar 11, 2018

@kinichiro do you think this commit can be cherry-picked?

busterb pushed a commit to libressl-portable/openbsd that referenced this issue Mar 12, 2018

inoguchi
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 libressl-portable/portable#395
by Anton Bukov (@k06a) .

ok beck@
@kinichiro

This comment has been minimized.

Copy link
Member

kinichiro commented Mar 12, 2018

This commit libressl-portable/openbsd@f075249 will solve this issue.
Can you close this issue ?

@k06a

This comment has been minimized.

Copy link

k06a commented Mar 12, 2018

@kinichiro thanks, sure!

@k06a k06a closed this Mar 12, 2018

bob-beck pushed a commit to openbsd/src that referenced this issue Mar 12, 2018

inoguchi
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 libressl-portable/portable#395
by Anton Bukov (@k06a) .

ok beck@

hakrdinesh pushed a commit to hakrtech/openbsd-src0-test that referenced this issue Mar 19, 2018

inoguchi
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 libressl-portable/portable#395
by Anton Bukov (@k06a) .

ok beck@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment