/** * PDF encryption support (Standard Security Handler, V=5, R=5). * * Implements AES-256 encryption compatible with PDF 2.0 (ISO 32000-2:2020). * Supports: * - User password (required to open the document) * - Owner password (grants full access) * - Permission flags (print, copy, modify, etc.) * * The file encryption key (FEK) is a random 256-bit key. * All streams and strings are encrypted using AES-256-CBC with a random * 16-byte IV prepended to each encrypted value. * * @see ISO 32000-2:2020, §7.6 — Encryption */ /** * PDF encryption options. */ export interface PdfEncryptionOptions { /** User password (required to open the document). Empty string = no open password. */ userPassword?: string; /** Owner password (grants full permissions). Required. */ ownerPassword: string; /** Permissions to grant when opened with user password. */ permissions?: Partial; } /** * PDF document permissions (what a user-password holder can do). * All default to false. */ export interface PdfPermissions { /** Allow printing */ print: boolean; /** Allow modifying content */ modify: boolean; /** Allow copying text/images */ copy: boolean; /** Allow adding/modifying annotations */ annotate: boolean; /** Allow filling form fields */ fillForms: boolean; /** Allow extracting content for accessibility */ accessibility: boolean; /** Allow assembling (insert/rotate/delete pages) */ assemble: boolean; /** Allow high-quality printing */ printHighQuality: boolean; } /** * Encryption state used during PDF generation (V=5, R=5, AES-256). */ export interface EncryptionState { /** 32-byte file encryption key */ encryptionKey: Uint8Array; /** 48-byte O value: hash(32) + validation salt(8) + key salt(8) */ oValue: Uint8Array; /** 48-byte U value: hash(32) + validation salt(8) + key salt(8) */ uValue: Uint8Array; /** 32-byte encrypted owner key (OE) */ oeValue: Uint8Array; /** 32-byte encrypted user key (UE) */ ueValue: Uint8Array; /** 16-byte encrypted permissions (Perms) */ permsValue: Uint8Array; /** Permissions integer (P value) */ permissions: number; /** File identifier (16 bytes) */ fileId: Uint8Array; } /** * Initialize encryption state for AES-256 (V=5, R=5). */ export declare function initEncryption(options: PdfEncryptionOptions): EncryptionState; /** * Encrypt data for a PDF object using AES-256-CBC. * * For V=5/R=5, the file encryption key is used directly (no per-object key derivation). * A random 16-byte IV is prepended to the ciphertext. */ export declare function encryptData(data: Uint8Array, _objectNumber: number, _generation: number, encryptionKey: Uint8Array): Uint8Array;