Skip to main content

SecurityHandler

Struct SecurityHandler 

Source
pub struct SecurityHandler { /* private fields */ }
Expand description

A security handler, authenticated and ready to decrypt.

Implementations§

Source§

impl SecurityHandler

Source

pub fn new( encrypt: &Dict, id0: &[u8], password: &[u8], ) -> Result<SecurityHandler, Error>

Authenticates against /Encrypt with password, trying it as the user password and then as the owner password. id0 is the first element of the trailer’s /ID.

Source

pub fn permissions(&self) -> u32

The /P permission bits.

Source

pub fn is_authenticated(&self) -> bool

Whether a password matched, so every class of data can be decrypted.

Source

pub fn authentication(&self) -> Authentication

Which password authenticated.

Source

pub fn revision(&self) -> i64

The security handler revision (/R).

Source

pub fn encrypt_metadata(&self) -> bool

Whether metadata streams are encrypted.

Source

pub fn string_method(&self) -> CryptMethod

The method for strings.

Source

pub fn stream_method(&self) -> CryptMethod

The method for streams.

Source

pub fn embedded_file_method(&self) -> CryptMethod

The method for embedded file streams.

Source

pub fn decrypt(&self, id: ObjId, method: CryptMethod, data: &[u8]) -> Vec<u8> ⓘ

Decrypts data belonging to object id with method.

Source

pub fn decrypt_strings(&self, id: ObjId, object: &mut Object)

Decrypts every string inside object (recursively), for object id. Streams’ data is left alone; see SecurityHandler::decrypt.

Source§

impl SecurityHandler

Source

pub fn new_aes256( user_password: &[u8], owner_password: &[u8], permissions: Permissions, encrypt_metadata: bool, entropy: &dyn Entropy, ) -> (SecurityHandler, Dict)

Creates a revision 6 (AES-256) handler for writing, and the /Encrypt dictionary that describes it (Algorithms 8, 9 and 10).

Source

pub fn can_encrypt(&self) -> bool

Whether this handler can encrypt new data: only AES-256 is ever written (D4); a file using RC4 or AES-128 must be re-encrypted by a full save instead.

Source

pub fn encrypt( &self, method: CryptMethod, data: &[u8], entropy: &dyn Entropy, ) -> Result<Vec<u8>, Error>

Encrypts data for object id with method (AES-256 or Identity).

Source

pub fn encrypt_strings( &self, object: &mut Object, entropy: &dyn Entropy, ) -> Result<(), Error>

Encrypts every string inside object in place (streams’ data is left to SecurityHandler::encrypt).

Trait Implementations§

Source§

impl Clone for SecurityHandler

Source§

fn clone(&self) -> SecurityHandler

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SecurityHandler

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.