Skip to content

Commit

Permalink
test(aegis_128l): add interop test with aegis crate
Browse files Browse the repository at this point in the history
  • Loading branch information
codahale committed Nov 2, 2023
1 parent 86d7c72 commit 5acf7ab
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
17 changes: 17 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ std = []
members = ["benchmarks", "xtask"]

[dev-dependencies]
aegis = { version = "0.4.9", features = ["pure-rust"] }
expect-test = "1.4.1"
hex = "0.4.3"
hex-literal = "0.4.1"
Expand Down
18 changes: 16 additions & 2 deletions src/aegis_128l.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,14 +565,28 @@ mod tests {
k: [u8; 16],
n: [u8; 16],
ad in vec(any::<u8>(), 0..200),
msg in vec(any::<u8>(), 0..200)) {

msg in vec(any::<u8>(), 0..200),
) {
let mut ct = msg.clone();
let tag_e = encrypt(&k, &n, &mut ct, &ad);
let tag_d = decrypt(&k, &n, &mut ct, &ad);

prop_assert_eq!(msg, ct, "invalid plaintext");
prop_assert_eq!(tag_e, tag_d, "invalid tag");
}

#[test]
fn interop(
k: [u8; 16],
n: [u8; 16],
ad in vec(any::<u8>(), 0..200),
msg in vec(any::<u8>(), 0..200),
) {
let mut ct = msg.clone();
let tag = encrypt(&k, &n, &mut ct, &ad);

let aegis = aegis::aegis128l::Aegis128L::<32>::new(&k, &n);
prop_assert_eq!(Ok(msg), aegis.decrypt(&ct, &tag, &ad), "should decrypt successfully");
}
}
}

0 comments on commit 5acf7ab

Please sign in to comment.