Skip to content
Snippets Groups Projects
index.js 8.18 MiB
Newer Older
  • Learn to ignore specific revisions
  • Hugo NOUTS's avatar
    Hugo NOUTS committed
    13001 13002 13003 13004 13005 13006 13007 13008 13009 13010 13011 13012 13013 13014 13015 13016 13017 13018 13019 13020 13021 13022 13023 13024 13025 13026 13027 13028 13029 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 13063 13064 13065 13066 13067 13068 13069 13070 13071 13072 13073 13074 13075 13076 13077 13078 13079 13080 13081 13082 13083 13084 13085 13086 13087 13088 13089 13090 13091 13092 13093 13094 13095 13096 13097 13098 13099 13100 13101 13102 13103 13104 13105 13106 13107 13108 13109 13110 13111 13112 13113 13114 13115 13116 13117 13118 13119 13120 13121 13122 13123 13124 13125 13126 13127 13128 13129 13130 13131 13132 13133 13134 13135 13136 13137 13138 13139 13140 13141 13142 13143 13144 13145 13146 13147 13148 13149 13150 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 13174 13175 13176 13177 13178 13179 13180 13181 13182 13183 13184 13185 13186 13187 13188 13189 13190 13191 13192 13193 13194 13195 13196 13197 13198 13199 13200 13201 13202 13203 13204 13205 13206 13207 13208 13209 13210 13211 13212 13213 13214 13215 13216 13217 13218 13219 13220 13221 13222 13223 13224 13225 13226 13227 13228 13229 13230 13231 13232 13233 13234 13235 13236 13237 13238 13239 13240 13241 13242 13243 13244 13245 13246 13247 13248 13249 13250 13251 13252 13253 13254 13255 13256 13257 13258 13259 13260 13261 13262 13263 13264 13265 13266 13267 13268 13269 13270 13271 13272 13273 13274 13275 13276 13277 13278 13279 13280 13281 13282 13283 13284 13285 13286 13287 13288 13289 13290 13291 13292 13293 13294 13295 13296 13297 13298 13299 13300 13301 13302 13303 13304 13305 13306 13307 13308 13309 13310 13311 13312 13313 13314 13315 13316 13317 13318 13319 13320 13321 13322 13323 13324 13325 13326 13327 13328 13329 13330 13331 13332 13333 13334 13335 13336 13337 13338 13339 13340 13341 13342 13343 13344 13345 13346 13347 13348 13349 13350 13351 13352 13353 13354 13355 13356 13357 13358 13359 13360 13361 13362 13363 13364 13365 13366 13367 13368 13369 13370 13371 13372 13373 13374 13375 13376 13377 13378 13379 13380 13381 13382 13383 13384 13385 13386 13387 13388 13389 13390 13391 13392 13393 13394 13395 13396 13397 13398 13399 13400 13401 13402 13403 13404 13405 13406 13407 13408 13409 13410 13411 13412 13413 13414 13415 13416 13417 13418 13419 13420 13421 13422 13423 13424 13425 13426 13427 13428 13429 13430 13431 13432 13433 13434 13435 13436 13437 13438 13439 13440 13441 13442 13443 13444 13445 13446 13447 13448 13449 13450 13451 13452 13453 13454 13455 13456 13457 13458 13459 13460 13461 13462 13463 13464 13465 13466 13467 13468 13469 13470 13471 13472 13473 13474 13475 13476 13477 13478 13479 13480 13481 13482 13483 13484 13485 13486 13487 13488 13489 13490 13491 13492 13493 13494 13495 13496 13497 13498 13499 13500 13501 13502 13503 13504 13505 13506 13507 13508 13509 13510 13511 13512 13513 13514 13515 13516 13517 13518 13519 13520 13521 13522 13523 13524 13525 13526 13527 13528 13529 13530 13531 13532 13533 13534 13535 13536 13537 13538 13539 13540 13541 13542 13543 13544 13545 13546 13547 13548 13549 13550 13551 13552 13553 13554 13555 13556 13557 13558 13559 13560 13561 13562 13563 13564 13565 13566 13567 13568 13569 13570 13571 13572 13573 13574 13575 13576 13577 13578 13579 13580 13581 13582 13583 13584 13585 13586 13587 13588 13589 13590 13591 13592 13593 13594 13595 13596 13597 13598 13599 13600 13601 13602 13603 13604 13605 13606 13607 13608 13609 13610 13611 13612 13613 13614 13615 13616 13617 13618 13619 13620 13621 13622 13623 13624 13625 13626 13627 13628 13629 13630 13631 13632 13633 13634 13635 13636 13637 13638 13639 13640 13641 13642 13643 13644 13645 13646 13647 13648 13649 13650 13651 13652 13653 13654 13655 13656 13657 13658 13659 13660 13661 13662 13663 13664 13665 13666 13667 13668 13669 13670 13671 13672 13673 13674 13675 13676 13677 13678 13679 13680 13681 13682 13683 13684 13685 13686 13687 13688 13689 13690 13691 13692 13693 13694 13695 13696 13697 13698 13699 13700 13701 13702 13703 13704 13705 13706 13707 13708 13709 13710 13711 13712 13713 13714 13715 13716 13717 13718 13719 13720 13721 13722 13723 13724 13725 13726 13727 13728 13729 13730 13731 13732 13733 13734 13735 13736 13737 13738 13739 13740 13741 13742 13743 13744 13745 13746 13747 13748 13749 13750 13751 13752 13753 13754 13755 13756 13757 13758 13759 13760 13761 13762 13763 13764 13765 13766 13767 13768 13769 13770 13771 13772 13773 13774 13775 13776 13777 13778 13779 13780 13781 13782 13783 13784 13785 13786 13787 13788 13789 13790 13791 13792 13793 13794 13795 13796 13797 13798 13799 13800 13801 13802 13803 13804 13805 13806 13807 13808 13809 13810 13811 13812 13813 13814 13815 13816 13817 13818 13819 13820 13821 13822 13823 13824 13825 13826 13827 13828 13829 13830 13831 13832 13833 13834 13835 13836 13837 13838 13839 13840 13841 13842 13843 13844 13845 13846 13847 13848 13849 13850 13851 13852 13853 13854 13855 13856 13857 13858 13859 13860 13861 13862 13863 13864 13865 13866 13867 13868 13869 13870 13871 13872 13873 13874 13875 13876 13877 13878 13879 13880 13881 13882 13883 13884 13885 13886 13887 13888 13889 13890 13891 13892 13893 13894 13895 13896 13897 13898 13899 13900 13901 13902 13903 13904 13905 13906 13907 13908 13909 13910 13911 13912 13913 13914 13915 13916 13917 13918 13919 13920 13921 13922 13923 13924 13925 13926 13927 13928 13929 13930 13931 13932 13933 13934 13935 13936 13937 13938 13939 13940 13941 13942 13943 13944 13945 13946 13947 13948 13949 13950 13951 13952 13953 13954 13955 13956 13957 13958 13959 13960 13961 13962 13963 13964 13965 13966 13967 13968 13969 13970 13971 13972 13973 13974 13975 13976 13977 13978 13979 13980 13981 13982 13983 13984 13985 13986 13987 13988 13989 13990 13991 13992 13993 13994 13995 13996 13997 13998 13999 14000
          throw new InvalidHeaderError('algorithm was not specified');
    
        if (!parsed.params.signature)
          throw new InvalidHeaderError('signature was not specified');
    
        // Check the algorithm against the official list
        parsed.params.algorithm = parsed.params.algorithm.toLowerCase();
        try {
          validateAlgorithm(parsed.params.algorithm);
        } catch (e) {
          if (e instanceof InvalidAlgorithmError)
            throw (new InvalidParamsError(parsed.params.algorithm + ' is not ' +
              'supported'));
          else
            throw (e);
        }
    
        // Build the signingString
        for (i = 0; i < parsed.params.headers.length; i++) {
          var h = parsed.params.headers[i].toLowerCase();
          parsed.params.headers[i] = h;
    
          if (h === 'request-line') {
            if (!options.strict) {
              /*
               * We allow headers from the older spec drafts if strict parsing isn't
               * specified in options.
               */
              parsed.signingString +=
                request.method + ' ' + request.url + ' HTTP/' + request.httpVersion;
            } else {
              /* Strict parsing doesn't allow older draft headers. */
              throw (new StrictParsingError('request-line is not a valid header ' +
                'with strict parsing enabled.'));
            }
          } else if (h === '(request-target)') {
            parsed.signingString +=
              '(request-target): ' + request.method.toLowerCase() + ' ' +
              request.url;
          } else {
            var value = request.headers[h];
            if (value === undefined)
              throw new MissingHeaderError(h + ' was not in the request');
            parsed.signingString += h + ': ' + value;
          }
    
          if ((i + 1) < parsed.params.headers.length)
            parsed.signingString += '\n';
        }
    
        // Check against the constraints
        var date;
        if (request.headers.date || request.headers['x-date']) {
            if (request.headers['x-date']) {
              date = new Date(request.headers['x-date']);
            } else {
              date = new Date(request.headers.date);
            }
          var now = new Date();
          var skew = Math.abs(now.getTime() - date.getTime());
    
          if (skew > options.clockSkew * 1000) {
            throw new ExpiredRequestError('clock skew of ' +
                                          (skew / 1000) +
                                          's was greater than ' +
                                          options.clockSkew + 's');
          }
        }
    
        options.headers.forEach(function (hdr) {
          // Remember that we already checked any headers in the params
          // were in the request, so if this passes we're good.
          if (parsed.params.headers.indexOf(hdr.toLowerCase()) < 0)
            throw new MissingHeaderError(hdr + ' was not a signed header');
        });
    
        if (options.algorithms) {
          if (options.algorithms.indexOf(parsed.params.algorithm) === -1)
            throw new InvalidParamsError(parsed.params.algorithm +
                                         ' is not a supported algorithm');
        }
    
        parsed.algorithm = parsed.params.algorithm.toUpperCase();
        parsed.keyId = parsed.params.keyId;
        return parsed;
      }
    
    };
    
    
    /***/ }),
    /* 90 */
    /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
    
    // Copyright (c) 2012, Mark Cavage. All rights reserved.
    // Copyright 2015 Joyent, Inc.
    
    var assert = __webpack_require__(91);
    var Stream = (__webpack_require__(82).Stream);
    var util = __webpack_require__(64);
    
    
    ///--- Globals
    
    /* JSSTYLED */
    var UUID_REGEXP = /^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/;
    
    
    ///--- Internal
    
    function _capitalize(str) {
        return (str.charAt(0).toUpperCase() + str.slice(1));
    }
    
    function _toss(name, expected, oper, arg, actual) {
        throw new assert.AssertionError({
            message: util.format('%s (%s) is required', name, expected),
            actual: (actual === undefined) ? typeof (arg) : actual(arg),
            expected: expected,
            operator: oper || '===',
            stackStartFunction: _toss.caller
        });
    }
    
    function _getClass(arg) {
        return (Object.prototype.toString.call(arg).slice(8, -1));
    }
    
    function noop() {
        // Why even bother with asserts?
    }
    
    
    ///--- Exports
    
    var types = {
        bool: {
            check: function (arg) { return typeof (arg) === 'boolean'; }
        },
        func: {
            check: function (arg) { return typeof (arg) === 'function'; }
        },
        string: {
            check: function (arg) { return typeof (arg) === 'string'; }
        },
        object: {
            check: function (arg) {
                return typeof (arg) === 'object' && arg !== null;
            }
        },
        number: {
            check: function (arg) {
                return typeof (arg) === 'number' && !isNaN(arg);
            }
        },
        finite: {
            check: function (arg) {
                return typeof (arg) === 'number' && !isNaN(arg) && isFinite(arg);
            }
        },
        buffer: {
            check: function (arg) { return Buffer.isBuffer(arg); },
            operator: 'Buffer.isBuffer'
        },
        array: {
            check: function (arg) { return Array.isArray(arg); },
            operator: 'Array.isArray'
        },
        stream: {
            check: function (arg) { return arg instanceof Stream; },
            operator: 'instanceof',
            actual: _getClass
        },
        date: {
            check: function (arg) { return arg instanceof Date; },
            operator: 'instanceof',
            actual: _getClass
        },
        regexp: {
            check: function (arg) { return arg instanceof RegExp; },
            operator: 'instanceof',
            actual: _getClass
        },
        uuid: {
            check: function (arg) {
                return typeof (arg) === 'string' && UUID_REGEXP.test(arg);
            },
            operator: 'isUUID'
        }
    };
    
    function _setExports(ndebug) {
        var keys = Object.keys(types);
        var out;
    
        /* re-export standard assert */
        if (process.env.NODE_NDEBUG) {
            out = noop;
        } else {
            out = function (arg, msg) {
                if (!arg) {
                    _toss(msg, 'true', arg);
                }
            };
        }
    
        /* standard checks */
        keys.forEach(function (k) {
            if (ndebug) {
                out[k] = noop;
                return;
            }
            var type = types[k];
            out[k] = function (arg, msg) {
                if (!type.check(arg)) {
                    _toss(msg, k, type.operator, arg, type.actual);
                }
            };
        });
    
        /* optional checks */
        keys.forEach(function (k) {
            var name = 'optional' + _capitalize(k);
            if (ndebug) {
                out[name] = noop;
                return;
            }
            var type = types[k];
            out[name] = function (arg, msg) {
                if (arg === undefined || arg === null) {
                    return;
                }
                if (!type.check(arg)) {
                    _toss(msg, k, type.operator, arg, type.actual);
                }
            };
        });
    
        /* arrayOf checks */
        keys.forEach(function (k) {
            var name = 'arrayOf' + _capitalize(k);
            if (ndebug) {
                out[name] = noop;
                return;
            }
            var type = types[k];
            var expected = '[' + k + ']';
            out[name] = function (arg, msg) {
                if (!Array.isArray(arg)) {
                    _toss(msg, expected, type.operator, arg, type.actual);
                }
                var i;
                for (i = 0; i < arg.length; i++) {
                    if (!type.check(arg[i])) {
                        _toss(msg, expected, type.operator, arg, type.actual);
                    }
                }
            };
        });
    
        /* optionalArrayOf checks */
        keys.forEach(function (k) {
            var name = 'optionalArrayOf' + _capitalize(k);
            if (ndebug) {
                out[name] = noop;
                return;
            }
            var type = types[k];
            var expected = '[' + k + ']';
            out[name] = function (arg, msg) {
                if (arg === undefined || arg === null) {
                    return;
                }
                if (!Array.isArray(arg)) {
                    _toss(msg, expected, type.operator, arg, type.actual);
                }
                var i;
                for (i = 0; i < arg.length; i++) {
                    if (!type.check(arg[i])) {
                        _toss(msg, expected, type.operator, arg, type.actual);
                    }
                }
            };
        });
    
        /* re-export built-in assertions */
        Object.keys(assert).forEach(function (k) {
            if (k === 'AssertionError') {
                out[k] = assert[k];
                return;
            }
            if (ndebug) {
                out[k] = noop;
                return;
            }
            out[k] = assert[k];
        });
    
        /* export ourselves (for unit tests _only_) */
        out._setExports = _setExports;
    
        return out;
    }
    
    module.exports = _setExports(process.env.NODE_NDEBUG);
    
    
    /***/ }),
    /* 91 */
    /***/ ((module) => {
    
    "use strict";
    module.exports = require("assert");
    
    /***/ }),
    /* 92 */
    /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
    
    // Copyright 2012 Joyent, Inc.  All rights reserved.
    
    var assert = __webpack_require__(90);
    var sshpk = __webpack_require__(93);
    var util = __webpack_require__(64);
    
    var HASH_ALGOS = {
      'sha1': true,
      'sha256': true,
      'sha512': true
    };
    
    var PK_ALGOS = {
      'rsa': true,
      'dsa': true,
      'ecdsa': true
    };
    
    function HttpSignatureError(message, caller) {
      if (Error.captureStackTrace)
        Error.captureStackTrace(this, caller || HttpSignatureError);
    
      this.message = message;
      this.name = caller.name;
    }
    util.inherits(HttpSignatureError, Error);
    
    function InvalidAlgorithmError(message) {
      HttpSignatureError.call(this, message, InvalidAlgorithmError);
    }
    util.inherits(InvalidAlgorithmError, HttpSignatureError);
    
    function validateAlgorithm(algorithm) {
      var alg = algorithm.toLowerCase().split('-');
    
      if (alg.length !== 2) {
        throw (new InvalidAlgorithmError(alg[0].toUpperCase() + ' is not a ' +
          'valid algorithm'));
      }
    
      if (alg[0] !== 'hmac' && !PK_ALGOS[alg[0]]) {
        throw (new InvalidAlgorithmError(alg[0].toUpperCase() + ' type keys ' +
          'are not supported'));
      }
    
      if (!HASH_ALGOS[alg[1]]) {
        throw (new InvalidAlgorithmError(alg[1].toUpperCase() + ' is not a ' +
          'supported hash algorithm'));
      }
    
      return (alg);
    }
    
    ///--- API
    
    module.exports = {
    
      HASH_ALGOS: HASH_ALGOS,
      PK_ALGOS: PK_ALGOS,
    
      HttpSignatureError: HttpSignatureError,
      InvalidAlgorithmError: InvalidAlgorithmError,
    
      validateAlgorithm: validateAlgorithm,
    
      /**
       * Converts an OpenSSH public key (rsa only) to a PKCS#8 PEM file.
       *
       * The intent of this module is to interoperate with OpenSSL only,
       * specifically the node crypto module's `verify` method.
       *
       * @param {String} key an OpenSSH public key.
       * @return {String} PEM encoded form of the RSA public key.
       * @throws {TypeError} on bad input.
       * @throws {Error} on invalid ssh key formatted data.
       */
      sshKeyToPEM: function sshKeyToPEM(key) {
        assert.string(key, 'ssh_key');
    
        var k = sshpk.parseKey(key, 'ssh');
        return (k.toString('pem'));
      },
    
    
      /**
       * Generates an OpenSSH fingerprint from an ssh public key.
       *
       * @param {String} key an OpenSSH public key.
       * @return {String} key fingerprint.
       * @throws {TypeError} on bad input.
       * @throws {Error} if what you passed doesn't look like an ssh public key.
       */
      fingerprint: function fingerprint(key) {
        assert.string(key, 'ssh_key');
    
        var k = sshpk.parseKey(key, 'ssh');
        return (k.fingerprint('md5').toString('hex'));
      },
    
      /**
       * Converts a PKGCS#8 PEM file to an OpenSSH public key (rsa)
       *
       * The reverse of the above function.
       */
      pemToRsaSSHKey: function pemToRsaSSHKey(pem, comment) {
        assert.equal('string', typeof (pem), 'typeof pem');
    
        var k = sshpk.parseKey(pem, 'pem');
        k.comment = comment;
        return (k.toString('ssh'));
      }
    };
    
    
    /***/ }),
    /* 93 */
    /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
    
    // Copyright 2015 Joyent, Inc.
    
    var Key = __webpack_require__(94);
    var Fingerprint = __webpack_require__(97);
    var Signature = __webpack_require__(100);
    var PrivateKey = __webpack_require__(99);
    var Certificate = __webpack_require__(126);
    var Identity = __webpack_require__(127);
    var errs = __webpack_require__(98);
    
    module.exports = {
    	/* top-level classes */
    	Key: Key,
    	parseKey: Key.parse,
    	Fingerprint: Fingerprint,
    	parseFingerprint: Fingerprint.parse,
    	Signature: Signature,
    	parseSignature: Signature.parse,
    	PrivateKey: PrivateKey,
    	parsePrivateKey: PrivateKey.parse,
    	generatePrivateKey: PrivateKey.generate,
    	Certificate: Certificate,
    	parseCertificate: Certificate.parse,
    	createSelfSignedCertificate: Certificate.createSelfSigned,
    	createCertificate: Certificate.create,
    	Identity: Identity,
    	identityFromDN: Identity.parseDN,
    	identityForHost: Identity.forHost,
    	identityForUser: Identity.forUser,
    	identityForEmail: Identity.forEmail,
    	identityFromArray: Identity.fromArray,
    
    	/* errors */
    	FingerprintFormatError: errs.FingerprintFormatError,
    	InvalidAlgorithmError: errs.InvalidAlgorithmError,
    	KeyParseError: errs.KeyParseError,
    	SignatureParseError: errs.SignatureParseError,
    	KeyEncryptedError: errs.KeyEncryptedError,
    	CertificateParseError: errs.CertificateParseError
    };
    
    
    /***/ }),
    /* 94 */
    /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
    
    // Copyright 2018 Joyent, Inc.
    
    module.exports = Key;
    
    var assert = __webpack_require__(90);
    var algs = __webpack_require__(95);
    var crypto = __webpack_require__(76);
    var Fingerprint = __webpack_require__(97);
    var Signature = __webpack_require__(100);
    var DiffieHellman = (__webpack_require__(112).DiffieHellman);
    var errs = __webpack_require__(98);
    var utils = __webpack_require__(101);
    var PrivateKey = __webpack_require__(99);
    var edCompat;
    
    try {
    	edCompat = __webpack_require__(115);
    } catch (e) {
    	/* Just continue through, and bail out if we try to use it. */
    }
    
    var InvalidAlgorithmError = errs.InvalidAlgorithmError;
    var KeyParseError = errs.KeyParseError;
    
    var formats = {};
    formats['auto'] = __webpack_require__(116);
    formats['pem'] = __webpack_require__(117);
    formats['pkcs1'] = __webpack_require__(118);
    formats['pkcs8'] = __webpack_require__(119);
    formats['rfc4253'] = __webpack_require__(121);
    formats['ssh'] = __webpack_require__(123);
    formats['ssh-private'] = __webpack_require__(120);
    formats['openssh'] = formats['ssh-private'];
    formats['dnssec'] = __webpack_require__(124);
    formats['putty'] = __webpack_require__(125);
    formats['ppk'] = formats['putty'];
    
    function Key(opts) {
    	assert.object(opts, 'options');
    	assert.arrayOfObject(opts.parts, 'options.parts');
    	assert.string(opts.type, 'options.type');
    	assert.optionalString(opts.comment, 'options.comment');
    
    	var algInfo = algs.info[opts.type];
    	if (typeof (algInfo) !== 'object')
    		throw (new InvalidAlgorithmError(opts.type));
    
    	var partLookup = {};
    	for (var i = 0; i < opts.parts.length; ++i) {
    		var part = opts.parts[i];
    		partLookup[part.name] = part;
    	}
    
    	this.type = opts.type;
    	this.parts = opts.parts;
    	this.part = partLookup;
    	this.comment = undefined;
    	this.source = opts.source;
    
    	/* for speeding up hashing/fingerprint operations */
    	this._rfc4253Cache = opts._rfc4253Cache;
    	this._hashCache = {};
    
    	var sz;
    	this.curve = undefined;
    	if (this.type === 'ecdsa') {
    		var curve = this.part.curve.data.toString();
    		this.curve = curve;
    		sz = algs.curves[curve].size;
    	} else if (this.type === 'ed25519' || this.type === 'curve25519') {
    		sz = 256;
    		this.curve = 'curve25519';
    	} else {
    		var szPart = this.part[algInfo.sizePart];
    		sz = szPart.data.length;
    		sz = sz * 8 - utils.countZeros(szPart.data);
    	}
    	this.size = sz;
    }
    
    Key.formats = formats;
    
    Key.prototype.toBuffer = function (format, options) {
    	if (format === undefined)
    		format = 'ssh';
    	assert.string(format, 'format');
    	assert.object(formats[format], 'formats[format]');
    	assert.optionalObject(options, 'options');
    
    	if (format === 'rfc4253') {
    		if (this._rfc4253Cache === undefined)
    			this._rfc4253Cache = formats['rfc4253'].write(this);
    		return (this._rfc4253Cache);
    	}
    
    	return (formats[format].write(this, options));
    };
    
    Key.prototype.toString = function (format, options) {
    	return (this.toBuffer(format, options).toString());
    };
    
    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));
    
    	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, 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, type),
    		algorithm: algo,
    		hashType: type
    	};
    	return (new Fingerprint(opts));
    };
    
    Key.prototype.defaultHashAlgorithm = function () {
    	var hashAlgo = 'sha1';
    	if (this.type === 'rsa')
    		hashAlgo = 'sha256';
    	if (this.type === 'dsa' && this.size > 1024)
    		hashAlgo = 'sha256';
    	if (this.type === 'ed25519')
    		hashAlgo = 'sha512';
    	if (this.type === 'ecdsa') {
    		if (this.size <= 256)
    			hashAlgo = 'sha256';
    		else if (this.size <= 384)
    			hashAlgo = 'sha384';
    		else
    			hashAlgo = 'sha512';
    	}
    	return (hashAlgo);
    };
    
    Key.prototype.createVerify = function (hashAlgo) {
    	if (hashAlgo === undefined)
    		hashAlgo = this.defaultHashAlgorithm();
    	assert.string(hashAlgo, 'hash algorithm');
    
    	/* ED25519 is not supported by OpenSSL, use a javascript impl. */
    	if (this.type === 'ed25519' && edCompat !== undefined)
    		return (new edCompat.Verifier(this, hashAlgo));
    	if (this.type === 'curve25519')
    		throw (new Error('Curve25519 keys are not suitable for ' +
    		    'signing or verification'));
    
    	var v, nm, err;
    	try {
    		nm = hashAlgo.toUpperCase();
    		v = crypto.createVerify(nm);
    	} catch (e) {
    		err = e;
    	}
    	if (v === undefined || (err instanceof Error &&
    	    err.message.match(/Unknown message digest/))) {
    		nm = 'RSA-';
    		nm += hashAlgo.toUpperCase();
    		v = crypto.createVerify(nm);
    	}
    	assert.ok(v, 'failed to create verifier');
    	var oldVerify = v.verify.bind(v);
    	var key = this.toBuffer('pkcs8');
    	var curve = this.curve;
    	var self = this;
    	v.verify = function (signature, fmt) {
    		if (Signature.isSignature(signature, [2, 0])) {
    			if (signature.type !== self.type)
    				return (false);
    			if (signature.hashAlgorithm &&
    			    signature.hashAlgorithm !== hashAlgo)
    				return (false);
    			if (signature.curve && self.type === 'ecdsa' &&
    			    signature.curve !== curve)
    				return (false);
    			return (oldVerify(key, signature.toBuffer('asn1')));
    
    		} else if (typeof (signature) === 'string' ||
    		    Buffer.isBuffer(signature)) {
    			return (oldVerify(key, signature, fmt));
    
    		/*
    		 * Avoid doing this on valid arguments, walking the prototype
    		 * chain can be quite slow.
    		 */
    		} else if (Signature.isSignature(signature, [1, 0])) {
    			throw (new Error('signature was created by too old ' +
    			    'a version of sshpk and cannot be verified'));
    
    		} else {
    			throw (new TypeError('signature must be a string, ' +
    			    'Buffer, or Signature object'));
    		}
    	};
    	return (v);
    };
    
    Key.prototype.createDiffieHellman = function () {
    	if (this.type === 'rsa')
    		throw (new Error('RSA keys do not support Diffie-Hellman'));
    
    	return (new DiffieHellman(this));
    };
    Key.prototype.createDH = Key.prototype.createDiffieHellman;
    
    Key.parse = function (data, format, options) {
    	if (typeof (data) !== 'string')
    		assert.buffer(data, 'data');
    	if (format === undefined)
    		format = 'auto';
    	assert.string(format, 'format');
    	if (typeof (options) === 'string')
    		options = { filename: options };
    	assert.optionalObject(options, 'options');
    	if (options === undefined)
    		options = {};
    	assert.optionalString(options.filename, 'options.filename');
    	if (options.filename === undefined)
    		options.filename = '(unnamed)';
    
    	assert.object(formats[format], 'formats[format]');
    
    	try {
    		var k = formats[format].read(data, options);
    		if (k instanceof PrivateKey)
    			k = k.toPublic();
    		if (!k.comment)
    			k.comment = options.filename;
    		return (k);
    	} catch (e) {
    		if (e.name === 'KeyEncryptedError')
    			throw (e);
    		throw (new KeyParseError(options.filename, format, e));
    	}
    };
    
    Key.isKey = function (obj, ver) {
    	return (utils.isCompatible(obj, Key, ver));
    };
    
    /*
     * API versions for Key:
     * [1,0] -- initial ver, may take Signature for createVerify or may not
     * [1,1] -- added pkcs1, pkcs8 formats
     * [1,2] -- added auto, ssh-private, openssh formats
     * [1,3] -- added defaultHashAlgorithm
     * [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, 7];
    
    Key._oldVersionDetect = function (obj) {
    	assert.func(obj.toBuffer);
    	assert.func(obj.fingerprint);
    	if (obj.createDH)
    		return ([1, 4]);
    	if (obj.defaultHashAlgorithm)
    		return ([1, 3]);
    	if (obj.formats['auto'])
    		return ([1, 2]);
    	if (obj.formats['pkcs1'])
    		return ([1, 1]);
    	return ([1, 0]);
    };
    
    
    /***/ }),
    /* 95 */
    /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
    
    // Copyright 2015 Joyent, Inc.
    
    var Buffer = (__webpack_require__(96).Buffer);
    
    var algInfo = {
    	'dsa': {
    		parts: ['p', 'q', 'g', 'y'],
    		sizePart: 'p'
    	},
    	'rsa': {
    		parts: ['e', 'n'],
    		sizePart: 'n'
    	},
    	'ecdsa': {
    		parts: ['curve', 'Q'],
    		sizePart: 'Q'
    	},
    	'ed25519': {
    		parts: ['A'],
    		sizePart: 'A'
    	}
    };
    algInfo['curve25519'] = algInfo['ed25519'];
    
    var algPrivInfo = {
    	'dsa': {
    		parts: ['p', 'q', 'g', 'y', 'x']
    	},
    	'rsa': {
    		parts: ['n', 'e', 'd', 'iqmp', 'p', 'q']
    	},
    	'ecdsa': {
    		parts: ['curve', 'Q', 'd']
    	},
    	'ed25519': {
    		parts: ['A', 'k']
    	}
    };
    algPrivInfo['curve25519'] = algPrivInfo['ed25519'];
    
    var hashAlgs = {
    	'md5': true,
    	'sha1': true,
    	'sha256': true,
    	'sha384': true,
    	'sha512': true
    };
    
    /*
     * Taken from
     * http://csrc.nist.gov/groups/ST/toolkit/documents/dss/NISTReCur.pdf
     */
    var curves = {
    	'nistp256': {
    		size: 256,
    		pkcs8oid: '1.2.840.10045.3.1.7',
    		p: Buffer.from(('00' +
    		    'ffffffff 00000001 00000000 00000000' +
    		    '00000000 ffffffff ffffffff ffffffff').
    		    replace(/ /g, ''), 'hex'),
    		a: Buffer.from(('00' +
    		    'FFFFFFFF 00000001 00000000 00000000' +
    		    '00000000 FFFFFFFF FFFFFFFF FFFFFFFC').
    		    replace(/ /g, ''), 'hex'),
    		b: Buffer.from((
    		    '5ac635d8 aa3a93e7 b3ebbd55 769886bc' +
    		    '651d06b0 cc53b0f6 3bce3c3e 27d2604b').
    		    replace(/ /g, ''), 'hex'),
    		s: Buffer.from(('00' +
    		    'c49d3608 86e70493 6a6678e1 139d26b7' +
    		    '819f7e90').
    		    replace(/ /g, ''), 'hex'),
    		n: Buffer.from(('00' +
    		    'ffffffff 00000000 ffffffff ffffffff' +
    		    'bce6faad a7179e84 f3b9cac2 fc632551').
    		    replace(/ /g, ''), 'hex'),
    		G: Buffer.from(('04' +
    		    '6b17d1f2 e12c4247 f8bce6e5 63a440f2' +
    		    '77037d81 2deb33a0 f4a13945 d898c296' +
    		    '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16' +
    		    '2bce3357 6b315ece cbb64068 37bf51f5').
    		    replace(/ /g, ''), 'hex')
    	},
    	'nistp384': {
    		size: 384,
    		pkcs8oid: '1.3.132.0.34',
    		p: Buffer.from(('00' +
    		    'ffffffff ffffffff ffffffff ffffffff' +
    		    'ffffffff ffffffff ffffffff fffffffe' +
    		    'ffffffff 00000000 00000000 ffffffff').
    		    replace(/ /g, ''), 'hex'),
    		a: Buffer.from(('00' +
    		    'FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF' +
    		    'FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE' +
    		    'FFFFFFFF 00000000 00000000 FFFFFFFC').
    		    replace(/ /g, ''), 'hex'),
    		b: Buffer.from((
    		    'b3312fa7 e23ee7e4 988e056b e3f82d19' +
    		    '181d9c6e fe814112 0314088f 5013875a' +
    		    'c656398d 8a2ed19d 2a85c8ed d3ec2aef').
    		    replace(/ /g, ''), 'hex'),
    		s: Buffer.from(('00' +
    		    'a335926a a319a27a 1d00896a 6773a482' +
    		    '7acdac73').
    		    replace(/ /g, ''), 'hex'),
    		n: Buffer.from(('00' +
    		    'ffffffff ffffffff ffffffff ffffffff' +
    		    'ffffffff ffffffff c7634d81 f4372ddf' +
    		    '581a0db2 48b0a77a ecec196a ccc52973').
    		    replace(/ /g, ''), 'hex'),
    		G: Buffer.from(('04' +
    		    'aa87ca22 be8b0537 8eb1c71e f320ad74' +
    		    '6e1d3b62 8ba79b98 59f741e0 82542a38' +
    		    '5502f25d bf55296c 3a545e38 72760ab7' +
    		    '3617de4a 96262c6f 5d9e98bf 9292dc29' +
    		    'f8f41dbd 289a147c e9da3113 b5f0b8c0' +
    		    '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f').
    		    replace(/ /g, ''), 'hex')
    	},
    	'nistp521': {
    		size: 521,
    		pkcs8oid: '1.3.132.0.35',
    		p: Buffer.from((
    		    '01ffffff ffffffff ffffffff ffffffff' +
    		    'ffffffff ffffffff ffffffff ffffffff' +
    		    'ffffffff ffffffff ffffffff ffffffff' +
    		    'ffffffff ffffffff ffffffff ffffffff' +
    		    'ffff').replace(/ /g, ''), 'hex'),
    		a: Buffer.from(('01FF' +
    		    'FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF' +
    		    'FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF' +
    		    'FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF' +
    		    'FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFC').
    		    replace(/ /g, ''), 'hex'),
    		b: Buffer.from(('51' +
    		    '953eb961 8e1c9a1f 929a21a0 b68540ee' +
    		    'a2da725b 99b315f3 b8b48991 8ef109e1' +
    		    '56193951 ec7e937b 1652c0bd 3bb1bf07' +
    		    '3573df88 3d2c34f1 ef451fd4 6b503f00').
    		    replace(/ /g, ''), 'hex'),
    		s: Buffer.from(('00' +
    		    'd09e8800 291cb853 96cc6717 393284aa' +
    		    'a0da64ba').replace(/ /g, ''), 'hex'),
    		n: Buffer.from(('01ff' +
    		    'ffffffff ffffffff ffffffff ffffffff' +
    		    'ffffffff ffffffff ffffffff fffffffa' +
    		    '51868783 bf2f966b 7fcc0148 f709a5d0' +
    		    '3bb5c9b8 899c47ae bb6fb71e 91386409').
    		    replace(/ /g, ''), 'hex'),
    		G: Buffer.from(('04' +
    		    '00c6 858e06b7 0404e9cd 9e3ecb66 2395b442' +
    		         '9c648139 053fb521 f828af60 6b4d3dba' +
    		         'a14b5e77 efe75928 fe1dc127 a2ffa8de' +
    		         '3348b3c1 856a429b f97e7e31 c2e5bd66' +
    		    '0118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9' +
    		         '98f54449 579b4468 17afbd17 273e662c' +
    		         '97ee7299 5ef42640 c550b901 3fad0761' +
    		         '353c7086 a272c240 88be9476 9fd16650').
    		    replace(/ /g, ''), 'hex')
    	}
    };
    
    module.exports = {
    	info: algInfo,
    	privInfo: algPrivInfo,
    	hashAlgs: hashAlgs,
    	curves: curves
    };
    
    
    /***/ }),
    /* 96 */
    /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
    
    "use strict";
    /* eslint-disable node/no-deprecated-api */
    
    
    
    var buffer = __webpack_require__(78)
    var Buffer = buffer.Buffer
    
    var safer = {}
    
    var key
    
    for (key in buffer) {
      if (!buffer.hasOwnProperty(key)) continue
      if (key === 'SlowBuffer' || key === 'Buffer') continue
      safer[key] = buffer[key]
    }
    
    var Safer = safer.Buffer = {}
    for (key in Buffer) {
      if (!Buffer.hasOwnProperty(key)) continue
      if (key === 'allocUnsafe' || key === 'allocUnsafeSlow') continue
      Safer[key] = Buffer[key]
    }
    
    safer.Buffer.prototype = Buffer.prototype
    
    if (!Safer.from || Safer.from === Uint8Array.from) {
      Safer.from = function (value, encodingOrOffset, length) {
        if (typeof value === 'number') {
          throw new TypeError('The "value" argument must not be of type number. Received type ' + typeof value)
        }
        if (value && typeof value.length === 'undefined') {
          throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type ' + typeof value)
        }
        return Buffer(value, encodingOrOffset, length)
      }
    }
    
    if (!Safer.alloc) {
      Safer.alloc = function (size, fill, encoding) {
        if (typeof size !== 'number') {
          throw new TypeError('The "size" argument must be of type number. Received type ' + typeof size)
        }