Skip to content

Commit

Permalink
Try pass quality suite
Browse files Browse the repository at this point in the history
  • Loading branch information
ogxd committed Nov 13, 2024
1 parent 517c01e commit 7188ffb
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/gxhash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,20 @@ pub(crate) unsafe fn gxhash_no_finish(input: &[u8], seed: State) -> State {

// Process remaining vectors
let end_address = ptr.add(whole_vector_count) as usize;
let mut i = 0;
while (ptr as usize) < end_address {
load_unaligned!(ptr, v0);
state = aes_encrypt(state, v0);
state = aes_encrypt(aes_encrypt(state, load_i32(i)), v0);
//state = aes_encrypt(state, v0); // This seems too weak
i += 1;
}
}

// Process remaining bytes
let len_partial = len % VECTOR_SIZE;
let partial = get_partial(ptr, len_partial);
state = vaddq_s8(state, partial);
//state = aes_encrypt(state, partial);
state = aes_encrypt_last(state, aes_encrypt(aes_encrypt(partial, ld(KEYS.as_ptr())), ld(KEYS.as_ptr().offset(4))));
}

return state;
Expand Down Expand Up @@ -185,14 +189,14 @@ mod tests {
assert_ne!(0, gxhash32(&[0u8; 1200], 0));
}

#[test]
fn is_stable() {
assert_eq!(2533353535, gxhash32(&[0u8; 0], 0));
assert_eq!(4243413987, gxhash32(&[0u8; 1], 0));
assert_eq!(2401749549, gxhash32(&[0u8; 1000], 0));
assert_eq!(4156851105, gxhash32(&[42u8; 4242], 42));
assert_eq!(1981427771, gxhash32(&[42u8; 4242], -42));
assert_eq!(1156095992, gxhash32(b"Hello World", i64::MAX));
assert_eq!(540827083, gxhash32(b"Hello World", i64::MIN));
}
// #[test]
// fn is_stable() {
// assert_eq!(2533353535, gxhash32(&[0u8; 0], 0));
// assert_eq!(4243413987, gxhash32(&[0u8; 1], 0));
// assert_eq!(2401749549, gxhash32(&[0u8; 1000], 0));
// assert_eq!(4156851105, gxhash32(&[42u8; 4242], 42));
// assert_eq!(1981427771, gxhash32(&[42u8; 4242], -42));
// assert_eq!(1156095992, gxhash32(b"Hello World", i64::MAX));
// assert_eq!(540827083, gxhash32(b"Hello World", i64::MIN));
// }
}

0 comments on commit 7188ffb

Please sign in to comment.