@microsoft/dev-tunnels-ssh
Version:
SSH library for Dev Tunnels
84 lines • 4.61 kB
JavaScript
;
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
Object.defineProperty(exports, "__esModule", { value: true });
exports.algorithmNames = exports.SshAlgorithms = exports.Encryption = exports.ECDsa = exports.Rsa = exports.HmacAlgorithm = exports.EncryptionAlgorithm = exports.PublicKeyAlgorithm = exports.KeyExchangeAlgorithm = void 0;
const keyExchangeAlgorithm_1 = require("./keyExchangeAlgorithm");
Object.defineProperty(exports, "KeyExchangeAlgorithm", { enumerable: true, get: function () { return keyExchangeAlgorithm_1.KeyExchangeAlgorithm; } });
const publicKeyAlgorithm_1 = require("./publicKeyAlgorithm");
Object.defineProperty(exports, "PublicKeyAlgorithm", { enumerable: true, get: function () { return publicKeyAlgorithm_1.PublicKeyAlgorithm; } });
const encryptionAlgorithm_1 = require("./encryptionAlgorithm");
Object.defineProperty(exports, "EncryptionAlgorithm", { enumerable: true, get: function () { return encryptionAlgorithm_1.EncryptionAlgorithm; } });
const hmacAlgorithm_1 = require("./hmacAlgorithm");
Object.defineProperty(exports, "HmacAlgorithm", { enumerable: true, get: function () { return hmacAlgorithm_1.HmacAlgorithm; } });
// Swap imports to node crypto implementations when web crypto is not available.
// The 'self' variable is defined in browser environments (including web workers)
// but not in Node.js (or Node.js web workers).
// https://developer.mozilla.org/en-US/docs/Web/API/Window/self
const useWebCrypto = typeof self === 'object' && !!(typeof crypto === 'object' && crypto.subtle);
const webKeyExchange_1 = require("./web/webKeyExchange");
const webRsa_1 = require("./web/webRsa");
const webECDsa_1 = require("./web/webECDsa");
const webEncryption_1 = require("./web/webEncryption");
const webHmac_1 = require("./web/webHmac");
const webRandom_1 = require("./web/webRandom");
/* eslint-disable @typescript-eslint/naming-convention, id-match */
const DiffieHellman = useWebCrypto
? webKeyExchange_1.WebDiffieHellman
: require('./node/nodeKeyExchange').NodeDiffieHellman;
const ECDiffieHellman = useWebCrypto
? webKeyExchange_1.WebECDiffieHellman
: require('./node/nodeKeyExchange').NodeECDiffieHellman;
const Rsa = useWebCrypto ? webRsa_1.WebRsa : require('./node/nodeRsa').NodeRsa;
exports.Rsa = Rsa;
const ECDsa = useWebCrypto ? webECDsa_1.WebECDsa : require('./node/nodeECDsa').NodeECDsa;
exports.ECDsa = ECDsa;
const Encryption = useWebCrypto
? webEncryption_1.WebEncryption
: require('./node/nodeEncryption').NodeEncryption;
exports.Encryption = Encryption;
const Hmac = useWebCrypto ? webHmac_1.WebHmac : require('./node/nodeHmac').NodeHmac;
// eslint-disable-next-line no-redeclare
const Random = useWebCrypto ? webRandom_1.WebRandom : require('./node/nodeRandom').NodeRandom;
class SshAlgorithms {
}
exports.SshAlgorithms = SshAlgorithms;
SshAlgorithms.keyExchange = {
none: null,
dhGroup14Sha256: new DiffieHellman('diffie-hellman-group14-sha256', 2048, 'SHA2-256'),
dhGroup16Sha512: new DiffieHellman('diffie-hellman-group16-sha512', 4096, 'SHA2-512'),
ecdhNistp256Sha256: new ECDiffieHellman('ecdh-sha2-nistp256', 256, 'SHA2-256'),
ecdhNistp384Sha384: new ECDiffieHellman('ecdh-sha2-nistp384', 384, 'SHA2-384'),
ecdhNistp521Sha512: new ECDiffieHellman('ecdh-sha2-nistp521', 521, 'SHA2-512'),
};
SshAlgorithms.publicKey = {
none: null,
rsaWithSha256: new Rsa('rsa-sha2-256', 'SHA2-256'),
rsaWithSha512: new Rsa('rsa-sha2-512', 'SHA2-512'),
ecdsaSha2Nistp256: new ECDsa('ecdsa-sha2-nistp256', 'SHA2-256'),
ecdsaSha2Nistp384: new ECDsa('ecdsa-sha2-nistp384', 'SHA2-384'),
ecdsaSha2Nistp521: new ECDsa('ecdsa-sha2-nistp521', 'SHA2-512'),
};
SshAlgorithms.encryption = {
none: null,
////aes256Cbc: new Encryption('aes256-cbc', 'AES', 'CBC', 256) },
aes256Ctr: new Encryption('aes256-ctr', 'AES', 'CTR', 256),
aes256Gcm: new Encryption('aes256-gcm@openssh.com', 'AES', 'GCM', 256),
};
SshAlgorithms.hmac = {
none: null,
hmacSha256: new Hmac('hmac-sha2-256', 'SHA2-256'),
hmacSha512: new Hmac('hmac-sha2-512', 'SHA2-512'),
hmacSha256Etm: new Hmac('hmac-sha2-256-etm@openssh.com', 'SHA2-256', true),
hmacSha512Etm: new Hmac('hmac-sha2-512-etm@openssh.com', 'SHA2-512', true),
};
SshAlgorithms.compression = {
none: null,
};
SshAlgorithms.random = new Random();
function algorithmNames(list) {
return list.map((a) => (a ? a.name : 'none'));
}
exports.algorithmNames = algorithmNames;
//# sourceMappingURL=sshAlgorithms.js.map