"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=https://github.com/VSCodium/sourcemaps/releases/download/stable-4c0b0c6cc561d2d3636d1ec250935431876ce4dc/node_modules-@microsoft-dev-tunnels-ssh-algorithms-publicKeyAlgorithm.js.map