diff options
Diffstat (limited to 'node_modules/sshpk/lib/private-key.js')
-rw-r--r-- | node_modules/sshpk/lib/private-key.js | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/node_modules/sshpk/lib/private-key.js b/node_modules/sshpk/lib/private-key.js index 77f667cd2..560083801 100644 --- a/node_modules/sshpk/lib/private-key.js +++ b/node_modules/sshpk/lib/private-key.js @@ -14,14 +14,8 @@ var utils = require('./utils'); var dhe = require('./dhe'); var generateECDSA = dhe.generateECDSA; var generateED25519 = dhe.generateED25519; -var edCompat; -var nacl; - -try { - edCompat = require('./ed-compat'); -} catch (e) { - /* Just continue through, and bail out if we try to use it. */ -} +var edCompat = require('./ed-compat'); +var nacl = require('tweetnacl'); var Key = require('./key'); @@ -60,8 +54,12 @@ PrivateKey.prototype.toBuffer = function (format, options) { return (formats[format].write(this, options)); }; -PrivateKey.prototype.hash = function (algo) { - return (this.toPublic().hash(algo)); +PrivateKey.prototype.hash = function (algo, type) { + return (this.toPublic().hash(algo, type)); +}; + +PrivateKey.prototype.fingerprint = function (algo, type) { + return (this.toPublic().fingerprint(algo, type)); }; PrivateKey.prototype.toPublic = function () { @@ -90,9 +88,6 @@ PrivateKey.prototype.derive = function (newType) { var priv, pub, pair; if (this.type === 'ed25519' && newType === 'curve25519') { - if (nacl === undefined) - nacl = require('tweetnacl'); - priv = this.part.k.data; if (priv[0] === 0x00) priv = priv.slice(1); @@ -108,9 +103,6 @@ PrivateKey.prototype.derive = function (newType) { ] })); } else if (this.type === 'curve25519' && newType === 'ed25519') { - if (nacl === undefined) - nacl = require('tweetnacl'); - priv = this.part.k.data; if (priv[0] === 0x00) priv = priv.slice(1); @@ -237,8 +229,9 @@ PrivateKey.generate = function (type, options) { * [1,3] -- added derive, ed, createDH * [1,4] -- first tagged version * [1,5] -- changed ed25519 part names and format + * [1,6] -- type arguments for hash() and fingerprint() */ -PrivateKey.prototype._sshpkApiVersion = [1, 5]; +PrivateKey.prototype._sshpkApiVersion = [1, 6]; PrivateKey._oldVersionDetect = function (obj) { assert.func(obj.toPublic); |