Update aes and xts-mode

This commit is contained in:
Jeremy Soller
2025-07-02 12:48:39 -06:00
parent bd6efe0c83
commit dc25344b68
4 changed files with 35 additions and 22 deletions
+12 -2
View File
@@ -99,7 +99,12 @@ impl Header {
}
if let Some(cipher) = cipher_opt {
let mut block = aes::Block::from(encrypted_hash);
cipher.encrypt_area(&mut block, BLOCK_SIZE as usize, self.generation().into(), get_tweak_default);
cipher.encrypt_area(
&mut block,
BLOCK_SIZE as usize,
self.generation().into(),
get_tweak_default,
);
encrypted_hash = block.into();
}
encrypted_hash
@@ -115,7 +120,12 @@ impl Header {
//TODO: handle errors
let cipher = slot.cipher(password).unwrap();
let mut block = aes::Block::from(self.encrypted_hash);
cipher.decrypt_area(&mut block, BLOCK_SIZE as usize, self.generation().into(), get_tweak_default);
cipher.decrypt_area(
&mut block,
BLOCK_SIZE as usize,
self.generation().into(),
get_tweak_default,
);
if block == aes::Block::from(hash) {
return Some(cipher);
}
+4 -1
View File
@@ -1,4 +1,7 @@
use aes::{Aes128, BlockDecrypt, BlockEncrypt, NewBlockCipher};
use aes::{
cipher::{BlockDecrypt, BlockEncrypt, KeyInit},
Aes128,
};
use xts_mode::Xts128;
// The raw key, keep secret!