import { ByteArray } from '../../types.js'; import { PdfEncryptionDictionary } from '../types.js'; import { PdfV4SecurityHandler } from './v4.js'; import { PdfStandardSecurityHandlerOptions } from './base.js'; import { Cipher } from '../../crypto/types.js'; /** * V5 security handler implementing AES-256-CBC encryption. * This is the most secure encryption method (PDF 2.0). * * @example * ```typescript * const handler = new PdfV5SecurityHandler({ * password: 'strongPassword123', * ownerPassword: 'adminPassword456' * }) * ``` */ export declare class PdfV5SecurityHandler extends PdfV4SecurityHandler { /** User encrypted file key (UE value). */ protected userEncryptedFileKey?: ByteArray; /** Owner encrypted file key (OE value). */ protected ownerEncryptedFileKey?: ByteArray; /** Permissions entry (Perms value). */ protected perms?: ByteArray; /** Promise resolving to the file encryption key. */ protected fileKey?: Promise; /** * Creates a new V5 security handler with AES-256 encryption. * * @param options - Configuration options including optional pre-computed keys. */ constructor(options: PdfStandardSecurityHandlerOptions & { userEncryptedFileKey?: ByteArray; ownerEncryptedFileKey?: ByteArray; }); /** * Checks if the handler is ready (has user encrypted file key). * * @returns True if the handler has the required keys. */ isReady(): boolean; /** * Initializes encryption keys, either deriving from existing values or generating new ones. */ protected initKeys(): Promise; /** * Computes the master encryption key. * * @returns The file encryption key. * @throws Error if file key is not initialized. */ protected computeMasterKey(): Promise; /** * Builds the Perms entry for the encryption dictionary. * * @param flags - The permission flags. * @param encryptMetadata - Whether metadata is encrypted. * @param fileKey - The file encryption key. * @returns The encrypted permissions entry. */ private buildPermsEntry; /** * Gets the encryption key length in bits. * * @returns 256 for V5 encryption. */ getKeyBits(): number; /** * Gets an AES-256 cipher. * * @returns An AES-256 cipher instance. */ protected getCipher(): Promise; /** * Gets the encryption version number. * * @returns 5 for AES-256 encryption. */ getVersion(): number; /** * Gets the encryption revision number. * * @returns 6 for V5 encryption. */ getRevision(): number; /** * Writes the encryption dictionary including V5-specific entries. * * @throws Error if required keys are not computed. */ write(): Promise; /** * Reads V5-specific encryption parameters from the dictionary. * * @param encryptionDictionary - The encryption dictionary from the PDF. * @throws Error if required entries are missing or invalid. */ readEncryptionDictionary(encryptionDictionary: PdfEncryptionDictionary): void; /** * Computes the object encryption key (same as master key for V5). * * @returns The master encryption key. */ computeObjectKey(): Promise; /** * Recovers the user password from the owner password. * Not supported for AES-256 encryption. * * @throws Error always, as this operation is not supported for V5. */ recoverUserPassword(ownerPassword?: ByteArray | string): Promise; }