You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
crypto: Assertation failed when createPrivateKey(PUBLIC) #29904
I have tried keyPair=require('crypto').generateKeyPairSync('rsa',{modulusLength:4096}) and keyPair=require('crypto').generateKeyPairSync('ec',{namedCurve:'P-256'}), the result are the same.
Activity
addaleax commentedon Oct 9, 2019
@nodejs/crypto @tniessen
sam-github commentedon Oct 9, 2019
@tespent can you provide a runnable reproduction, I can't repro:
tespent commentedon Oct 9, 2019
node -p "require('crypto').createPrivateKey({key:Buffer.from('MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEBEGMUwSkAYZNhIctHCL6VV/ufsVjGax0gWxBhCP9rZckKlcI1HQhIMv1qPzIS5zbFpud0YgrvZnYFkgWlJs5Ig==','base64'),format:'der',type:'spki'})"@sam-github
sam-github commentedon Oct 9, 2019
Thanks, I can repro
sam-github commentedon Oct 9, 2019
Its because spki is a public key format, and it isn't handled in the private key parsing code. I'm rebuildign to see if this fixes it:
crypto: reject public keys properly
tniessen commentedon Oct 10, 2019
Right, but I believe execution shouldn't even get to
ParsePrivateKeyin this case. Possible fix in #29913.crypto: reject public keys properly
crypto: reject public keys properly
crypto: reject public keys properly