diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 17:39:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 17:39:49 +0000 |
commit | a0aa2307322cd47bbf416810ac0292925e03be87 (patch) | |
tree | 37076262a026c4b48c8a0e84f44ff9187556ca35 /rust/vendor/polyval/tests | |
parent | Initial commit. (diff) | |
download | suricata-a0aa2307322cd47bbf416810ac0292925e03be87.tar.xz suricata-a0aa2307322cd47bbf416810ac0292925e03be87.zip |
Adding upstream version 1:7.0.3.upstream/1%7.0.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'rust/vendor/polyval/tests')
-rw-r--r-- | rust/vendor/polyval/tests/lib.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/rust/vendor/polyval/tests/lib.rs b/rust/vendor/polyval/tests/lib.rs new file mode 100644 index 0000000..fdb98d2 --- /dev/null +++ b/rust/vendor/polyval/tests/lib.rs @@ -0,0 +1,27 @@ +use hex_literal::hex; +use polyval::{ + universal_hash::{NewUniversalHash, UniversalHash}, + Polyval, BLOCK_SIZE, +}; + +// +// Test vectors for POLYVAL from RFC 8452 Appendix A +// <https://tools.ietf.org/html/rfc8452#appendix-A> +// + +const H: [u8; BLOCK_SIZE] = hex!("25629347589242761d31f826ba4b757b"); +const X_1: [u8; BLOCK_SIZE] = hex!("4f4f95668c83dfb6401762bb2d01a262"); +const X_2: [u8; BLOCK_SIZE] = hex!("d1a24ddd2721d006bbe45f20d3c9f362"); + +/// POLYVAL(H, X_1, X_2) +const POLYVAL_RESULT: [u8; BLOCK_SIZE] = hex!("f7a3b47b846119fae5b7866cf5e5b77e"); + +#[test] +fn polyval_test_vector() { + let mut poly = Polyval::new(&H.into()); + poly.update(&X_1.into()); + poly.update(&X_2.into()); + + let result = poly.finalize(); + assert_eq!(&POLYVAL_RESULT[..], result.into_bytes().as_slice()); +} |