Skip to content

Commit

Permalink
aes: move Block8 to the hazmat module
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov committed Jan 29, 2025
1 parent b13fe20 commit 4417227
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion aes/src/armv8/hazmat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! implementations in this crate, but instead provides raw AES-NI accelerated
//! access to the AES round function gated under the `hazmat` crate feature.
use crate::{Block, Block8};
use crate::hazmat::{Block, Block8};
use core::arch::aarch64::*;

/// AES cipher (encrypt) round function.
Expand Down
6 changes: 5 additions & 1 deletion aes/src/hazmat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
//! We do NOT recommend using it to implement any algorithm which has not
//! received extensive peer review by cryptographers.
use crate::{soft::fixslice::hazmat as soft, Block, Block8};
use crate::soft::fixslice::hazmat as soft;

pub use crate::Block;
/// Eight 128-bit AES blocks
pub type Block8 = cipher::array::Array<Block, cipher::consts::U8>;

#[cfg(all(target_arch = "aarch64", not(aes_force_soft)))]
use crate::armv8::hazmat as intrinsics;
Expand Down
4 changes: 1 addition & 3 deletions aes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,11 @@ cfg_if! {
pub use cipher;
use cipher::{
array::Array,
consts::{U16, U8},
consts::U16,
};

/// 128-bit AES block
pub type Block = Array<u8, U16>;
/// Eight 128-bit AES blocks
pub type Block8 = Array<Block, U8>;

#[cfg(test)]
mod tests {
Expand Down
2 changes: 1 addition & 1 deletion aes/src/ni/hazmat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! access to the AES round function gated under the `hazmat` crate feature.
use super::arch::*;
use crate::{Block, Block8};
use crate::hazmat::{Block, Block8};
use cipher::array::{Array, ArraySize};

#[target_feature(enable = "sse2")]
Expand Down
2 changes: 1 addition & 1 deletion aes/src/soft/fixslice32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ pub(crate) mod hazmat {
bitslice, inv_bitslice, inv_mix_columns_0, inv_shift_rows_1, inv_sub_bytes, mix_columns_0,
shift_rows_1, sub_bytes, sub_bytes_nots, State,
};
use crate::{Block, Block8};
use crate::hazmat::{Block, Block8};

/// XOR the `src` block into the `dst` block in-place.
fn xor_in_place(dst: &mut Block, src: &Block) {
Expand Down
2 changes: 1 addition & 1 deletion aes/src/soft/fixslice64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,7 @@ pub(crate) mod hazmat {
bitslice, inv_bitslice, inv_mix_columns_0, inv_shift_rows_1, inv_sub_bytes, mix_columns_0,
shift_rows_1, sub_bytes, sub_bytes_nots, State,
};
use crate::{Block, Block8};
use crate::hazmat::{Block, Block8};

/// XOR the `src` block into the `dst` block in-place.
fn xor_in_place(dst: &mut Block, src: &Block) {
Expand Down
2 changes: 1 addition & 1 deletion aes/tests/hazmat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// TODO(tarcieri): support for using the hazmat functions with the `soft` backend
#![cfg(feature = "hazmat")]

use aes::{Block, Block8};
use aes::hazmat::{Block, Block8};
use hex_literal::hex;

/// Round function tests vectors.
Expand Down

0 comments on commit 4417227

Please sign in to comment.