aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack O'Connor <[email protected]>2022-03-09 14:39:24 -0500
committerJack O'Connor <[email protected]>2022-03-09 14:39:24 -0500
commitffed5c5605bb2e56d195d45b445cf32916c012f9 (patch)
tree15f76f0da89f20bf306ada8289625316e6e86e38
parent09c2b9141c81e5afc0720ce9c4937856e0dbfdb6 (diff)
test unaligned writes
-rw-r--r--src/kernel.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/kernel.rs b/src/kernel.rs
index 49ac3f6..0a32fcd 100644
--- a/src/kernel.rs
+++ b/src/kernel.rs
@@ -1585,7 +1585,11 @@ fn test_xof_stream16() {
let block_words = crate::platform::words_from_le_bytes_64(&padded_block);
let key_words = crate::platform::words_from_le_bytes_32(&key);
let flags = crate::KEYED_HASH | crate::CHUNK_START | crate::CHUNK_END;
- let mut found = [0; 1024];
+ let mut found_aligned = [0u32; 16 * 16 + 1];
+ assert!(std::mem::size_of_val(&found_aligned) > 1024);
+ let found: &mut [u8; 1024] =
+ unsafe { &mut *((found_aligned.as_mut_ptr() as *mut u8).add(1) as *mut _) };
+ assert_eq!(1, found.as_ptr() as usize % 4);
unsafe {
xof_stream16(
&block_words,
@@ -1593,8 +1597,8 @@ fn test_xof_stream16() {
0,
block_len as u32,
flags as u32,
- &mut found,
+ found,
);
}
- assert_eq!(expected, found);
+ assert_eq!(expected, *found);
}