Skip to content

Commit

Permalink
debug_assert that xof_many is always called with whole blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
oconnor663 committed Aug 18, 2024
1 parent 93c989a commit 0fc4049
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ffi_avx512.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ pub unsafe fn xof_many(
flags: u8,
out: &mut [u8],
) {
debug_assert_eq!(0, out.len() % BLOCK_LEN, "whole blocks only");
ffi::blake3_xof_many_avx512(
cv.as_ptr(),
block.as_ptr(),
Expand Down
1 change: 1 addition & 0 deletions src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ impl Platform {
flags: u8,
out: &mut [u8],
) {
debug_assert_eq!(0, out.len() % BLOCK_LEN, "whole blocks only");
if out.is_empty() {
// The current assembly implementation always outputs at least 1 block.
return;
Expand Down
1 change: 1 addition & 0 deletions src/portable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ pub fn xof_many(
flags: u8,
out: &mut [u8],
) {
debug_assert_eq!(0, out.len() % BLOCK_LEN, "whole blocks only");
for out_block in out.chunks_exact_mut(64) {
out_block.copy_from_slice(&compress_xof(cv, block, block_len, counter, flags));
counter += 1;
Expand Down

0 comments on commit 0fc4049

Please sign in to comment.