pub struct Encryptor { /* private fields */ }Expand description
A configured Standard-handler encryptor: AES-256, revision 6, the write
side of Decryptor. Built by Encryptor::aes256 or
Encryptor::aes256_with_rng, which also return the complete
/Encrypt dictionary for the trailer.
Implementations§
Source§impl Encryptor
impl Encryptor
Sourcepub fn aes256(
user_password: &str,
owner_password: &str,
permissions: Permissions,
) -> (Encryptor, Dict)
pub fn aes256( user_password: &str, owner_password: &str, permissions: Permissions, ) -> (Encryptor, Dict)
AES-256 (/V 5, /R 6) key material from the operating system’s
random source (ISO 32000-2 §7.6.4.3). Returns the encryptor plus the
complete /Encrypt dictionary to place in the trailer. Passwords
encode as UTF-8 and are truncated to 127 bytes, matching the reader.
Not available on wasm32-unknown-unknown: there is no operating
system random source to draw from there. Use
Encryptor::aes256_with_rng instead, with caller-supplied
randomness (for example from the host’s crypto.getRandomValues).
Sourcepub fn aes256_with_rng(
user_password: &str,
owner_password: &str,
permissions: Permissions,
rng: Box<dyn FnMut(&mut [u8]) + Send>,
) -> (Encryptor, Dict)
pub fn aes256_with_rng( user_password: &str, owner_password: &str, permissions: Permissions, rng: Box<dyn FnMut(&mut [u8]) + Send>, ) -> (Encryptor, Dict)
Encryptor::aes256 with a caller-supplied source of random bytes
in place of the operating system’s, for reproducible tests.
Sourcepub fn encrypt_object(&mut self, obj: &mut Object, num: u32, gen: u16)
pub fn encrypt_object(&mut self, obj: &mut Object, num: u32, gen: u16)
Encrypts one indirect object’s strings and stream data in place, the
exact inverse of Decryptor::decrypt_object: every string and
stream body gets a fresh random IV and PKCS#7 padding before
AES-256-CBC under the file key. AESV3 applies the same key to every
object, so num and gen are accepted and ignored here, purely for
signature symmetry with decrypt_object; a future per-object write
cipher (an AESV2 write path, say) would need to start deriving its
key from them instead of discarding them.