Skip to content

Commit

Permalink
Added CI support for bitsliced AES
Browse files Browse the repository at this point in the history
  • Loading branch information
sayantn committed Sep 1, 2024
1 parent a8374c5 commit 024251a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/runtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ on:
required: false
type: string
default: ''
extra-features:
required: false
type: string
default: ''

jobs:
test:
Expand All @@ -36,5 +40,5 @@ jobs:
- name: Test
run: |
chmod 777 ./ci/run-docker.sh
./ci/run-docker.sh ${{ inputs.arch }} ${{ inputs.target }} ${{ inputs.channel == 'nightly' && '--features=nightly' || '' }}
./ci/run-docker.sh ${{ inputs.arch }} ${{ inputs.target }} ${{ inputs.extra-features }}
shell: bash
34 changes: 31 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,21 @@ jobs:
target: x86_64-unknown-linux-gnu
caps: X86_64_UNKNOWN_LINUX_GNU
target-features: +vaes
extra-features: --features=nightly
- name: AES-NI with VAES and AVX-512
target: x86_64-unknown-linux-gnu
caps: X86_64_UNKNOWN_LINUX_GNU
target-features: +vaes,+avx512f
extra-features: --features=nightly
- name: Neon
target: aarch64-unknown-linux-gnu
caps: AARCH64_UNKNOWN_LINUX_GNU
target-features: +aes
- name: ARMv8
target: armv7-unknown-linux-gnueabihf
caps: ARMV7_UNKNOWN_LINUX_GNUEABIHF
target-features: +v8,+aes
extra-features: --features=nightly
- name: RV64
target: riscv64gc-unknown-linux-gnu
caps: RISCV64GC_UNKNOWN_LINUX_GNU
Expand All @@ -52,6 +59,11 @@ jobs:
target: x86_64-unknown-linux-gnu
caps: X86_64_UNKNOWN_LINUX_GNU
target-features: ''
- name: Software
target: x86_64-unknown-linux-gnu
caps: X86_64_UNKNOWN_LINUX_GNU
target-features: ''
extra-features: --features=constant-time
steps:
- uses: actions/checkout@v3

Expand All @@ -67,7 +79,7 @@ jobs:
override: true

- name: Clippy Check
run: cargo clippy --target ${{ matrix.impl.target }} --features=nightly --no-deps -- -D clippy::pedantic
run: cargo clippy --target ${{ matrix.impl.target }} ${{ matrix.impl.extra-features }} --no-deps -- -D clippy::pedantic

test-aesni:
strategy:
Expand All @@ -89,6 +101,7 @@ jobs:
target: x86_64-unknown-linux-gnu
channel: nightly
target-features: +vaes
extra-features: --features=nightly

test-aesni-vaes-avx512:
name: Test of AESNI with VAES and AVX512F
Expand All @@ -98,6 +111,7 @@ jobs:
target: x86_64-unknown-linux-gnu
channel: nightly
target-features: +vaes,+avx512f
extra-features: --features=nightly

test-neon:
strategy:
Expand All @@ -118,7 +132,8 @@ jobs:
arch: arm
target: armv7-unknown-linux-gnueabihf
channel: nightly
target-features: +aes
target-features: +v8,+aes
extra-features: --features=nightly

test-riscv64:
name: Test of RiscV-64
Expand All @@ -128,6 +143,7 @@ jobs:
target: riscv64gc-unknown-linux-gnu
channel: nightly
target-features: +zkne,+zknd
extra-features: --features=nightly

test-software:
strategy:
Expand All @@ -138,4 +154,16 @@ jobs:
with:
arch: x86_64
target: x86_64-unknown-linux-gnu
channel: ${{ matrix.channel }}
channel: ${{ matrix.channel }}

test-constant-time:
strategy:
matrix:
channel: [ stable, beta, nightly ]
name: Test of Software Implementation with ${{ matrix.channel }}
uses: ./.github/workflows/runtest.yml
with:
arch: x86_64
target: x86_64-unknown-linux-gnu
channel: ${{ matrix.channel }}
extra-features: --features=constant-time
4 changes: 2 additions & 2 deletions src/aes_bitslice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const fn step_b(a: u128, mask: u128) -> u128 {
(x | (x >> 1)) ^ ((a << 1) & mask)
}

#[allow(clippy::cast_possible_truncation)]
const fn sub_word(x: u32) -> u32 {
// Check if rustc is enough to optimize this
subbytes(x as u128) as u32
Expand Down Expand Up @@ -155,9 +156,8 @@ const fn invsubbytes(x: u128) -> u128 {
let y = ror1(y);
let x = x ^ (y & rep(0xfb));
let y = ror1(y);
let x = x ^ (y & rep(0x7d));

x
x ^ (y & rep(0x7d))
}

const fn shiftrows(state: [u8; 16]) -> [u8; 16] {
Expand Down

0 comments on commit 024251a

Please sign in to comment.