pub struct StandardHandler {
pub key: Vec<u8>,
pub method: CryptMethod,
pub revision: u8,
}Expand description
File-level encryption parameters resolved from the trailer’s
/Encrypt dictionary. Carries the master key (Algorithm 2 output)
plus the per-object cipher selection.
Fields§
§key: Vec<u8>File encryption key — n bytes, where n ∈ {5, 16}.
method: CryptMethodDefault crypt method for streams + strings.
revision: u8Revision (2..=4 supported).
Implementations§
Source§impl StandardHandler
impl StandardHandler
Sourcepub fn decrypt_object(
&self,
id: ObjectId,
data: &[u8],
) -> Result<Vec<u8>, PdfError>
pub fn decrypt_object( &self, id: ObjectId, data: &[u8], ) -> Result<Vec<u8>, PdfError>
Decrypt the data of an indirect object whose id is id and
whose payload is data (a string body or stream body, after
any /Filter decoding). Returns the cleartext bytes.
AESV3 (R=5 / R=6) intentionally ignores id: ISO 32000-2:2020
§7.6.3.1 specifies that for V=5 the file encryption key is fed
to AES-256 directly, with no per-object derivation.
Sourcepub fn encrypt_object(
&self,
id: ObjectId,
data: &[u8],
iv: &[u8; 16],
) -> Result<Vec<u8>, PdfError>
pub fn encrypt_object( &self, id: ObjectId, data: &[u8], iv: &[u8; 16], ) -> Result<Vec<u8>, PdfError>
Encrypt the cleartext payload of an indirect object — the inverse
of Self::decrypt_object used by the writer to populate /Encrypt-
protected strings + streams. RC4 is symmetric (so this re-uses
rc4); AES uses a fresh IV which must be embedded as the
leading 16 bytes of the ciphertext per §7.6.2.
iv (only consulted for Aes128 / Aes256) lets fixture builders
pin the IV for byte-for-byte deterministic outputs. Production
callers pass a per-call-randomised IV.
Trait Implementations§
Source§impl Clone for StandardHandler
impl Clone for StandardHandler
Source§fn clone(&self) -> StandardHandler
fn clone(&self) -> StandardHandler
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more