diff options
Diffstat (limited to 'src/hash_quality_test.rs')
-rw-r--r-- | src/hash_quality_test.rs | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/hash_quality_test.rs b/src/hash_quality_test.rs index 837924d..4cd3156 100644 --- a/src/hash_quality_test.rs +++ b/src/hash_quality_test.rs @@ -316,6 +316,16 @@ fn test_padding_doesnot_collide<T: Hasher>(hasher: impl Fn() -> T) { } } +fn test_length_extension<T: Hasher>(hasher: impl Fn(u128, u128) -> T) { + for key in 0..256 { + let h1 = hasher(key, key); + let v1 = hash_with(&[0_u8, 0, 0, 0, 0, 0, 0, 0], h1); + let h2 = hasher(key, key); + let v2 = hash_with(&[1_u8, 0, 0, 0, 0, 0, 0, 0, 0], h2); + assert_ne!(v1, v2); + } +} + #[cfg(test)] mod fallback_tests { use crate::fallback_hash::*; @@ -377,10 +387,18 @@ mod fallback_tests { test_padding_doesnot_collide(|| AHasher::new_with_keys(2, 0)); test_padding_doesnot_collide(|| AHasher::new_with_keys(2, 2)); } + + #[test] + fn fallback_length_extension() { + test_length_extension(|a, b| AHasher::new_with_keys(a, b)); + } } ///Basic sanity tests of the cypto properties of aHash. -#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes", not(miri)))] +#[cfg(any( + all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes", not(miri)), + all(any(target_arch = "arm", target_arch = "aarch64"), target_feature = "crypto", not(miri), feature = "stdsimd") +))] #[cfg(test)] mod aes_tests { use crate::aes_hash::*; @@ -457,4 +475,9 @@ mod aes_tests { test_padding_doesnot_collide(|| AHasher::test_with_keys(BAD_KEY, BAD_KEY)); test_padding_doesnot_collide(|| AHasher::test_with_keys(BAD_KEY2, BAD_KEY2)); } + + #[test] + fn aes_length_extension() { + test_length_extension(|a, b| AHasher::test_with_keys(a, b)); + } } |