mirror of
https://github.com/kristoferssolo/cipher-workshop.git
synced 2025-12-20 11:04:38 +00:00
fix: clippy warnings
This commit is contained in:
parent
bf6ae712a7
commit
4007a9a04d
@ -18,8 +18,8 @@ impl BlockCipher for Aes {
|
|||||||
|
|
||||||
fn transform_impl(
|
fn transform_impl(
|
||||||
&self,
|
&self,
|
||||||
block: &[u8],
|
_block: &[u8],
|
||||||
action: cipher_core::CipherAction,
|
_action: cipher_core::CipherAction,
|
||||||
) -> cipher_core::CipherResult<cipher_core::Output> {
|
) -> cipher_core::CipherResult<cipher_core::Output> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,7 +28,7 @@ impl Subkeys {
|
|||||||
for (round, &rcon) in RCON.iter().enumerate() {
|
for (round, &rcon) in RCON.iter().enumerate() {
|
||||||
let idx = round * 4 + 4;
|
let idx = round * 4 + 4;
|
||||||
|
|
||||||
subkeys[idx + 0] = subkeys[idx - 4] ^ expand(&subkeys[idx - 1], rcon);
|
subkeys[idx] = subkeys[idx - 4] ^ expand(subkeys[idx - 1], rcon);
|
||||||
subkeys[idx + 1] = subkeys[idx] ^ subkeys[idx - 3];
|
subkeys[idx + 1] = subkeys[idx] ^ subkeys[idx - 3];
|
||||||
subkeys[idx + 2] = subkeys[idx + 1] ^ subkeys[idx - 2];
|
subkeys[idx + 2] = subkeys[idx + 1] ^ subkeys[idx - 2];
|
||||||
subkeys[idx + 3] = subkeys[idx + 2] ^ subkeys[idx - 1];
|
subkeys[idx + 3] = subkeys[idx + 2] ^ subkeys[idx - 1];
|
||||||
@ -82,7 +82,7 @@ impl Debug for Subkeys {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const fn expand(subkey: &Subkey, rcon: u32) -> ExpandedKey {
|
const fn expand(subkey: Subkey, rcon: u32) -> ExpandedKey {
|
||||||
let word = subkey.rotate_left(8).as_u32();
|
let word = subkey.rotate_left(8).as_u32();
|
||||||
|
|
||||||
let b0 = sbox_lookup(word >> 24);
|
let b0 = sbox_lookup(word >> 24);
|
||||||
@ -105,7 +105,7 @@ const fn sbox_lookup(byte: u32) -> u32 {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const TEST_KEY: u128 = 0x0F1571C947D9E8591CB7ADD6AF7F6798;
|
const TEST_KEY: u128 = 0x0F15_71C9_47D9_E859_1CB7_ADD6_AF7F_6798;
|
||||||
|
|
||||||
impl PartialEq<[[u8; 4]; 44]> for Subkeys {
|
impl PartialEq<[[u8; 4]; 44]> for Subkeys {
|
||||||
fn eq(&self, other: &[[u8; 4]; 44]) -> bool {
|
fn eq(&self, other: &[[u8; 4]; 44]) -> bool {
|
||||||
@ -167,6 +167,6 @@ mod tests {
|
|||||||
[0xDD, 0xB0, 0x06, 0x46],
|
[0xDD, 0xB0, 0x06, 0x46],
|
||||||
[0x86, 0xDB, 0x18, 0x10],
|
[0x86, 0xDB, 0x18, 0x10],
|
||||||
]
|
]
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
/// The table should have `output_bits` entries. For each entry i (0-based), `position_table`[i] indicates
|
/// The table should have `output_bits` entries. For each entry i (0-based), `position_table`[i] indicates
|
||||||
/// which input bit (1-based) should go to the i-th output bit position (from MSB to LSB).
|
/// which input bit (1-based) should go to the i-th output bit position (from MSB to LSB).
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn permutate(
|
pub fn _permutate(
|
||||||
input: u64,
|
input: u64,
|
||||||
input_bit_amount: u64,
|
input_bit_amount: u64,
|
||||||
output_bit_amount: u64,
|
output_bit_amount: u64,
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
/// Generic bit permutation for DES specification.
|
/// Generic bit permutation for DES specification.
|
||||||
|
///
|
||||||
/// DES uses 1-based positioning where bit 1 is the leftmost (MSB) and bit 64 is the rightmost (LSB).
|
/// DES uses 1-based positioning where bit 1 is the leftmost (MSB) and bit 64 is the rightmost (LSB).
|
||||||
/// This function handles this correctly for arbitrary input/output sizes.
|
/// This function handles this correctly for arbitrary input/output sizes.
|
||||||
///
|
///
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user