UNPKG

@microsoft/dev-tunnels-ssh

Version:
33 lines 1.32 kB
"use strict"; // // Copyright (c) Microsoft Corporation. All rights reserved. // Object.defineProperty(exports, "__esModule", { value: true }); exports.PublicKeyAlgorithm = void 0; const buffer_1 = require("buffer"); const sshData_1 = require("../io/sshData"); class PublicKeyAlgorithm { constructor(name, keyAlgorithmName, hashAlgorithmName) { this.name = name; this.keyAlgorithmName = keyAlgorithmName; this.hashAlgorithmName = hashAlgorithmName; } readSignatureData(signatureData) { const reader = new sshData_1.SshDataReader(signatureData); const algorithmName = reader.readString('ascii'); if (algorithmName !== this.name) { throw new Error('Mismatched public key algorithm: ' + `got '${algorithmName}', expected '${this.name}'.`); } const signature = reader.readBinary(); return signature; } createSignatureData(signature) { const writer = new sshData_1.SshDataWriter(buffer_1.Buffer.alloc(this.name.length + signature.length + 20)); writer.writeString(this.name, 'ascii'); writer.writeBinary(signature); return writer.toBuffer(); } } exports.PublicKeyAlgorithm = PublicKeyAlgorithm; //# sourceMappingURL=publicKeyAlgorithm.js.map