pub struct Rar5Crypto { /* private fields */ }Available on crate feature
crypto only.Expand description
RAR5 cryptographic operations.
Implementations§
Source§impl Rar5Crypto
impl Rar5Crypto
Sourcepub fn derive_key(password: &str, salt: &[u8; 16], lg2_count: u8) -> Self
pub fn derive_key(password: &str, salt: &[u8; 16], lg2_count: u8) -> Self
Derive key from password using PBKDF2-HMAC-SHA256.
RAR5 derives these values using PBKDF2-HMAC-SHA256:
- Key (32 bytes) - for AES-256 encryption (at
iterations) - Password check (32 bytes) - for password verification (at
iterations + 32)
Note: RAR5 spec also defines a hash key (at iterations + 16) for MAC
checksums, but this implementation does not compute it since we don’t
verify header MACs.
Sourcepub fn verify_password(&self, expected: &[u8; 8]) -> bool
pub fn verify_password(&self, expected: &[u8; 8]) -> bool
Verify password using the stored check value.
Sourcepub fn decrypt(&self, iv: &[u8; 16], data: &mut [u8]) -> Result<(), CryptoError>
pub fn decrypt(&self, iv: &[u8; 16], data: &mut [u8]) -> Result<(), CryptoError>
Decrypt data in-place using AES-256-CBC.
Sourcepub fn decrypt_to_vec(
&self,
iv: &[u8; 16],
data: &[u8],
) -> Result<Vec<u8>, CryptoError>
pub fn decrypt_to_vec( &self, iv: &[u8; 16], data: &[u8], ) -> Result<Vec<u8>, CryptoError>
Decrypt data to a new buffer.
Trait Implementations§
Source§impl Clone for Rar5Crypto
impl Clone for Rar5Crypto
Source§fn clone(&self) -> Rar5Crypto
fn clone(&self) -> Rar5Crypto
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Rar5Crypto
impl Debug for Rar5Crypto
Auto Trait Implementations§
impl Freeze for Rar5Crypto
impl RefUnwindSafe for Rar5Crypto
impl Send for Rar5Crypto
impl Sync for Rar5Crypto
impl Unpin for Rar5Crypto
impl UnsafeUnpin for Rar5Crypto
impl UnwindSafe for Rar5Crypto
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
Mutably borrows from an owned value. Read more