pub struct SecurityHandler { /* private fields */ }Expand description
A security handler, authenticated and ready to decrypt.
Implementations§
Source§impl SecurityHandler
impl SecurityHandler
Sourcepub fn new(
encrypt: &Dict,
id0: &[u8],
password: &[u8],
) -> Result<SecurityHandler, Error>
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.
Sourcepub fn permissions(&self) -> u32
pub fn permissions(&self) -> u32
The /P permission bits.
Sourcepub fn is_authenticated(&self) -> bool
pub fn is_authenticated(&self) -> bool
Whether a password matched, so every class of data can be decrypted.
Sourcepub fn authentication(&self) -> Authentication
pub fn authentication(&self) -> Authentication
Which password authenticated.
Sourcepub fn encrypt_metadata(&self) -> bool
pub fn encrypt_metadata(&self) -> bool
Whether metadata streams are encrypted.
Sourcepub fn string_method(&self) -> CryptMethod
pub fn string_method(&self) -> CryptMethod
The method for strings.
Sourcepub fn stream_method(&self) -> CryptMethod
pub fn stream_method(&self) -> CryptMethod
The method for streams.
Sourcepub fn embedded_file_method(&self) -> CryptMethod
pub fn embedded_file_method(&self) -> CryptMethod
The method for embedded file streams.
Sourcepub fn decrypt(&self, id: ObjId, method: CryptMethod, data: &[u8]) -> Vec<u8> ⓘ
pub fn decrypt(&self, id: ObjId, method: CryptMethod, data: &[u8]) -> Vec<u8> ⓘ
Decrypts data belonging to object id with method.
Sourcepub fn decrypt_strings(&self, id: ObjId, object: &mut Object)
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
impl SecurityHandler
Sourcepub fn new_aes256(
user_password: &[u8],
owner_password: &[u8],
permissions: Permissions,
encrypt_metadata: bool,
entropy: &dyn Entropy,
) -> (SecurityHandler, Dict)
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).
Sourcepub fn can_encrypt(&self) -> bool
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.
Sourcepub fn encrypt(
&self,
method: CryptMethod,
data: &[u8],
entropy: &dyn Entropy,
) -> Result<Vec<u8>, Error>
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).
Sourcepub fn encrypt_strings(
&self,
object: &mut Object,
entropy: &dyn Entropy,
) -> Result<(), Error>
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
impl Clone for SecurityHandler
Source§fn clone(&self) -> SecurityHandler
fn clone(&self) -> SecurityHandler
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more