Skip to content

Commit

Permalink
hss/aux: Fix aux_data is empty cmp
Browse files Browse the repository at this point in the history
  • Loading branch information
aewag committed Sep 8, 2024
1 parent e3f6c32 commit d13b4db
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/hss/aux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ pub fn hss_extract_aux_data<H: HashChain>(
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;
}

Expand Down
24 changes: 15 additions & 9 deletions src/hss/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,35 +471,41 @@ mod tests {

#[test]
fn test_signing_sha256_128() {
test_signing_core::<Sha256_128>();
test_signing_core_sha_x::<Sha256_128>();
}

#[test]
fn test_signing_sha256_192() {
test_signing_core::<Sha256_192>();
test_signing_core_sha_x::<Sha256_192>();
}

#[test]
fn test_signing_sha256_256() {
test_signing_core::<Sha256_256>();
test_signing_core_sha_x::<Sha256_256>();
}

#[test]
fn test_signing_shake256_128() {
test_signing_core::<Shake256_128>();
test_signing_core_sha_x::<Shake256_128>();
}

#[test]
fn test_signing_shake256_192() {
test_signing_core::<Shake256_192>();
test_signing_core_sha_x::<Shake256_192>();
}

#[test]
fn test_signing_shake256_256() {
test_signing_core::<Shake256_256>();
test_signing_core_sha_x::<Shake256_256>();
}

fn test_signing_core<H: HashChain>() {
fn test_signing_core_sha_x<H: HashChain>() {
test_signing_core::<H>(&mut None);
let mut aux_data = [0u8; 1_000];
test_signing_core::<H>(&mut Some(&mut aux_data));
}

fn test_signing_core<H: HashChain>(aux_data: &mut Option<&mut [u8]>) {
let seed = gen_random_seed::<H>();
let (mut signing_key, verifying_key) = hss_keygen::<H>(
&[
Expand All @@ -508,7 +514,7 @@ mod tests {
HssParameter::construct_default_parameters(),
],
&seed,
None,
aux_data.as_mut(),
)
.expect("Should generate HSS keys");

Expand All @@ -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.");

Expand Down

0 comments on commit d13b4db

Please sign in to comment.