pub struct Rar4Crypto { /* private fields */ }Available on crate feature
crypto only.Expand description
RAR 3.x/4.x crypto handler.
Implementations§
Source§impl Rar4Crypto
impl Rar4Crypto
Sourcepub fn derive_key(password: &str, salt: &[u8; 8]) -> Self
pub fn derive_key(password: &str, salt: &[u8; 8]) -> Self
Derive key and IV from password and salt.
The RAR4 KDF uses 2^18 iterations of SHA-1:
- Password is encoded as UTF-16LE, concatenated with salt as seed
- Each iteration:
SHA1.update(seed + counter[0..3]) - Counter is a 3-byte little-endian integer
- Every 16384 (0x4000) iterations at j=0, extract byte 19 of digest as IV byte
- Final SHA-1 digest (first 16 bytes) is the AES-128 key (with endian swap)
Sourcepub fn decrypt(&self, data: &mut [u8]) -> Result<(), CryptoError>
pub fn decrypt(&self, data: &mut [u8]) -> Result<(), CryptoError>
Decrypt data in place using AES-128-CBC (using first 16 bytes of key).
Sourcepub fn decrypt_to_vec(&self, data: &[u8]) -> Result<Vec<u8>, CryptoError>
pub fn decrypt_to_vec(&self, data: &[u8]) -> Result<Vec<u8>, CryptoError>
Decrypt data returning a new Vec.
Trait Implementations§
Source§impl Clone for Rar4Crypto
impl Clone for Rar4Crypto
Source§fn clone(&self) -> Rar4Crypto
fn clone(&self) -> Rar4Crypto
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 Rar4Crypto
impl Debug for Rar4Crypto
Auto Trait Implementations§
impl Freeze for Rar4Crypto
impl RefUnwindSafe for Rar4Crypto
impl Send for Rar4Crypto
impl Sync for Rar4Crypto
impl Unpin for Rar4Crypto
impl UnsafeUnpin for Rar4Crypto
impl UnwindSafe for Rar4Crypto
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