/**
 * DevExtreme (cjs/__internal/core/license/pkcs1.js)
 * Version: 23.2.6 (build 24140-0112)
 * Build date: Sun May 19 2024
 *
 * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.pad = pad;
var _byte_utils = require("./byte_utils");
var _key = require("./key");
const ASN1_SHA1 = "3021300906052b0e03021a05000414";

function pad(hash) {
    const dataLength = (8 * _key.PUBLIC_KEY.n.length + 6) / 8;
    const data = (0, _byte_utils.concatBytes)((0, _byte_utils.hexToBytes)(ASN1_SHA1), hash);
    if (data.length + 10 > dataLength) {
        throw Error("Key is too short for SHA1 signing algorithm")
    }
    const padding = new Uint8Array(dataLength - data.length);
    padding.fill(255, 0, padding.length - 1);
    padding[0] = 0;
    padding[1] = 1;
    padding[padding.length - 1] = 0;
    return (0, _byte_utils.concatBytes)(padding, data)
}
