UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

31 lines (29 loc) 1.05 kB
/** * DevExtreme (cjs/__internal/core/license/pkcs1.js) * Version: 24.2.6 * Build date: Mon Mar 17 2025 * * Copyright (c) 2012 - 2025 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) }