diff options
author | isaacs <i@izs.me> | 2020-07-23 20:58:04 +0300 |
---|---|---|
committer | isaacs <i@izs.me> | 2020-07-29 21:53:42 +0300 |
commit | ad5e07d8bd86d1dbe2b03dc142f8c8d6f4828ffe (patch) | |
tree | 97b66f97d77f35774f10a5e3e9957b1897d150bb /node_modules/sshpk/lib/formats/pkcs8.js | |
parent | a16994cfdd2f255016f3d8ee60d03473d80eabd8 (diff) |
Full dependency reboot
Reinstall everything from a clean node_modules and package-lock.json
state.
Re-generate list of bundleDependencies and node_modules/.gitignore with
a script that does the right thing based on actual dependency state.
Diffstat (limited to 'node_modules/sshpk/lib/formats/pkcs8.js')
-rw-r--r-- | node_modules/sshpk/lib/formats/pkcs8.js | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/node_modules/sshpk/lib/formats/pkcs8.js b/node_modules/sshpk/lib/formats/pkcs8.js index aa27427c1..2ca3ca7a2 100644 --- a/node_modules/sshpk/lib/formats/pkcs8.js +++ b/node_modules/sshpk/lib/formats/pkcs8.js @@ -1,10 +1,11 @@ -// Copyright 2015 Joyent, Inc. +// Copyright 2018 Joyent, Inc. module.exports = { read: read, readPkcs8: readPkcs8, write: write, writePkcs8: writePkcs8, + pkcs8ToBuffer: pkcs8ToBuffer, readECDSACurve: readECDSACurve, writeECDSACurve: writeECDSACurve @@ -300,10 +301,22 @@ function readPkcs8ECDSAPrivate(der) { assert.equal(version[0], 1, 'unknown version of ECDSA key'); var d = der.readString(asn1.Ber.OctetString, true); - der.readSequence(0xa1); + var Q; - var Q = der.readString(asn1.Ber.BitString, true); - Q = utils.ecNormalize(Q); + if (der.peek() == 0xa0) { + der.readSequence(0xa0); + der._offset += der.length; + } + if (der.peek() == 0xa1) { + der.readSequence(0xa1); + Q = der.readString(asn1.Ber.BitString, true); + Q = utils.ecNormalize(Q); + } + + if (Q === undefined) { + var pub = utils.publicFromPrivateECDSA(curveName, d); + Q = pub.part.Q.data; + } var key = { type: 'ecdsa', @@ -412,6 +425,12 @@ function readPkcs8X25519Private(der) { return (new PrivateKey(key)); } +function pkcs8ToBuffer(key) { + var der = new asn1.BerWriter(); + writePkcs8(der, key); + return (der.buffer); +} + function writePkcs8(der, key) { der.startSequence(); |