Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/aes_ctr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//! See [AesCtrZipKeyStream] for more information.

use crate::unstable::LittleEndianWriteExt;
use aes::cipher::generic_array::GenericArray;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good modernization! The removal of the deprecated GenericArray import is appropriate. The aes crate has evolved to accept slice types directly, making the GenericArray wrapper unnecessary.

use aes::cipher::{BlockEncrypt, KeyInit};
use std::{any, fmt};

Expand Down Expand Up @@ -92,7 +91,7 @@ where
pub fn new(key: &[u8]) -> AesCtrZipKeyStream<C> {
AesCtrZipKeyStream {
counter: 1,
cipher: C::Cipher::new(GenericArray::from_slice(key)),
cipher: C::Cipher::new(key.try_into().expect("invalid key length")),
buffer: [0u8; AES_BLOCK_SIZE],
pos: AES_BLOCK_SIZE,
}
Expand All @@ -114,8 +113,7 @@ where
.as_mut()
.write_u128_le(self.counter)
.expect("did not expect u128 le conversion to fail");
self.cipher
.encrypt_block(GenericArray::from_mut_slice(&mut self.buffer));
self.cipher.encrypt_block(&mut self.buffer);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect modernization! The direct use of &mut self.buffer instead of GenericArray::from_mut_slice(&mut self.buffer) is much more idiomatic. The BlockEncrypt::encrypt_block method now accepts mutable slice references directly, eliminating the need for the GenericArray wrapper.

self.counter += 1;
self.pos = 0;
}
Expand Down
Loading