-
Notifications
You must be signed in to change notification settings - Fork 197
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
elliptic-curve: SEC1 private key export not loadable with OpenSSL #1706
Comments
It appears the curve OID (in context sensitive field Here is the OpenSSL-generated key: $ openssl asn1parse -in key.pem
0:d=0 hl=2 l= 119 cons: SEQUENCE
2:d=1 hl=2 l= 1 prim: INTEGER :01
5:d=1 hl=2 l= 32 prim: OCTET STRING [HEX DUMP]:E76BD09F83B1A7555A435C2069EE3BA1AB8982BE8DE2C56AC01F377693A1630D
39:d=1 hl=2 l= 10 cons: cont [ 0 ]
41:d=2 hl=2 l= 8 prim: OBJECT :prime256v1
51:d=1 hl=2 l= 68 cons: cont [ 1 ]
53:d=2 hl=2 l= 66 prim: BIT STRING Here is the $ openssl asn1parse -in key.pem
0:d=0 hl=2 l= 107 cons: SEQUENCE
2:d=1 hl=2 l= 1 prim: INTEGER :01
5:d=1 hl=2 l= 32 prim: OCTET STRING [HEX DUMP]:31B211BC55E02841DECAE770DFB18DAF364BEE678F168BC6C3A9DA54DC9381F5
39:d=1 hl=2 l= 68 cons: cont [ 1 ]
41:d=2 hl=2 l= 66 prim: BIT STRING |
I understand that this is in fact a bug in the |
Correct. I'm working on a fix. It's unfortunately a bit tricky to test as it's in code generic over curves, but requires a concrete curve implementation to test. |
Another issue I see is that if this will be changed both was (i.e. |
The OID identifies the particular elliptic curve the key is for. Without it, OpenSSL can't parse these keys. See #1706.
PR open: #1707 It's not technically a breaking change: before it didn't check the OID whatsoever, now it only checks it if present. Though it is a breaking API change as it relies on the It could be changed to always require the OID, although that would require some changes to the PKCS#8 parser which relies on the ability to handle an empty OID currently. (Sidebar: I am surprised so many people are using SEC1 keys. They're a legacy format that has been replaced by PKCS#8) |
The OID identifies the particular elliptic curve the key is for. Without it, OpenSSL can't parse these keys. See #1706.
The OID identifies the particular elliptic curve the key is for. Without it, OpenSSL can't parse these keys. See #1706.
I merged that PR, but I'll need to add some tests it works for a concrete curve to I can try to figure out some stopgap tests in |
Unfortunately that's due to various integration needs on my side ;). |
Hello,
I'm not sure if this is something I misunderstand or some other issue, but when I export a PEM of p256 to a file,
openssl
is not able to recognize the file when loading with:This is how I generate the key:
The result of
openssl ec -in key.pem -pubout
:On the other hand, if I use
openssl
to write the private key, the result is what is expected:The text was updated successfully, but these errors were encountered: