summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack O'Connor <oconnor663@gmail.com>2024-08-18 15:36:11 -0700
committerJack O'Connor <oconnor663@gmail.com>2024-08-18 17:43:58 -0700
commitdcff6b65acdd978863512c2d9c1359aef2564ea4 (patch)
tree22126611ede951804d2818e7fbef2e9fad83348c
parent5c4c351a1a0729f8e7a88e6895379bb952ed1a07 (diff)
delete portable::xof_many and blake3_xof_many_portable
-rw-r--r--c/blake3_c_rust_bindings/src/lib.rs9
-rw-r--r--c/blake3_c_rust_bindings/src/test.rs29
-rw-r--r--c/blake3_impl.h8
-rw-r--r--c/blake3_portable.c10
-rw-r--r--src/portable.rs25
-rw-r--r--src/test.rs19
6 files changed, 24 insertions, 76 deletions
diff --git a/c/blake3_c_rust_bindings/src/lib.rs b/c/blake3_c_rust_bindings/src/lib.rs
index 31b7731..ce7185e 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 6a8e3e3..2070886 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 3da773b..3bb9169 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 73e7f3e..062dd1b 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 35b5f5d..7af6828 100644
--- a/src/portable.rs
+++ b/src/portable.rs
@@ -177,25 +177,6 @@ pub fn hash_many<const N: usize>(
}
}
-// 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 251a783..bb99d10 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 {