Public-Key Encrypted Document Reload

Documents encrypted with the public-key security handler (/Filter /Adobe.PPKLite or /Adobe.PubSec, /SubFilter adbe.pkcs7.s4/s5) now load when the caller supplies the recipient private key

Key material

Assign THotPDF.PubSecKeyMaterial (a THPDFPFXKeyMaterial from HPDFParsePFX) before calling LoadFromFile. During the bounded-range prescan the file key is recovered: every /Recipients envelope is unwrapped with the RSA-OAEP private key (seed and permissions recovered from the CMS EnvelopedData), and the file key is re-derived exactly like the writer does - SHA-256 of seed plus envelopes for AES-256, SHA-1 for the legacy key lengths

Recipient selection

PubSecRecipientQuery (a reference to function(Context: Pointer; RecipientCount: Integer): Integer) selects which envelope index the supplied key unwraps; without a callback every recipient is tried until one unwraps. PubSecRecipientQueryContext carries the caller state

Writer fixes

Round-tripping exposed three writer defects, all fixed: recipient envelopes were corrupted by a binary-through-Unicode string round-trip, the file-key digest hashed envelope bytes with a one-byte offset, and /Recipients strings were encrypted like ordinary strings (every viewer needs them plaintext); envelopes now opt out through an explicit SkipEncryption flag on the string object