digitalbazaar / forge

A native implementation of TLS in Javascript and tools to write crypto-based and network-heavy webapps
https://digitalbazaar.com/
Other
5.04k stars 778 forks source link

Does forge support ec256 keys? #1093

Open sbweeden opened 1 month ago

sbweeden commented 1 month ago

More of a question than an issue I guess - but tried this:

PEM file of EC256 key:

-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIFB2teeHGu5T7bh597NtvJJJ/WumONRAkfOzYCP1nKEFoAoGCCqGSM49
AwEHoUQDQgAEaYys5soGb5m0vg1sgNRTw+/2WthcZO3FI1ALhu62jszNvcyipL7s
/4Vx/bP11KhwnwhX9ucDyq+HtV1dmgXmig==
-----END EC PRIVATE KEY-----

JS code:

let pkiPrivateKey = pki.privateKeyFromPem( <string of PEM above> );

Got error:

Error: Cannot read public key. Unknown OID.
    at pki.publicKeyFromAsn1 (.../node_modules/node-forge/lib/rsa.js:1474:19)
    at pki.publicKeyFromPem(.../node_modules/node-forge/lib/x509.js:865:14)
...

Looks like it assumes RSA keys. No support at all for EC256?

El-Virus commented 1 month ago

Do take a look at: #925