UNPKG

@syncfusion/ej2-pdf

Version:

Feature-rich JavaScript PDF library with built-in support for loading and manipulating PDF document.

116 lines (115 loc) 4.29 kB
import { _PdfCipherParameter } from '../x509/x509-cipher-handler'; import { _ICipherBlock } from './pdf-interfaces'; /** * Provides the internal RSA core operations, including modular exponentiation, * CRT optimization for private keys, and block size management. * * @private */ export declare class _PdfRsaCoreAlgorithm { private _key; private _isEncryption; private _bitSize; /** * Gets the maximum input block size in bytes based on the key size and operation mode. * * @private * @returns {number} The allowed input block size in bytes. */ _getInputBlockSize(): number; /** * Gets the maximum output block size in bytes based on the key size and operation mode. * * @private * @returns {number} The output block size in bytes. */ _getOutputBlockSize(): number; /** * Initializes the RSA core engine with the specified mode and key parameters. * * @private * @param {boolean} isEncryption Specifies whether to operate in encryption mode. * @param {_PdfCipherParameter} parameters The RSA key parameters to use. * @returns {void} nothing. */ _initialize(isEncryption: boolean, parameters: _PdfCipherParameter): void; /** * Converts a segment of bytes into a bigint suitable for RSA modular operations, * validating the block size and modulus constraints. * * @private * @param {Uint8Array} bytes The source byte array. * @param {number} offset The starting index within the array. * @param {number} length The number of bytes to read. * @returns {bigint} The bigint representation of the input block. */ _convertInput(bytes: Uint8Array, offset: number, length: number): bigint; /** * Converts a bigint result back into a byte array, padding as required for encryption output size. * * @private * @param {bigint} result The bigint value to convert. * @returns {Uint8Array} The converted byte array. */ _convertOutput(result: bigint): Uint8Array; /** * Processes a single RSA block using modular exponentiation. If a CRT private key is present, * uses the CRT optimization; otherwise, falls back to standard exponentiation. * * @private * @param {bigint} input The bigint block to process. * @returns {bigint} The processed bigint result. */ _processBlock(input: bigint): bigint; } /** * Provides the internal RSA block cipher wrapper built on top of the RSA core, * exposing block size and processing methods for encryption/decryption. * * @private */ export declare class _PdfRsaAlgorithm implements _ICipherBlock { private _rsaCoreEngine; private _key; /** * Gets the internal algorithm name. * * @private * @returns {string} The algorithm name, i.e., "RSA". */ _getAlgorithmName(): string; /** * Gets the maximum input block size in bytes for the current key and mode. * * @private * @returns {number} The input block size in bytes. */ _getInputBlock(): number; /** * Gets the maximum output block size in bytes for the current key and mode. * * @private * @returns {number} The output block size in bytes. */ _getOutputBlock(): number; /** * Initializes the RSA algorithm with the specified mode and parameters. * * @private * @param {boolean} isEncryption Specifies whether to operate in encryption mode. * @param {_PdfCipherParameter} parameter The RSA key parameters to use. * @returns {void} nothing. */ _initialize(isEncryption: boolean, parameter: _PdfCipherParameter): void; /** * Processes a single block of input using RSA. Applies blinding when a private key is used * and a public exponent is available to mitigate timing attacks. * * @private * @param {Uint8Array} bytes The input buffer containing the block data. * @param {number} offset The starting index of the block within the buffer. * @param {number} length The number of bytes to process from the buffer. * @returns {Uint8Array} The processed output block. */ _processBlock(bytes: Uint8Array, offset: number, length: number): Uint8Array; }