diff --git a/src/hss/aux.rs b/src/hss/aux.rs index 81e83a42..424c4633 100644 --- a/src/hss/aux.rs +++ b/src/hss/aux.rs @@ -205,7 +205,7 @@ pub fn hss_extract_aux_data( let start_index = lms_leaf_identifier as usize * hash_size; let end_index = start_index + hash_size; - if src[start_index..end_index] == [0u8; MAX_HASH_SIZE] { + if src[start_index..end_index].iter().all(|&b| b == 0u8) { return None; } diff --git a/src/hss/mod.rs b/src/hss/mod.rs index cd7db949..8f3664da 100644 --- a/src/hss/mod.rs +++ b/src/hss/mod.rs @@ -471,35 +471,41 @@ mod tests { #[test] fn test_signing_sha256_128() { - test_signing_core::(); + test_signing_core_sha_x::(); } #[test] fn test_signing_sha256_192() { - test_signing_core::(); + test_signing_core_sha_x::(); } #[test] fn test_signing_sha256_256() { - test_signing_core::(); + test_signing_core_sha_x::(); } #[test] fn test_signing_shake256_128() { - test_signing_core::(); + test_signing_core_sha_x::(); } #[test] fn test_signing_shake256_192() { - test_signing_core::(); + test_signing_core_sha_x::(); } #[test] fn test_signing_shake256_256() { - test_signing_core::(); + test_signing_core_sha_x::(); } - fn test_signing_core() { + fn test_signing_core_sha_x() { + test_signing_core::(&mut None); + let mut aux_data = [0u8; 1_000]; + test_signing_core::(&mut Some(&mut aux_data)); + } + + fn test_signing_core(aux_data: &mut Option<&mut [u8]>) { let seed = gen_random_seed::(); let (mut signing_key, verifying_key) = hss_keygen::( &[ @@ -508,7 +514,7 @@ mod tests { HssParameter::construct_default_parameters(), ], &seed, - None, + aux_data.as_mut(), ) .expect("Should generate HSS keys"); @@ -529,7 +535,7 @@ mod tests { &message, signing_key_const.as_slice(), &mut update_private_key, - None, + aux_data.as_mut(), ) .expect("Signing should complete without error.");