Closed
Description
- Version: 12.11.1 and 12.7.0 (and more, i believe)
- Platform: Linux dev 5.3.5-arch1-1-ARCH deps: update openssl to 1.0.1j #1 SMP PREEMPT Mon Oct 7 19:03:08 UTC 2019 x86_64 GNU/Linux
crypto.createPrivateKey
raise an assertation failure when trying to import a public key.
Output of v12.11.1:
> keyPair.publicKey.export({format:'der',type:'spki'}).toString('base64')
'PUBLIC_KEY_IN_BASE64'
> pubkey=require('crypto').createPrivateKey({key:Buffer.from('PUBLIC_KEY_IN_BASE64','base64'),format:'der',type:'spki'})
node[8267]: ../src/node_crypto.cc:3299:node::crypto::ParseKeyResult node::crypto::ParsePrivateKey(node::crypto::EVPKeyPointer*, const node::crypto::PrivateKeyEncodingConfig&, const char*, size_t): Assertion `(config.type_.ToChecked()) == (kKeyEncodingSEC1)' failed.
1: 0x9d33e0 node::Abort() [node]
2: 0x9d3467 [node]
3: 0xace6ea [node]
4: 0xadf83e [node]
5: 0xae03e7 node::crypto::KeyObject::Init(v8::FunctionCallbackInfo<v8::Value> const&) [node]
6: 0xb9ec19 [node]
7: 0xba0a07 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [node]
8: 0x136d639 [node]
Aborted (core dumped)
I have tried keyPair=require('crypto').generateKeyPairSync('rsa',{modulusLength:4096})
and keyPair=require('crypto').generateKeyPairSync('ec',{namedCurve:'P-256'})
, the result are the same.