Skip to main content

Encryptor

Struct Encryptor 

Source
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

Source

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).

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.