Skip to content

Commit

Permalink
cipher: fixup macro block_mode_{dec,enc}_test
Browse files Browse the repository at this point in the history
  • Loading branch information
baloo committed Feb 20, 2024
1 parent 13144ff commit bc57d68
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cipher/src/dev/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ macro_rules! block_mode_enc_test {
fn $name() {
use cipher::{
array::Array, blobby::Blob4Iterator, inout::InOutBuf, typenum::Unsigned,
BlockCipherEncrypt, BlockSizeUser, KeyIvInit,
BlockCipherEncrypt, BlockSizeUser, KeyIvInit, BlockModeEncrypt
};

fn run_test(key: &[u8], iv: &[u8], pt: &[u8], ct: &[u8]) -> bool {
Expand All @@ -115,7 +115,7 @@ macro_rules! block_mode_enc_test {
let (blocks, tail) = buf.reborrow().into_chunks();
assert_eq!(tail.len(), 0);
for block in blocks {
state.encrypt_block_inout_mut(block);
state.encrypt_block_inout(block);
}
if buf.get_out() != ct {
return false;
Expand All @@ -125,7 +125,7 @@ macro_rules! block_mode_enc_test {
let mut state = <$cipher as KeyIvInit>::new_from_slices(key, iv).unwrap();
buf.get_out().iter_mut().for_each(|b| *b = 0);
let (blocks, _) = buf.reborrow().into_chunks();
state.encrypt_blocks_inout_mut(blocks);
state.encrypt_blocks_inout(blocks);
if buf.get_out() != ct {
return false;
}
Expand Down Expand Up @@ -160,7 +160,7 @@ macro_rules! block_mode_dec_test {
fn $name() {
use cipher::{
array::Array, blobby::Blob4Iterator, inout::InOutBuf, typenum::Unsigned,
BlockCipherDecrypt, BlockSizeUser, KeyIvInit,
BlockCipherDecrypt, BlockSizeUser, KeyIvInit, BlockModeDecrypt,
};

fn run_test(key: &[u8], iv: &[u8], pt: &[u8], ct: &[u8]) -> bool {
Expand All @@ -173,7 +173,7 @@ macro_rules! block_mode_dec_test {
let (blocks, tail) = buf.reborrow().into_chunks();
assert_eq!(tail.len(), 0);
for block in blocks {
state.decrypt_block_inout_mut(block);
state.decrypt_block_inout(block);
}
if buf.get_out() != pt {
return false;
Expand All @@ -183,7 +183,7 @@ macro_rules! block_mode_dec_test {
let mut state = <$cipher as KeyIvInit>::new_from_slices(key, iv).unwrap();
buf.get_out().iter_mut().for_each(|b| *b = 0);
let (blocks, _) = buf.reborrow().into_chunks();
state.decrypt_blocks_inout_mut(blocks);
state.decrypt_blocks_inout(blocks);
if buf.get_out() != pt {
return false;
}
Expand Down

0 comments on commit bc57d68

Please sign in to comment.