Skip to content

Commit

Permalink
aes: remove force-soft feature
Browse files Browse the repository at this point in the history
It's breaking cross-based builds. See:

#208 (comment)
  • Loading branch information
tarcieri committed Dec 1, 2020
1 parent d8587e8 commit f2f37ec
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 204 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/aes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ jobs:
- run: cargo build --release --target ${{ matrix.target }}
- run: cargo build --release --target ${{ matrix.target }} --features compact
- run: cargo build --release --target ${{ matrix.target }} --features ctr
- run: cargo build --release --target ${{ matrix.target }} --features force-soft
- run: cargo build --release --target ${{ matrix.target }} --all-features

# Tests for the portable software backend
Expand Down Expand Up @@ -74,7 +73,6 @@ jobs:
- run: cargo test --release --target ${{ matrix.target }}
- run: cargo test --release --target ${{ matrix.target }} --features compact
- run: cargo test --release --target ${{ matrix.target }} --features ctr
- run: cargo test --release --target ${{ matrix.target }} --features force-soft
- run: cargo test --release --target ${{ matrix.target }} --all-features

# Tests for the AES-NI backend
Expand Down Expand Up @@ -113,7 +111,6 @@ jobs:
- run: cargo test --release --target ${{ matrix.target }}
- run: cargo test --release --target ${{ matrix.target }} --features compact
- run: cargo test --release --target ${{ matrix.target }} --features ctr
- run: cargo test --release --target ${{ matrix.target }} --features force-soft
- run: cargo test --release --target ${{ matrix.target }} --all-features

# Cross-compiled tests
Expand Down Expand Up @@ -147,5 +144,4 @@ jobs:
- run: cross test --release --target ${{ matrix.target }}
- run: cross test --release --target ${{ matrix.target }} --features compact
- run: cross test --release --target ${{ matrix.target }} --features ctr
- run: cargo test --release --target ${{ matrix.target }} --features force-soft
- run: cargo test --release --target ${{ matrix.target }} --all-features
3 changes: 1 addition & 2 deletions aes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ cipher = { version = "=0.3.0-pre", features = ["dev"] }
cpuid-bool = "0.2"

[features]
compact = [] # Reduce code size at the cost of performance
force-soft = [] # Disable support for AES hardware intrinsics
compact = [] # Reduce code size at the cost of slower performance

[package.metadata.docs.rs]
features = ["ctr"]
Expand Down
1 change: 1 addition & 0 deletions aes/src/autodetect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ pub(crate) mod ctr {
}

mod $module {
#[allow(clippy::large_enum_variant)]
pub(super) enum Inner {
Ni(crate::ni::$name),
Soft(crate::soft::$name),
Expand Down
5 changes: 1 addition & 4 deletions aes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@
use cfg_if::cfg_if;

cfg_if! {
if #[cfg(all(
any(target_arch = "x86_64", target_arch = "x86"),
not(feature = "force-soft")
))] {
if #[cfg(any(target_arch = "x86_64", target_arch = "x86"))] {
mod autodetect;
mod ni;
mod soft;
Expand Down
4 changes: 4 additions & 0 deletions aes/src/ni/aes128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ impl BlockDecrypt for Aes128 {
// Safety: `loadu` and `storeu` support unaligned access
#[allow(clippy::cast_ptr_alignment)]
let mut b = _mm_loadu_si128(block.as_ptr() as *const __m128i);

b = _mm_xor_si128(b, keys[10]);
b = _mm_aesdec_si128(b, keys[9]);
b = _mm_aesdec_si128(b, keys[8]);
Expand All @@ -123,6 +124,9 @@ impl BlockDecrypt for Aes128 {
b = _mm_aesdec_si128(b, keys[2]);
b = _mm_aesdec_si128(b, keys[1]);
b = _mm_aesdeclast_si128(b, keys[0]);

// Safety: `loadu` and `storeu` support unaligned access
#[allow(clippy::cast_ptr_alignment)]
_mm_storeu_si128(block.as_mut_ptr() as *mut __m128i, b);
}

Expand Down
4 changes: 4 additions & 0 deletions aes/src/ni/aes192.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ impl BlockDecrypt for Aes192 {
// Safety: `loadu` and `storeu` support unaligned access
#[allow(clippy::cast_ptr_alignment)]
let mut b = _mm_loadu_si128(block.as_ptr() as *const __m128i);

b = _mm_xor_si128(b, keys[12]);
b = _mm_aesdec_si128(b, keys[11]);
b = _mm_aesdec_si128(b, keys[10]);
Expand All @@ -127,6 +128,9 @@ impl BlockDecrypt for Aes192 {
b = _mm_aesdec_si128(b, keys[2]);
b = _mm_aesdec_si128(b, keys[1]);
b = _mm_aesdeclast_si128(b, keys[0]);

// Safety: `loadu` and `storeu` support unaligned access
#[allow(clippy::cast_ptr_alignment)]
_mm_storeu_si128(block.as_mut_ptr() as *mut __m128i, b);
}

Expand Down
4 changes: 4 additions & 0 deletions aes/src/ni/aes256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ impl BlockDecrypt for Aes256 {
// Safety: `loadu` and `storeu` support unaligned access
#[allow(clippy::cast_ptr_alignment)]
let mut b = _mm_loadu_si128(block.as_ptr() as *const __m128i);

b = _mm_xor_si128(b, keys[14]);
b = _mm_aesdec_si128(b, keys[13]);
b = _mm_aesdec_si128(b, keys[12]);
Expand All @@ -133,6 +134,9 @@ impl BlockDecrypt for Aes256 {
b = _mm_aesdec_si128(b, keys[2]);
b = _mm_aesdec_si128(b, keys[1]);
b = _mm_aesdeclast_si128(b, keys[0]);

// Safety: `loadu` and `storeu` support unaligned access
#[allow(clippy::cast_ptr_alignment)]
_mm_storeu_si128(block.as_mut_ptr() as *mut __m128i, b);
}

Expand Down
Loading

0 comments on commit f2f37ec

Please sign in to comment.