pub struct StandardSecurityHandler {
pub revision: SecurityHandlerRevision,
pub key_length: usize,
}Expand description
Standard Security Handler
Fields§
§revision: SecurityHandlerRevisionRevision
key_length: usizeKey length in bytes
Implementations§
Source§impl StandardSecurityHandler
impl StandardSecurityHandler
Sourcepub fn rc4_128bit() -> Self
pub fn rc4_128bit() -> Self
Create handler for RC4 128-bit encryption
Sourcepub fn aes_256_r5() -> Self
pub fn aes_256_r5() -> Self
Create handler for AES-256 encryption (Revision 5)
Sourcepub fn aes_256_r6() -> Self
pub fn aes_256_r6() -> Self
Create handler for AES-256 encryption (Revision 6)
Sourcepub fn compute_owner_hash(
&self,
owner_password: &OwnerPassword,
user_password: &UserPassword,
) -> Vec<u8> ⓘ
pub fn compute_owner_hash( &self, owner_password: &OwnerPassword, user_password: &UserPassword, ) -> Vec<u8> ⓘ
Compute owner password hash (O entry)
Sourcepub fn compute_user_hash(
&self,
user_password: &UserPassword,
owner_hash: &[u8],
permissions: Permissions,
file_id: Option<&[u8]>,
) -> Result<Vec<u8>>
pub fn compute_user_hash( &self, user_password: &UserPassword, owner_hash: &[u8], permissions: Permissions, file_id: Option<&[u8]>, ) -> Result<Vec<u8>>
Compute user password hash (U entry)
Sourcepub fn compute_encryption_key(
&self,
user_password: &UserPassword,
owner_hash: &[u8],
permissions: Permissions,
file_id: Option<&[u8]>,
) -> Result<EncryptionKey>
pub fn compute_encryption_key( &self, user_password: &UserPassword, owner_hash: &[u8], permissions: Permissions, file_id: Option<&[u8]>, ) -> Result<EncryptionKey>
Compute encryption key from user password
Sourcepub fn encrypt_string(
&self,
data: &[u8],
key: &EncryptionKey,
obj_id: &ObjectId,
) -> Vec<u8> ⓘ
pub fn encrypt_string( &self, data: &[u8], key: &EncryptionKey, obj_id: &ObjectId, ) -> Vec<u8> ⓘ
Encrypt a string
Sourcepub fn decrypt_string(
&self,
data: &[u8],
key: &EncryptionKey,
obj_id: &ObjectId,
) -> Vec<u8> ⓘ
pub fn decrypt_string( &self, data: &[u8], key: &EncryptionKey, obj_id: &ObjectId, ) -> Vec<u8> ⓘ
Decrypt a string
Sourcepub fn encrypt_stream(
&self,
data: &[u8],
key: &EncryptionKey,
obj_id: &ObjectId,
) -> Vec<u8> ⓘ
pub fn encrypt_stream( &self, data: &[u8], key: &EncryptionKey, obj_id: &ObjectId, ) -> Vec<u8> ⓘ
Encrypt a stream
Sourcepub fn decrypt_stream(
&self,
data: &[u8],
key: &EncryptionKey,
obj_id: &ObjectId,
) -> Vec<u8> ⓘ
pub fn decrypt_stream( &self, data: &[u8], key: &EncryptionKey, obj_id: &ObjectId, ) -> Vec<u8> ⓘ
Decrypt a stream
Sourcepub fn encrypt_aes(
&self,
data: &[u8],
key: &EncryptionKey,
obj_id: &ObjectId,
) -> Result<Vec<u8>>
pub fn encrypt_aes( &self, data: &[u8], key: &EncryptionKey, obj_id: &ObjectId, ) -> Result<Vec<u8>>
Encrypt data using AES (for Rev 5/6)
Sourcepub fn decrypt_aes(
&self,
data: &[u8],
key: &EncryptionKey,
obj_id: &ObjectId,
) -> Result<Vec<u8>>
pub fn decrypt_aes( &self, data: &[u8], key: &EncryptionKey, obj_id: &ObjectId, ) -> Result<Vec<u8>>
Decrypt data using AES (for Rev 5/6)
Sourcepub fn compute_aes_encryption_key(
&self,
user_password: &UserPassword,
owner_hash: &[u8],
permissions: Permissions,
file_id: Option<&[u8]>,
) -> Result<EncryptionKey>
pub fn compute_aes_encryption_key( &self, user_password: &UserPassword, owner_hash: &[u8], permissions: Permissions, file_id: Option<&[u8]>, ) -> Result<EncryptionKey>
Compute encryption key for AES Rev 5/6
Sourcepub fn validate_aes_user_password(
&self,
password: &UserPassword,
user_hash: &[u8],
permissions: Permissions,
file_id: Option<&[u8]>,
) -> Result<bool>
pub fn validate_aes_user_password( &self, password: &UserPassword, user_hash: &[u8], permissions: Permissions, file_id: Option<&[u8]>, ) -> Result<bool>
Validate user password for AES Rev 5/6
Sourcepub fn compute_object_key(
&self,
key: &EncryptionKey,
obj_id: &ObjectId,
) -> Vec<u8> ⓘ
pub fn compute_object_key( &self, key: &EncryptionKey, obj_id: &ObjectId, ) -> Vec<u8> ⓘ
Compute object-specific encryption key (Algorithm 1, ISO 32000-1 §7.6.2)
Sourcepub fn validate_user_password(
&self,
password: &UserPassword,
user_hash: &[u8],
owner_hash: &[u8],
permissions: Permissions,
file_id: Option<&[u8]>,
) -> Result<bool>
pub fn validate_user_password( &self, password: &UserPassword, user_hash: &[u8], owner_hash: &[u8], permissions: Permissions, file_id: Option<&[u8]>, ) -> Result<bool>
Validate user password (Algorithm 6, ISO 32000-1 §7.6.3.4)
Returns Ok(true) if password is correct, Ok(false) if incorrect. Returns Err only on internal errors.
Sourcepub fn validate_owner_password(
&self,
owner_password: &OwnerPassword,
owner_hash: &[u8],
_user_password: &UserPassword,
_permissions: Permissions,
_file_id: Option<&[u8]>,
) -> Result<bool>
pub fn validate_owner_password( &self, owner_password: &OwnerPassword, owner_hash: &[u8], _user_password: &UserPassword, _permissions: Permissions, _file_id: Option<&[u8]>, ) -> Result<bool>
Validate owner password (Algorithm 7, ISO 32000-1 §7.6.3.4)
Returns Ok(true) if password is correct, Ok(false) if incorrect. Returns Err only on internal errors.
Note: For owner password validation, we first decrypt the user password from the owner hash, then validate that user password.
Trait Implementations§
Source§impl SecurityHandler for StandardSecurityHandler
Standard Security Handler implementation
impl SecurityHandler for StandardSecurityHandler
Standard Security Handler implementation
Source§fn encrypt_string(
&self,
data: &[u8],
key: &EncryptionKey,
obj_id: &ObjectId,
) -> Result<Vec<u8>>
fn encrypt_string( &self, data: &[u8], key: &EncryptionKey, obj_id: &ObjectId, ) -> Result<Vec<u8>>
Source§fn decrypt_string(
&self,
data: &[u8],
key: &EncryptionKey,
obj_id: &ObjectId,
) -> Result<Vec<u8>>
fn decrypt_string( &self, data: &[u8], key: &EncryptionKey, obj_id: &ObjectId, ) -> Result<Vec<u8>>
Source§fn encrypt_stream(
&self,
data: &[u8],
key: &EncryptionKey,
obj_id: &ObjectId,
) -> Result<Vec<u8>>
fn encrypt_stream( &self, data: &[u8], key: &EncryptionKey, obj_id: &ObjectId, ) -> Result<Vec<u8>>
Source§fn decrypt_stream(
&self,
data: &[u8],
key: &EncryptionKey,
obj_id: &ObjectId,
) -> Result<Vec<u8>>
fn decrypt_stream( &self, data: &[u8], key: &EncryptionKey, obj_id: &ObjectId, ) -> Result<Vec<u8>>
Source§fn encrypt_string_aes(
&self,
data: &[u8],
key: &EncryptionKey,
obj_id: &ObjectId,
bits: u32,
) -> Result<Vec<u8>>
fn encrypt_string_aes( &self, data: &[u8], key: &EncryptionKey, obj_id: &ObjectId, bits: u32, ) -> Result<Vec<u8>>
Source§fn decrypt_string_aes(
&self,
data: &[u8],
key: &EncryptionKey,
obj_id: &ObjectId,
bits: u32,
) -> Result<Vec<u8>>
fn decrypt_string_aes( &self, data: &[u8], key: &EncryptionKey, obj_id: &ObjectId, bits: u32, ) -> Result<Vec<u8>>
Source§fn encrypt_stream_aes(
&self,
data: &[u8],
key: &EncryptionKey,
obj_id: &ObjectId,
bits: u32,
) -> Result<Vec<u8>>
fn encrypt_stream_aes( &self, data: &[u8], key: &EncryptionKey, obj_id: &ObjectId, bits: u32, ) -> Result<Vec<u8>>
Source§fn decrypt_stream_aes(
&self,
data: &[u8],
key: &EncryptionKey,
obj_id: &ObjectId,
bits: u32,
) -> Result<Vec<u8>>
fn decrypt_stream_aes( &self, data: &[u8], key: &EncryptionKey, obj_id: &ObjectId, bits: u32, ) -> Result<Vec<u8>>
Auto Trait Implementations§
impl Freeze for StandardSecurityHandler
impl RefUnwindSafe for StandardSecurityHandler
impl Send for StandardSecurityHandler
impl Sync for StandardSecurityHandler
impl Unpin for StandardSecurityHandler
impl UnwindSafe for StandardSecurityHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more