Skip to content

Commit a1e14b5

Browse files
committed
[WIP] ARMv8 Cryptography Extensions support
Adds a new backend which uses ARMv8 Cryptography Extensions. These extensions are supported on both 32-bit and 64-bit ARM targets, however the current implementation is gated on `aarch64` (as that's the only architecture it's been tested on so far). Presently only AES-128 is supported, but the code is written in such a way it should be easy to expand to AES-192 and AES-256.
1 parent 371d711 commit a1e14b5

File tree

11 files changed

+492
-45
lines changed

11 files changed

+492
-45
lines changed

.github/workflows/aes.yml

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ jobs:
3636
target: ${{ matrix.target }}
3737
profile: minimal
3838
override: true
39-
- run: cargo check --all-features
39+
- run: cargo check --features compact,ctr,force-soft
4040
- run: cargo build --release --target ${{ matrix.target }}
4141
- run: cargo build --release --target ${{ matrix.target }} --features compact
4242
- run: cargo build --release --target ${{ matrix.target }} --features ctr
4343
- run: cargo build --release --target ${{ matrix.target }} --features force-soft
44-
- run: cargo build --release --target ${{ matrix.target }} --all-features
44+
- run: cargo build --release --target ${{ matrix.target }} --features compact,ctr,force-soft
4545

4646
# Tests for the AES-NI backend
4747
aesni:
@@ -79,7 +79,6 @@ jobs:
7979
- run: cargo test --release --target ${{ matrix.target }} --features compact
8080
- run: cargo test --release --target ${{ matrix.target }} --features ctr
8181
- run: cargo test --release --target ${{ matrix.target }} --features force-soft
82-
- run: cargo test --release --target ${{ matrix.target }} --all-features
8382

8483
# Tests for CPU feature autodetection with fallback to portable software implementation
8584
autodetect:
@@ -144,7 +143,7 @@ jobs:
144143
- run: cargo test --release --target ${{ matrix.target }} --features force-soft
145144
- run: cargo test --release --target ${{ matrix.target }} --features force-soft,compact
146145
- run: cargo test --release --target ${{ matrix.target }} --features force-soft,ctr
147-
- run: cargo test --release --target ${{ matrix.target }} --all-features
146+
- run: cargo build --release --target ${{ matrix.target }} --features compact,ctr,force-soft
148147

149148
# Cross-compiled tests
150149
cross:
@@ -162,7 +161,6 @@ jobs:
162161
rust: 1.49.0 # MSRV
163162
- target: powerpc-unknown-linux-gnu
164163
rust: stable
165-
166164
runs-on: ubuntu-latest
167165
steps:
168166
- uses: actions/checkout@v1
@@ -178,4 +176,43 @@ jobs:
178176
- run: cross test --release --target ${{ matrix.target }} --features compact
179177
- run: cross test --release --target ${{ matrix.target }} --features ctr
180178
- run: cross test --release --target ${{ matrix.target }} --features force-soft
179+
- run: cross test --release --target ${{ matrix.target }} --features compact,ctr,force-soft
180+
181+
# Nightly-only cross-compiled tests (for ARM64 intrinsics)
182+
nightly:
183+
strategy:
184+
matrix:
185+
include:
186+
# ARM64
187+
- target: aarch64-unknown-linux-gnu
188+
rust: 1.49.0 # MSRV
189+
- target: aarch64-unknown-linux-gnu
190+
rust: stable
191+
runs-on: ubuntu-latest
192+
steps:
193+
- uses: actions/checkout@v1
194+
- run: ${{ matrix.deps }}
195+
- uses: actions-rs/toolchain@v1
196+
with:
197+
toolchain: ${{ matrix.rust }}
198+
target: ${{ matrix.target }}
199+
profile: minimal
200+
override: true
201+
- run: cargo install cross
202+
- run: cross test --release --target ${{ matrix.target }}
203+
- run: cross test --release --target ${{ matrix.target }} --features nightly,compact
204+
- run: cross test --release --target ${{ matrix.target }} --features nightly,ctr
205+
- run: cross test --release --target ${{ matrix.target }} --features nightly,force-soft
181206
- run: cross test --release --target ${{ matrix.target }} --all-features
207+
208+
clippy:
209+
runs-on: ubuntu-latest
210+
steps:
211+
- uses: actions/checkout@v1
212+
- uses: actions-rs/toolchain@v1
213+
with:
214+
toolchain: 1.49.0 # MSRV
215+
components: clippy
216+
override: true
217+
profile: minimal
218+
- run: cargo clippy --features compact,ctr,force-soft -- -D warnings

.github/workflows/workspace.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
components: clippy
2121
override: true
2222
profile: minimal
23-
- run: cargo clippy --all --all-features -- -D warnings
23+
- run: cargo clippy --all --exclude aes --all-features -- -D warnings
2424

2525
rustfmt:
2626
runs-on: ubuntu-latest

aes/Cargo.lock

Lines changed: 86 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aes/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ cipher = { version = "0.3", features = ["dev"] }
2727
cpufeatures = "0.1"
2828

2929
[features]
30-
compact = [] # Reduce code size at the cost of slower performance
30+
compact = [] # Reduce code size at the cost of slower performance
3131
force-soft = [] # Disable support for AES hardware intrinsics
32+
nightly = [] # Nightly compiler support; enables ARMv8 intrinsics
3233

3334
[package.metadata.docs.rs]
3435
features = ["ctr"]

0 commit comments

Comments
 (0)