Skip to content

Commit

Permalink
Fix clippy::precedence lints (#466)
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov authored Jan 31, 2025
1 parent 81f1eb4 commit 551e791
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion belt-block/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ mod tests {
let mut h: [u32; 256] = [0u32; 256];
for x in 0..256 {
let mut y: u32 = H[x] as u32;
y = y << r | y >> (32 - r);
y = (y << r) | (y >> (32 - r));
h[x] = y;
}
match r {
Expand Down
18 changes: 9 additions & 9 deletions serpent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ fn apply_s_bitslice(index: usize, [w1, w2, w3, w4]: Words) -> Words {
let quad = apply_s(
index,
get_bit(w1 as usize, i)
| get_bit(w2 as usize, i) << 1
| get_bit(w3 as usize, i) << 2
| get_bit(w4 as usize, i) << 3,
| (get_bit(w2 as usize, i) << 1)
| (get_bit(w3 as usize, i) << 2)
| (get_bit(w4 as usize, i) << 3),
);

for l in 0..4 {
Expand All @@ -111,9 +111,9 @@ fn apply_s_inverse_bitslice(index: usize, [w1, w2, w3, w4]: Words) -> Words {
let quad = apply_s_inverse(
index,
get_bit(w1 as usize, i)
| get_bit(w2 as usize, i) << 1
| get_bit(w3 as usize, i) << 2
| get_bit(w4 as usize, i) << 3,
| (get_bit(w2 as usize, i) << 1)
| (get_bit(w3 as usize, i) << 2)
| (get_bit(w4 as usize, i) << 3),
);
for l in 0..4 {
words[l] |= u32::from(get_bit(quad as usize, l)) << i;
Expand Down Expand Up @@ -183,9 +183,9 @@ impl KeyInit for Serpent {
// calculate keys in bitslicing mode
for j in 0..32 {
let input = get_bit(a as usize, j)
| get_bit(b as usize, j) << 1
| get_bit(c as usize, j) << 2
| get_bit(d as usize, j) << 3;
| (get_bit(b as usize, j) << 1)
| (get_bit(c as usize, j) << 2)
| (get_bit(d as usize, j) << 3);
let output = apply_s(sbox_index, input);
for l in 0..4 {
k[4 * i + l] |= u32::from(get_bit(output as usize, l)) << j;
Expand Down
2 changes: 1 addition & 1 deletion twofish/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn gf_mult(mut a: u8, mut b: u8, p: u8) -> u8 {

// q_i sbox
fn sbox(i: usize, x: u8) -> u8 {
let (a0, b0) = (x >> 4 & 15, x & 15);
let (a0, b0) = ((x >> 4) & 15, x & 15);
let a1 = a0 ^ b0;
let b1 = (a0 ^ ((b0 << 3) | (b0 >> 1)) ^ (a0 << 3)) & 15;
let (a2, b2) = (QBOX[i][0][a1 as usize], QBOX[i][1][b1 as usize]);
Expand Down

0 comments on commit 551e791

Please sign in to comment.