Skip to content

Commit

Permalink
rc6: fix clippy and add github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ashWhiteHat committed Jul 31, 2024
1 parent bc11b3f commit e8e7360
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 2 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/rc6.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: rc6
on:
pull_request:
paths:
- "rc6/**"
- "Cargo.*"
push:
branches: master

defaults:
run:
working-directory: rc6

env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-Dwarnings"

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- 1.56.0 # MSRV
- stable
target:
- thumbv7em-none-eabi
- wasm32-unknown-unknown
steps:
- uses: actions/checkout@v3
- uses: RustCrypto/actions/cargo-cache@master
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
- run: cargo build --no-default-features --release --target ${{ matrix.target }}

minimal-versions:
uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master
with:
working-directory: ${{ github.workflow }}

test:
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- 1.56.0 # MSRV
- stable
steps:
- uses: actions/checkout@v3
- uses: RustCrypto/actions/cargo-cache@master
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- run: cargo check --all-features
- run: cargo test --no-default-features
- run: cargo test
- run: cargo test --all-features
4 changes: 2 additions & 2 deletions rc6/src/core/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ where
pub fn encrypt(&self, mut block: InOut<'_, '_, Block<W>>) {
let (mut a, mut b) = Self::words_from_block(block.get_in());
let key = &self.key_table;
let log_w = W::from((W::Bytes::USIZE as f64 * 8 as f64).log2() as u8);
let log_w = W::from((usize::BITS - 1 - (W::Bytes::USIZE * 8).leading_zeros()) as u8);

b = b.wrapping_add(key[0]);
d = d.wrapping_add(key[1]);
Expand Down Expand Up @@ -170,7 +170,7 @@ where
pub fn decrypt(&self, mut block: InOut<'_, '_, Block<W>>) {
let (mut a, mut b) = Self::words_from_block(block.get_in());
let key = &self.key_table;
let log_w = W::from((W::Bytes::USIZE as f64 * 8 as f64).log2() as u8);
let log_w = W::from((usize::BITS - 1 - (W::Bytes::USIZE * 8).leading_zeros()) as u8);

c = c.wrapping_sub(key[2 * R::USIZE + 3]);
a = a.wrapping_sub(key[2 * R::USIZE + 2]);
Expand Down

0 comments on commit e8e7360

Please sign in to comment.