Skip to content

Commit

Permalink
test gm-zuc
Browse files Browse the repository at this point in the history
  • Loading branch information
Nugine committed Jan 9, 2025
1 parent 2fd083d commit c9b3587
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ const-str = "0.5.7"
std-next = "0.1.4"

[dev-dependencies]
bytemuck = "1.21.0"
criterion = "0.5.1"
gm-zuc = "0.10.1"
rand = "0.8.5"

[[bench]]
Expand Down
15 changes: 15 additions & 0 deletions src/eia3_128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,21 @@ mod tests {
let mac = eia3_128_generate_mac(x.count, x.bearer, x.direction, &x.ik, x.length, x.m);
assert_eq!(mac, x.mac);
}

for x in examples {
let mut eia =
gm_zuc::eia::EIA::new(&x.ik, x.count, x.bearer.into(), x.direction.into());

let mut buf = vec![0; x.m.len().div_ceil(4)];
bytemuck::cast_slice_mut::<u32, u8>(buf.as_mut_slice())[..x.m.len()]
.copy_from_slice(x.m);
for u in &mut buf {
*u = u.swap_bytes();
}

let mac = eia.gen_mac(&buf, x.length);
assert_eq!(mac, x.mac);
}
}

#[should_panic(expected = "`length` is greater than the length of `m`")]
Expand Down

0 comments on commit c9b3587

Please sign in to comment.