mirror of
https://github.com/S2-/minifyfromhtml.git
synced 2025-08-03 20:30:04 +02:00
update node modules
This commit is contained in:
41
node_modules/sshpk/lib/key.js
generated
vendored
41
node_modules/sshpk/lib/key.js
generated
vendored
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017 Joyent, Inc.
|
||||
// Copyright 2018 Joyent, Inc.
|
||||
|
||||
module.exports = Key;
|
||||
|
||||
@@ -32,6 +32,8 @@ formats['ssh'] = require('./formats/ssh');
|
||||
formats['ssh-private'] = require('./formats/ssh-private');
|
||||
formats['openssh'] = formats['ssh-private'];
|
||||
formats['dnssec'] = require('./formats/dnssec');
|
||||
formats['putty'] = require('./formats/putty');
|
||||
formats['ppk'] = formats['putty'];
|
||||
|
||||
function Key(opts) {
|
||||
assert.object(opts, 'options');
|
||||
@@ -98,28 +100,44 @@ Key.prototype.toString = function (format, options) {
|
||||
return (this.toBuffer(format, options).toString());
|
||||
};
|
||||
|
||||
Key.prototype.hash = function (algo) {
|
||||
Key.prototype.hash = function (algo, type) {
|
||||
assert.string(algo, 'algorithm');
|
||||
assert.optionalString(type, 'type');
|
||||
if (type === undefined)
|
||||
type = 'ssh';
|
||||
algo = algo.toLowerCase();
|
||||
if (algs.hashAlgs[algo] === undefined)
|
||||
throw (new InvalidAlgorithmError(algo));
|
||||
|
||||
if (this._hashCache[algo])
|
||||
return (this._hashCache[algo]);
|
||||
var hash = crypto.createHash(algo).
|
||||
update(this.toBuffer('rfc4253')).digest();
|
||||
this._hashCache[algo] = hash;
|
||||
var cacheKey = algo + '||' + type;
|
||||
if (this._hashCache[cacheKey])
|
||||
return (this._hashCache[cacheKey]);
|
||||
|
||||
var buf;
|
||||
if (type === 'ssh') {
|
||||
buf = this.toBuffer('rfc4253');
|
||||
} else if (type === 'spki') {
|
||||
buf = formats.pkcs8.pkcs8ToBuffer(this);
|
||||
} else {
|
||||
throw (new Error('Hash type ' + type + ' not supported'));
|
||||
}
|
||||
var hash = crypto.createHash(algo).update(buf).digest();
|
||||
this._hashCache[cacheKey] = hash;
|
||||
return (hash);
|
||||
};
|
||||
|
||||
Key.prototype.fingerprint = function (algo) {
|
||||
Key.prototype.fingerprint = function (algo, type) {
|
||||
if (algo === undefined)
|
||||
algo = 'sha256';
|
||||
if (type === undefined)
|
||||
type = 'ssh';
|
||||
assert.string(algo, 'algorithm');
|
||||
assert.string(type, 'type');
|
||||
var opts = {
|
||||
type: 'key',
|
||||
hash: this.hash(algo),
|
||||
algorithm: algo
|
||||
hash: this.hash(algo, type),
|
||||
algorithm: algo,
|
||||
hashType: type
|
||||
};
|
||||
return (new Fingerprint(opts));
|
||||
};
|
||||
@@ -257,8 +275,9 @@ Key.isKey = function (obj, ver) {
|
||||
* [1,4] -- added ed support, createDH
|
||||
* [1,5] -- first explicitly tagged version
|
||||
* [1,6] -- changed ed25519 part names
|
||||
* [1,7] -- spki hash types
|
||||
*/
|
||||
Key.prototype._sshpkApiVersion = [1, 6];
|
||||
Key.prototype._sshpkApiVersion = [1, 7];
|
||||
|
||||
Key._oldVersionDetect = function (obj) {
|
||||
assert.func(obj.toBuffer);
|
||||
|
Reference in New Issue
Block a user