Skip to content

Commit

Permalink
modified to address clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
AnarchistHoneybun committed Jun 27, 2024
1 parent d99728a commit fa5c077
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
13 changes: 4 additions & 9 deletions kupyna512/src/sub_units/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ fn silo(message_block: &[u8], prev_vector: &[u8]) -> Vec<u8> {

let t_xor_mp = t_xor_l(&m_xor_p, ROUNDS);

let t_plus_m = t_plus_l(&message_block, ROUNDS);
let t_plus_m = t_plus_l(message_block, ROUNDS);

let return_vector = xor_bytes(&(xor_bytes(&t_xor_mp, &t_plus_m)), prev_vector);

return_vector
xor_bytes(&(xor_bytes(&t_xor_mp, &t_plus_m)), prev_vector)
}

pub(crate) fn plant(message_blocks: Vec<&[u8]>, init_vector: &[u8]) -> Vec<u8> {
Expand All @@ -27,13 +25,10 @@ pub(crate) fn plant(message_blocks: Vec<&[u8]>, init_vector: &[u8]) -> Vec<u8> {
last_vector = silo(block, &last_vector);
}

let last_vector = finalize(&last_vector);

last_vector
finalize(&last_vector)
}

fn finalize(ult_processed_block: &[u8]) -> Vec<u8> {
let t_xor_ult_processed_block = t_xor_l(ult_processed_block, ROUNDS);
let final_state = xor_bytes(ult_processed_block, &t_xor_ult_processed_block);
final_state
xor_bytes(ult_processed_block, &t_xor_ult_processed_block)
}
10 changes: 5 additions & 5 deletions kupyna512/src/sub_units/t_xor_plus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ fn matrix_to_block(matrix: Matrix) -> Vec<u8> {
}

pub(crate) fn add_constant_xor(mut state: Matrix, round: usize) -> Matrix {
for j in 0..ROWS {
for (j, row) in state.iter_mut().enumerate().take(ROWS) {
let constant = ((j * 0x10) ^ round) as u8;
state[j][0] ^= constant;
row[0] ^= constant;
}
state
}
Expand All @@ -58,8 +58,8 @@ pub(crate) fn add_constant_plus(mut state: Matrix, round: usize) -> Matrix {

pub(crate) fn s_box_layer(mut state: Matrix) -> Matrix {
for i in 0..COLS {
for j in 0..ROWS {
state[j][i] = SBOXES[i % 4][state[j][i] as usize];
for row in state.iter_mut() {
row[i] = SBOXES[i % 4][row[i] as usize];
}
}
state
Expand All @@ -69,7 +69,7 @@ pub(crate) fn rotate_rows(mut state: Matrix) -> Matrix {
let mut temp = [0u8; ROWS];
let mut shift: i32 = -1;
for i in 0..COLS {
if (i == COLS - 1) && true {
if i == COLS - 1 {
shift = 11;
} else {
shift += 1;
Expand Down

0 comments on commit fa5c077

Please sign in to comment.