diff --git a/c/blake3_c_rust_bindings/src/lib.rs b/c/blake3_c_rust_bindings/src/lib.rs index 31b7731bc..ce7185ef3 100644 --- a/c/blake3_c_rust_bindings/src/lib.rs +++ b/c/blake3_c_rust_bindings/src/lib.rs @@ -177,15 +177,6 @@ pub mod ffi { flags_end: u8, out: *mut u8, ); - pub fn blake3_xof_many_portable( - cv: *const u32, - block: *const u8, - block_len: u8, - counter: u64, - flags: u8, - out: *mut u8, - outblocks: usize, - ); } #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] diff --git a/c/blake3_c_rust_bindings/src/test.rs b/c/blake3_c_rust_bindings/src/test.rs index 6a8e3e3e6..2070886df 100644 --- a/c/blake3_c_rust_bindings/src/test.rs +++ b/c/blake3_c_rust_bindings/src/test.rs @@ -359,6 +359,7 @@ fn test_hash_many_neon() { test_hash_many_fn(crate::ffi::neon::blake3_hash_many_neon); } +#[allow(unused)] type XofManyFunction = unsafe extern "C" fn( cv: *const u32, block: *const u8, @@ -370,6 +371,7 @@ type XofManyFunction = unsafe extern "C" fn( ); // A shared helper function for platform-specific tests. +#[allow(unused)] pub fn test_xof_many_fn(xof_many_function: XofManyFunction) { let mut block = [0; BLOCK_LEN]; let block_len = 42; @@ -390,16 +392,17 @@ pub fn test_xof_many_fn(xof_many_function: XofManyFunction) { const OUTPUT_SIZE: usize = 31 * BLOCK_LEN; let mut portable_out = [0u8; OUTPUT_SIZE]; - unsafe { - crate::ffi::blake3_xof_many_portable( - cv.as_ptr(), - block.as_ptr(), - block_len as u8, - counter, - flags, - portable_out.as_mut_ptr(), - OUTPUT_SIZE / BLOCK_LEN, - ); + for (i, out_block) in portable_out.chunks_exact_mut(BLOCK_LEN).enumerate() { + unsafe { + crate::ffi::blake3_compress_xof_portable( + cv.as_ptr(), + block.as_ptr(), + block_len as u8, + counter + i as u64, + flags, + out_block.as_mut_ptr(), + ); + } } let mut test_out = [0u8; OUTPUT_SIZE]; @@ -445,12 +448,6 @@ pub fn test_xof_many_fn(xof_many_function: XofManyFunction) { } } -// Testing the portable implementation against itself is circular, but why not. -#[test] -fn test_xof_many_portable() { - test_xof_many_fn(crate::ffi::blake3_xof_many_portable); -} - #[test] #[cfg(unix)] #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] diff --git a/c/blake3_impl.h b/c/blake3_impl.h index 3da773b95..3bb916914 100644 --- a/c/blake3_impl.h +++ b/c/blake3_impl.h @@ -222,14 +222,6 @@ void blake3_compress_xof_portable(const uint32_t cv[8], uint8_t block_len, uint64_t counter, uint8_t flags, uint8_t out[64]); -// This function is test-only. When blake3_xof_many doesn't have an optimized implementation, -// it loops over blake3_compress_xof instead of falling back to this, so it still benefits -// from compress optimizations. -void blake3_xof_many_portable(const uint32_t cv[8], - const uint8_t block[BLAKE3_BLOCK_LEN], - uint8_t block_len, uint64_t counter, uint8_t flags, - uint8_t out[64], size_t outblocks); - void blake3_hash_many_portable(const uint8_t *const *inputs, size_t num_inputs, size_t blocks, const uint32_t key[8], uint64_t counter, bool increment_counter, diff --git a/c/blake3_portable.c b/c/blake3_portable.c index 73e7f3e93..062dd1b47 100644 --- a/c/blake3_portable.c +++ b/c/blake3_portable.c @@ -122,16 +122,6 @@ void blake3_compress_xof_portable(const uint32_t cv[8], store32(&out[15 * 4], state[15] ^ cv[7]); } -void blake3_xof_many_portable(const uint32_t cv[8], - const uint8_t block[BLAKE3_BLOCK_LEN], - uint8_t block_len, uint64_t counter, uint8_t flags, - uint8_t out[BLAKE3_BLOCK_LEN], size_t outblocks) -{ - for(size_t i = 0; i < outblocks; ++i) { - blake3_compress_xof_portable(cv, block, block_len, counter + i, flags, out + 64*i); - } -} - INLINE void hash_one_portable(const uint8_t *input, size_t blocks, const uint32_t key[8], uint64_t counter, uint8_t flags, uint8_t flags_start, diff --git a/src/portable.rs b/src/portable.rs index 35b5f5d44..7af6828b0 100644 --- a/src/portable.rs +++ b/src/portable.rs @@ -177,25 +177,6 @@ pub fn hash_many( } } -// This function is test-only. When platform::xof_many() doesn't have an optimized implementation, -// it loops over platform::compress_xof() instead of falling back to this, so it still benefits -// from compress optimizations. -#[cfg(test)] -pub fn xof_many( - cv: &CVWords, - block: &[u8; BLOCK_LEN], - block_len: u8, - mut counter: u64, - 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; - } -} - #[cfg(test)] pub mod test { use super::*; @@ -214,10 +195,4 @@ pub mod test { fn test_hash_many() { crate::test::test_hash_many_fn(hash_many, hash_many); } - - // Ditto. - #[test] - fn test_xof_many() { - crate::test::test_xof_many_fn(xof_many); - } } diff --git a/src/test.rs b/src/test.rs index 251a7834b..bb99d1021 100644 --- a/src/test.rs +++ b/src/test.rs @@ -206,6 +206,7 @@ pub fn test_hash_many_fn( } } +#[allow(unused)] type XofManyFunction = unsafe fn( cv: &CVWords, block: &[u8; BLOCK_LEN], @@ -216,6 +217,7 @@ type XofManyFunction = unsafe fn( ); // A shared helper function for platform-specific tests. +#[allow(unused)] pub fn test_xof_many_fn(xof_many_function: XofManyFunction) { let mut block = [0; BLOCK_LEN]; let block_len = 42; @@ -237,14 +239,15 @@ pub fn test_xof_many_fn(xof_many_function: XofManyFunction) { const OUTPUT_SIZE: usize = 31 * BLOCK_LEN; let mut portable_out = [0u8; OUTPUT_SIZE]; - crate::portable::xof_many( - &cv, - &block, - block_len as u8, - counter, - flags, - &mut portable_out, - ); + for (i, out_block) in portable_out.chunks_exact_mut(64).enumerate() { + out_block.copy_from_slice(&crate::portable::compress_xof( + &cv, + &block, + block_len as u8, + counter + i as u64, + flags, + )); + } let mut test_out = [0u8; OUTPUT_SIZE]; unsafe {