From 6a707deeefdbde0e4a81fff2e2a29ff50a9db2ef Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Mon, 20 Jan 2020 23:06:47 +0100 Subject: [PATCH] beamsplitter updates from upstream they found and fixed the precedence bug, but then went a bit overboard with inlining without macros. But the mixers are now wordwise. --- beamsplitter.cpp | 189 +++++++++++++++++++++++++++++++++-------------- beamsplitter.h | 15 ++-- main.cpp | 2 +- 3 files changed, 141 insertions(+), 65 deletions(-) diff --git a/beamsplitter.cpp b/beamsplitter.cpp index a012b850..6ab04bd1 100644 --- a/beamsplitter.cpp +++ b/beamsplitter.cpp @@ -1,3 +1,4 @@ +#include #include "beamsplitter.h" #if defined(_MSC_VER) @@ -12,97 +13,171 @@ #endif // !defined(_MSC_VER) +typedef uint8_t u8; + //--------- - // mix function : mix 128 bits of state to 128 bits of state + // mix function : 8 bits -> 8 bits, using an offset to specify the s-box and a key - FORCE_INLINE void mix ( uint32_t * s64, uint8_t * s8, - const uint8_t box1[8][256], const uint8_t box2[8][256] ) + FORCE_INLINE int mix ( u8 * state_byte, u8 key, int offset ) { - uint8_t x[16] = {0}; - uint32_t * t = (uint32_t *)x; - uint8_t * q = (uint8_t *)x; - - int counter = 0; - for( int i = 0; i < 8; i++ ) { - q[i] = s8[i] + counter; - q[i] = box1[i][q[i]]; - counter += q[i]; - } + const uint8_t *sbox = S[((offset>>6)&2)][offset&7]; - for( int i = 8; i < 16; i++ ) { - q[i] = s8[i] + q[i-8]; - q[i] = box2[i-8][q[i]]; - } + *state_byte = sbox[sbox[*state_byte] ^ key]; + + offset += sbox[sbox[*state_byte] + key]; + + return offset; + } + + //--------- + // mix2 function : 8 bytes -> 8 bytes + + FORCE_INLINE void mix2 ( u8 *p, u8 *q, u8 *r, u8 *s, u8 *t, u8 *u, u8 *v, u8 *w, u8 k[8], int offset ) + { + offset = mix(p, k[0], offset); + offset = mix(q, k[1], offset); + offset = mix(r, k[2], offset); + offset = mix(s, k[3], offset); + offset = mix(t, k[4], offset); + offset = mix(u, k[5], offset); + offset = mix(v, k[6], offset); + mix(w, k[7], offset); + } + + //--------- + // mix3 function : 64 bytes -> 64 bytes - s64[0] = t[2]; - s64[1] = t[3]; - s64[2] = t[0]; - s64[3] = t[1]; + FORCE_INLINE uint64_t mix3 ( u8 s[64], u8 *k, int index ) + { + int m = 63; + u8 z[8] = {0}; + uint64_t *w = (uint64_t *)z; + + u8 *a = z; + u8 *b = z+1; + u8 *c = z+2; + u8 *d = z+3; + u8 *e = z+4; + u8 *f = z+5; + u8 *g = z+6; + u8 *h = z+7; + + mix2(s+(*a&m),s+(*b&m),s+(*c&m),s+(*d&m),s+(*e&m),s+(*f&m),s+(*g&m),s+(*h&m), k+0, index ); + mix2(z+0,z+1,z+2,z+3,z+4,z+5,z+6,z+7, k+0, index ); + mix2(s+(*b&m),s+(*c&m),s+(*d&m),s+(*e&m),s+(*f&m),s+(*g&m),s+(*h&m),s+(*a&m), k+8, index + 8); + mix2(z+0,z+1,z+2,z+3,z+4,z+5,z+6,z+7, k+8, index + 8); + + mix2(s+(*c&m),s+(*d&m),s+(*e&m),s+(*f&m),s+(*g&m),s+(*h&m),s+(*a&m),s+(*b&m), k+16, index + 16); + mix2(z+0,z+1,z+2,z+3,z+4,z+5,z+6,z+7, k+16, index + 16); + mix2(s+(*d&m),s+(*e&m),s+(*f&m),s+(*g&m),s+(*h&m),s+(*a&m),s+(*b&m),s+(*c&m), k+24, index + 24); + mix2(z+0,z+1,z+2,z+3,z+4,z+5,z+6,z+7, k+24, index + 24); + + mix2(s+(*e&m),s+(*f&m),s+(*g&m),s+(*h&m),s+(*a&m),s+(*b&m),s+(*c&m),s+(*d&m), k+32, index + 32); + mix2(z+0,z+1,z+2,z+3,z+4,z+5,z+6,z+7, k+32, index + 32); + mix2(s+(*f&m),s+(*g&m),s+(*h&m),s+(*a&m),s+(*b&m),s+(*c&m),s+(*d&m),s+(*e&m), k+40, index + 40); + mix2(z+0,z+1,z+2,z+3,z+4,z+5,z+6,z+7, k+40, index + 40); + + mix2(s+(*g&m),s+(*h&m),s+(*a&m),s+(*b&m),s+(*c&m),s+(*d&m),s+(*e&m),s+(*f&m), k+48, index + 48); + mix2(z+0,z+1,z+2,z+3,z+4,z+5,z+6,z+7, k+48, index + 48); + mix2(s+(*h&m),s+(*a&m),s+(*b&m),s+(*c&m),s+(*d&m),s+(*e&m),s+(*f&m),s+(*g&m), k+56, index + 56); + mix2(z+0,z+1,z+2,z+3,z+4,z+5,z+6,z+7, k+56, index + 56); + + return *w; } //--------- // Hash round function - FORCE_INLINE void round( const uint32_t * m64, const uint8_t * m8, int len, - uint32_t * state64, uint8_t * state8 ) + FORCE_INLINE uint64_t round( const uint64_t * m64, const uint8_t * m8, int len, + uint64_t state64[8], uint8_t state8[64], uint64_t w) { int index = 0; - for( int Len = len >> 2; index < Len; index++ ) { - state64[index&3] ^= (m64[index] + index); - if ( index&3 == 0 && index != 0 ) { - mix( state64, state8, S[0], S[1] ); + for( int Len = len >> 6; index < Len; index++ ) { + w ^= mix3( state8, (u8 *)m64+index, index<<6 ); + } + + index <<= 6; + + if ( len >= 64 ) { + w ^= mix3( state8, (u8 *)m8+len-64, index ); + index = len; + } else if ( len >= 8 ) { + int i = 0; + int m = 63; + u8 z[8] = {0}; + uint64_t *w2 = (uint64_t *)z; + + u8 *a = z; + u8 *b = z+1; + u8 *c = z+2; + u8 *d = z+3; + u8 *e = z+4; + u8 *f = z+5; + u8 *g = z+6; + u8 *h = z+7; + + while( i + 8 < len ) { + mix2(state8+(*a&m),state8+(*b&m),state8+(*c&m),state8+(*d&m), + state8+(*e&m),state8+(*f&m),state8+(*g&m),state8+(*h&m), (u8 *)m8+i, i); + mix2(z+0,z+1,z+2,z+3,z+4,z+5,z+6,z+7, (u8 *)m8+i, i); + i += 8; } + + w ^= *w2; + index = i; } - for( index <<= 2; index < len; index++ ) { - state8[index&15] ^= (m8[index] + index); - if ( index&7 == 0 && index != 0 ) { - mix( state64, state8, S[0], S[1] ); + w ^= mix3( state8, state8, index ); + + if ( index < len ) { + int offset = index; + for( index; index < len; index++ ) { + offset = mix(state8+(index&63), m8[index], offset); } } - mix( state64, state8, S[2], S[3] ); + + w ^= mix3( state8, state8, index ); + + return w; } //--------- // main hash function - void beamsplitter_64 ( const void * key, int len, unsigned seed, void * out ) + void beamsplitter_64 ( const void * key, int len, uint32_t seed, void * out ) { + uint64_t w = 0; + const uint8_t *key8Arr = (uint8_t *)key; - const uint32_t *key64Arr = (uint32_t *)key; + const uint64_t *key64Arr = (uint64_t *)key; const uint8_t seedbuf[8] = {0}; - uint32_t *seed64Arr = (uint32_t *)seedbuf; + uint32_t *seed32Arr = (uint32_t *)seedbuf; + uint64_t *seed64Arr = (uint64_t *)seedbuf; const uint8_t *seed8Arr = (uint8_t *)seedbuf; - const uint8_t buf[16] = {0}; + const uint8_t buf[64] = {0}; uint8_t *state8 = (uint8_t *)buf; uint32_t *state32 = (uint32_t *)buf; - uint32_t *state = (uint32_t *)buf; - - seed64Arr[0] = seed; - seed64Arr[1] = seed; - - round( seed64Arr, seed8Arr, 8, state, state8 ); - round( key64Arr, key8Arr, len, state, state8 ); - - round( seed64Arr, seed8Arr, 8, state, state8 ); - round( key64Arr, key8Arr, len, state, state8 ); + uint64_t *state = (uint64_t *)buf; - const uint8_t output[16] = {0}; - uint32_t *h = (uint32_t *)output; + seed32Arr[0] = seed; + seed32Arr[1] = seed; - // The new combination step - h[0] = state32[0]; - h[1] = state32[1]; - h[2] = state32[2]; - h[3] = state32[3]; + w += round( seed64Arr, seed8Arr, 8, state, state8, w); + w += round( key64Arr, key8Arr, len, state, state8, w); + w += round( state, state8, 64, state, state8, w); + w += round( key64Arr, key8Arr, len, state, state8, w); + w += round( state, state8, 64, state, state8, w); + w += round( key64Arr, key8Arr, len, state, state8, w); + w += round( state, state8, 64, state, state8, w); + w += round( state, state8, 64, state, state8, w); - h[0] = h[0] + h[3]; - h[1] = h[1] + h[2]; + //printf("s[0..3] = %#018" PRIx64 " %#018" PRIx64 " %#018" PRIx64 " %#018" PRIx64 "\n", state[0], state[1], state[2], state[3]); + //printf("s[4..7] = %#018" PRIx64 " %#018" PRIx64 " %#018" PRIx64 " %#018" PRIx64 "\n", state[4], state[5], state[6], state[7]); + //printf("w = %#018" PRIx64 "\n\n", w); - ((uint32_t *)out)[0] = h[0]; - ((uint32_t *)out)[1] = h[1]; + ((uint64_t *)out)[0] = w; } diff --git a/beamsplitter.h b/beamsplitter.h index 41985467..0a8eb152 100644 --- a/beamsplitter.h +++ b/beamsplitter.h @@ -1,4 +1,5 @@ #include +#include #ifndef _BEAMSPLITTER_H_ #define _BEAMSPLITTER_H_ @@ -6,7 +7,7 @@ const uint8_t S[4][8][256] = { { { - 57, 191, 149, 181, 190, 120, 196, 66, 180, 17, 67, 128, 231, 207, 83, 96, 106, 51, 27, 7, 92, 204, 40, 2, 45, 84, 28, 223, 32, 1, 5, 90, 171, 142, 144, 118, 24, 221, 44, 46, 244, 42, 159, 177, 220, 203, 253, 77, 184, 124, 123, 230, 209, 25, 186, 16, 113, 33, 88, 112, 80, 228, 217, 254, 182, 161, 153, 218, 211, 166, 183, 157, 72, 176, 94, 56, 158, 179, 13, 38, 227, 129, 187, 41, 156, 236, 246, 219, 114, 195, 229, 121, 3, 122, 62, 50, 136, 104, 197, 189, 213, 85, 115, 108, 86, 134, 160, 252, 242, 188, 79, 9, 52, 74, 21, 245, 165, 8, 97, 54, 91, 139, 6, 119, 155, 39, 29, 71, 18, 240, 247, 148, 163, 194, 131, 174, 130, 12, 140, 70, 109, 255, 170, 126, 75, 202, 132, 95, 154, 137, 14, 102, 138, 125, 55, 210, 222, 15, 216, 117, 135, 60, 151, 98, 100, 20, 127, 69, 226, 64, 167, 22, 19, 193, 198, 61, 162, 133, 232, 147, 235, 35, 76, 208, 68, 48, 0, 225, 116, 82, 89, 63, 185, 212, 58, 10, 201, 206, 99, 248, 30, 65, 233, 141, 164, 146, 34, 150, 249, 59, 26, 111, 145, 238, 241, 169, 178, 81, 11, 175, 101, 250, 4, 47, 73, 234, 172, 224, 237, 37, 78, 107, 251, 215, 192, 43, 143, 105, 49, 239, 110, 168, 205, 23, 53, 36, 103, 173, 31, 243, 87, 152, 214, 199, 93, 200 + 210, 221, 88, 178, 229, 239, 33, 81, 201, 136, 108, 196, 143, 63, 106, 148, 37, 145, 177, 172, 132, 213, 243, 102, 97, 232, 173, 100, 3, 235, 144, 59, 156, 76, 151, 242, 238, 154, 209, 115, 121, 237, 126, 58, 190, 13, 53, 103, 6, 188, 159, 152, 186, 248, 39, 95, 135, 67, 168, 224, 170, 7, 11, 38, 64, 25, 184, 55, 99, 31, 195, 155, 93, 153, 134, 171, 114, 149, 40, 194, 61, 181, 142, 253, 183, 216, 16, 65, 68, 164, 113, 50, 77, 193, 146, 215, 84, 120, 85, 105, 227, 199, 101, 104, 233, 51, 161, 220, 125, 231, 42, 118, 66, 27, 236, 30, 226, 110, 255, 4, 34, 176, 23, 162, 124, 214, 223, 49, 15, 122, 247, 147, 92, 207, 254, 197, 109, 5, 21, 89, 18, 140, 217, 211, 116, 9, 46, 60, 57, 86, 8, 180, 75, 107, 246, 48, 252, 222, 111, 244, 74, 69, 24, 17, 241, 150, 228, 14, 127, 230, 73, 250, 62, 56, 192, 212, 139, 225, 29, 138, 94, 41, 189, 204, 200, 129, 26, 157, 218, 71, 83, 208, 141, 234, 117, 78, 166, 191, 79, 128, 185, 82, 158, 0, 47, 131, 35, 87, 163, 54, 249, 22, 12, 133, 167, 245, 90, 203, 169, 240, 219, 174, 160, 45, 96, 98, 119, 32, 130, 80, 137, 202, 2, 28, 72, 20, 165, 70, 10, 44, 19, 123, 91, 182, 251, 1, 52, 179, 36, 206, 198, 187, 175, 112, 43, 205 }, { 130, 114, 19, 126, 18, 214, 206, 222, 253, 7, 216, 148, 38, 170, 73, 159, 56, 125, 156, 197, 176, 27, 95, 215, 157, 117, 123, 86, 249, 44, 14, 201, 42, 65, 210, 83, 88, 62, 5, 229, 87, 46, 220, 76, 10, 82, 102, 212, 217, 219, 207, 124, 178, 91, 24, 75, 15, 45, 60, 59, 22, 0, 104, 70, 165, 198, 172, 13, 248, 135, 250, 121, 94, 136, 189, 29, 112, 224, 146, 155, 8, 69, 25, 53, 35, 37, 49, 61, 184, 99, 254, 142, 152, 151, 118, 93, 195, 166, 137, 16, 194, 111, 109, 64, 252, 122, 199, 228, 47, 36, 48, 161, 147, 31, 133, 183, 1, 101, 119, 169, 132, 6, 51, 128, 20, 43, 77, 188, 63, 204, 116, 196, 138, 208, 103, 175, 221, 150, 237, 23, 90, 71, 80, 105, 153, 200, 33, 11, 241, 72, 84, 97, 21, 247, 243, 227, 233, 218, 134, 171, 39, 120, 108, 231, 113, 67, 191, 127, 115, 131, 149, 187, 225, 154, 186, 26, 139, 54, 85, 173, 144, 34, 58, 68, 17, 12, 209, 40, 179, 100, 163, 240, 92, 4, 238, 168, 164, 30, 211, 181, 174, 223, 245, 55, 32, 89, 213, 239, 242, 74, 251, 145, 236, 57, 203, 96, 226, 234, 106, 129, 110, 160, 2, 235, 9, 162, 167, 79, 246, 107, 244, 50, 192, 28, 202, 232, 41, 143, 177, 66, 185, 193, 3, 98, 141, 182, 190, 230, 158, 255, 180, 140, 52, 205, 81, 78 @@ -15,13 +16,13 @@ const uint8_t S[4][8][256] = { 63, 1, 203, 93, 151, 24, 49, 171, 61, 55, 156, 39, 88, 177, 96, 7, 186, 145, 80, 112, 59, 219, 194, 84, 32, 191, 178, 31, 25, 34, 207, 165, 53, 70, 2, 54, 97, 72, 140, 253, 28, 123, 200, 161, 150, 154, 4, 128, 73, 78, 190, 172, 127, 17, 125, 231, 142, 246, 181, 218, 234, 212, 119, 216, 102, 159, 42, 12, 229, 167, 182, 213, 143, 131, 30, 241, 10, 217, 220, 22, 138, 215, 157, 183, 47, 16, 13, 155, 248, 206, 148, 113, 254, 87, 19, 104, 68, 193, 38, 144, 135, 158, 45, 162, 197, 173, 225, 40, 15, 69, 89, 6, 129, 81, 27, 101, 176, 174, 201, 160, 196, 58, 18, 136, 95, 77, 179, 115, 245, 62, 41, 226, 214, 114, 120, 124, 110, 239, 251, 163, 130, 195, 60, 46, 164, 66, 230, 180, 146, 205, 106, 65, 185, 198, 90, 227, 33, 57, 153, 48, 0, 37, 247, 74, 139, 192, 249, 111, 23, 204, 56, 118, 238, 75, 76, 211, 202, 126, 36, 43, 79, 26, 221, 228, 237, 188, 9, 240, 44, 85, 91, 141, 210, 99, 8, 133, 134, 3, 175, 166, 233, 35, 243, 108, 105, 52, 232, 11, 29, 98, 209, 103, 92, 149, 67, 208, 244, 5, 168, 170, 50, 20, 223, 189, 252, 255, 199, 116, 86, 82, 94, 152, 184, 147, 236, 71, 14, 235, 169, 64, 51, 107, 132, 121, 224, 222, 250, 122, 83, 187, 100, 109, 242, 21, 117, 137 }, { - 142, 0, 208, 6, 169, 123, 70, 131, 78, 41, 182, 7, 95, 191, 55, 5, 110, 132, 238, 25, 81, 35, 244, 74, 36, 76, 241, 178, 20, 187, 234, 156, 164, 193, 154, 166, 104, 96, 229, 190, 58, 8, 217, 201, 103, 14, 145, 249, 40, 146, 167, 107, 109, 161, 202, 54, 38, 235, 223, 168, 121, 115, 111, 186, 68, 88, 90, 31, 199, 242, 245, 59, 228, 77, 2, 147, 66, 30, 189, 252, 237, 83, 218, 144, 34, 75, 160, 207, 105, 204, 51, 60, 128, 10, 130, 206, 102, 86, 148, 220, 158, 73, 134, 17, 120, 192, 24, 157, 200, 194, 72, 52, 114, 253, 246, 177, 108, 153, 197, 174, 227, 139, 203, 159, 195, 129, 135, 219, 79, 50, 213, 255, 47, 11, 69, 85, 247, 1, 136, 112, 48, 21, 248, 214, 236, 133, 61, 26, 124, 250, 210, 230, 71, 127, 113, 65, 18, 19, 143, 9, 222, 150, 15, 16, 151, 57, 118, 29, 98, 4, 33, 27, 42, 196, 39, 170, 181, 198, 185, 100, 141, 125, 163, 221, 12, 44, 22, 176, 233, 97, 180, 212, 117, 183, 49, 226, 89, 62, 216, 209, 184, 92, 63, 254, 152, 215, 93, 91, 205, 101, 239, 13, 80, 122, 225, 116, 155, 173, 224, 126, 188, 45, 171, 240, 67, 23, 140, 232, 149, 251, 64, 3, 32, 84, 106, 162, 137, 43, 165, 211, 87, 46, 53, 172, 243, 56, 138, 179, 28, 37, 231, 119, 99, 94, 82, 175 + 57, 191, 149, 181, 190, 120, 196, 66, 180, 17, 67, 128, 231, 207, 83, 96, 106, 51, 27, 7, 92, 204, 40, 2, 45, 84, 28, 223, 32, 1, 5, 90, 171, 142, 144, 118, 24, 221, 44, 46, 244, 42, 159, 177, 220, 203, 253, 77, 184, 124, 123, 230, 209, 25, 186, 16, 113, 33, 88, 112, 80, 228, 217, 254, 182, 161, 153, 218, 211, 166, 183, 157, 72, 176, 94, 56, 158, 179, 13, 38, 227, 129, 187, 41, 156, 236, 246, 219, 114, 195, 229, 121, 3, 122, 62, 50, 136, 104, 197, 189, 213, 85, 115, 108, 86, 134, 160, 252, 242, 188, 79, 9, 52, 74, 21, 245, 165, 8, 97, 54, 91, 139, 6, 119, 155, 39, 29, 71, 18, 240, 247, 148, 163, 194, 131, 174, 130, 12, 140, 70, 109, 255, 170, 126, 75, 202, 132, 95, 154, 137, 14, 102, 138, 125, 55, 210, 222, 15, 216, 117, 135, 60, 151, 98, 100, 20, 127, 69, 226, 64, 167, 22, 19, 193, 198, 61, 162, 133, 232, 147, 235, 35, 76, 208, 68, 48, 0, 225, 116, 82, 89, 63, 185, 212, 58, 10, 201, 206, 99, 248, 30, 65, 233, 141, 164, 146, 34, 150, 249, 59, 26, 111, 145, 238, 241, 169, 178, 81, 11, 175, 101, 250, 4, 47, 73, 234, 172, 224, 237, 37, 78, 107, 251, 215, 192, 43, 143, 105, 49, 239, 110, 168, 205, 23, 53, 36, 103, 173, 31, 243, 87, 152, 214, 199, 93, 200 }, { - 219, 28, 40, 107, 181, 10, 248, 58, 121, 85, 1, 83, 241, 109, 6, 144, 55, 250, 187, 183, 39, 204, 123, 71, 220, 88, 225, 179, 188, 18, 36, 162, 0, 76, 53, 101, 54, 237, 110, 82, 103, 89, 207, 113, 79, 60, 249, 167, 151, 148, 38, 235, 203, 205, 125, 65, 30, 3, 133, 178, 253, 143, 165, 2, 7, 37, 19, 11, 177, 29, 173, 62, 69, 169, 48, 91, 152, 194, 198, 22, 184, 72, 245, 202, 175, 32, 211, 172, 239, 57, 233, 66, 234, 35, 206, 189, 108, 146, 164, 195, 209, 100, 127, 27, 240, 106, 157, 78, 161, 145, 96, 124, 67, 212, 247, 230, 216, 200, 221, 214, 90, 98, 50, 150, 77, 15, 74, 68, 117, 46, 228, 141, 231, 116, 95, 73, 242, 137, 156, 26, 166, 186, 23, 190, 87, 120, 176, 193, 180, 223, 56, 254, 122, 128, 255, 252, 135, 154, 84, 208, 196, 170, 199, 86, 34, 213, 4, 93, 136, 81, 159, 246, 16, 43, 115, 217, 222, 9, 153, 210, 112, 41, 44, 129, 226, 149, 134, 191, 14, 59, 63, 114, 243, 218, 130, 142, 33, 70, 201, 155, 244, 13, 5, 238, 160, 236, 185, 64, 132, 229, 17, 75, 174, 45, 8, 197, 92, 232, 131, 80, 168, 215, 94, 104, 42, 97, 52, 192, 20, 224, 51, 158, 99, 126, 118, 147, 182, 12, 61, 21, 138, 105, 24, 47, 227, 31, 119, 251, 111, 49, 171, 25, 140, 139, 102, 163 + 142, 0, 208, 6, 169, 123, 70, 131, 78, 41, 182, 7, 95, 191, 55, 5, 110, 132, 238, 25, 81, 35, 244, 74, 36, 76, 241, 178, 20, 187, 234, 156, 164, 193, 154, 166, 104, 96, 229, 190, 58, 8, 217, 201, 103, 14, 145, 249, 40, 146, 167, 107, 109, 161, 202, 54, 38, 235, 223, 168, 121, 115, 111, 186, 68, 88, 90, 31, 199, 242, 245, 59, 228, 77, 2, 147, 66, 30, 189, 252, 237, 83, 218, 144, 34, 75, 160, 207, 105, 204, 51, 60, 128, 10, 130, 206, 102, 86, 148, 220, 158, 73, 134, 17, 120, 192, 24, 157, 200, 194, 72, 52, 114, 253, 246, 177, 108, 153, 197, 174, 227, 139, 203, 159, 195, 129, 135, 219, 79, 50, 213, 255, 47, 11, 69, 85, 247, 1, 136, 112, 48, 21, 248, 214, 236, 133, 61, 26, 124, 250, 210, 230, 71, 127, 113, 65, 18, 19, 143, 9, 222, 150, 15, 16, 151, 57, 118, 29, 98, 4, 33, 27, 42, 196, 39, 170, 181, 198, 185, 100, 141, 125, 163, 221, 12, 44, 22, 176, 233, 97, 180, 212, 117, 183, 49, 226, 89, 62, 216, 209, 184, 92, 63, 254, 152, 215, 93, 91, 205, 101, 239, 13, 80, 122, 225, 116, 155, 173, 224, 126, 188, 45, 171, 240, 67, 23, 140, 232, 149, 251, 64, 3, 32, 84, 106, 162, 137, 43, 165, 211, 87, 46, 53, 172, 243, 56, 138, 179, 28, 37, 231, 119, 99, 94, 82, 175 }, { - 116, 209, 232, 35, 139, 128, 105, 1, 46, 225, 255, 235, 213, 250, 51, 172, 8, 4, 169, 11, 246, 3, 125, 234, 73, 114, 245, 94, 16, 34, 22, 244, 7, 122, 37, 220, 83, 176, 217, 146, 10, 199, 54, 52, 195, 109, 66, 29, 108, 61, 74, 180, 92, 86, 12, 67, 5, 242, 18, 201, 248, 130, 149, 148, 41, 181, 33, 224, 230, 167, 0, 64, 27, 140, 100, 88, 252, 28, 200, 48, 214, 101, 63, 187, 161, 21, 24, 15, 166, 127, 228, 193, 185, 165, 43, 137, 117, 154, 49, 69, 205, 183, 93, 121, 6, 189, 240, 99, 87, 124, 222, 143, 210, 23, 55, 118, 236, 89, 206, 85, 113, 76, 239, 218, 26, 132, 157, 112, 17, 202, 150, 207, 179, 153, 226, 68, 170, 216, 57, 120, 174, 60, 141, 84, 159, 110, 197, 192, 168, 191, 115, 152, 25, 44, 156, 9, 188, 198, 62, 136, 82, 119, 50, 131, 144, 39, 253, 75, 254, 91, 45, 20, 135, 249, 173, 215, 145, 38, 96, 104, 151, 243, 72, 31, 231, 134, 19, 59, 56, 80, 40, 186, 178, 77, 147, 42, 70, 158, 194, 204, 123, 221, 241, 162, 65, 247, 171, 71, 208, 2, 36, 219, 13, 90, 79, 14, 133, 237, 30, 223, 106, 177, 111, 126, 238, 107, 233, 203, 227, 97, 102, 32, 164, 47, 251, 81, 95, 163, 98, 212, 78, 175, 160, 142, 53, 138, 190, 184, 196, 155, 182, 129, 103, 58, 211, 229 + 219, 28, 40, 107, 181, 10, 248, 58, 121, 85, 1, 83, 241, 109, 6, 144, 55, 250, 187, 183, 39, 204, 123, 71, 220, 88, 225, 179, 188, 18, 36, 162, 0, 76, 53, 101, 54, 237, 110, 82, 103, 89, 207, 113, 79, 60, 249, 167, 151, 148, 38, 235, 203, 205, 125, 65, 30, 3, 133, 178, 253, 143, 165, 2, 7, 37, 19, 11, 177, 29, 173, 62, 69, 169, 48, 91, 152, 194, 198, 22, 184, 72, 245, 202, 175, 32, 211, 172, 239, 57, 233, 66, 234, 35, 206, 189, 108, 146, 164, 195, 209, 100, 127, 27, 240, 106, 157, 78, 161, 145, 96, 124, 67, 212, 247, 230, 216, 200, 221, 214, 90, 98, 50, 150, 77, 15, 74, 68, 117, 46, 228, 141, 231, 116, 95, 73, 242, 137, 156, 26, 166, 186, 23, 190, 87, 120, 176, 193, 180, 223, 56, 254, 122, 128, 255, 252, 135, 154, 84, 208, 196, 170, 199, 86, 34, 213, 4, 93, 136, 81, 159, 246, 16, 43, 115, 217, 222, 9, 153, 210, 112, 41, 44, 129, 226, 149, 134, 191, 14, 59, 63, 114, 243, 218, 130, 142, 33, 70, 201, 155, 244, 13, 5, 238, 160, 236, 185, 64, 132, 229, 17, 75, 174, 45, 8, 197, 92, 232, 131, 80, 168, 215, 94, 104, 42, 97, 52, 192, 20, 224, 51, 158, 99, 126, 118, 147, 182, 12, 61, 21, 138, 105, 24, 47, 227, 31, 119, 251, 111, 49, 171, 25, 140, 139, 102, 163 }, { 238, 91, 206, 69, 149, 205, 125, 176, 36, 225, 249, 144, 39, 162, 67, 236, 35, 164, 3, 61, 204, 109, 53, 142, 83, 190, 197, 171, 224, 121, 7, 168, 79, 24, 253, 146, 209, 52, 243, 63, 19, 155, 246, 84, 97, 112, 43, 178, 159, 193, 213, 2, 76, 59, 172, 128, 160, 161, 66, 254, 150, 175, 107, 137, 117, 31, 180, 145, 203, 1, 210, 235, 41, 237, 124, 15, 136, 140, 196, 101, 85, 42, 177, 189, 153, 141, 34, 156, 27, 242, 214, 30, 227, 99, 252, 228, 217, 173, 221, 58, 179, 208, 12, 188, 166, 157, 163, 127, 187, 240, 138, 212, 191, 103, 170, 28, 38, 239, 181, 54, 111, 241, 68, 247, 108, 130, 71, 57, 152, 199, 148, 114, 98, 11, 232, 74, 0, 33, 123, 182, 81, 87, 80, 154, 118, 45, 70, 8, 231, 105, 62, 90, 48, 110, 131, 186, 234, 251, 194, 49, 248, 198, 116, 165, 100, 10, 37, 143, 106, 122, 229, 158, 89, 55, 133, 78, 119, 185, 75, 9, 13, 222, 23, 174, 47, 46, 169, 40, 151, 134, 192, 17, 93, 244, 65, 201, 211, 233, 226, 147, 72, 126, 26, 129, 4, 104, 216, 6, 21, 60, 51, 120, 95, 73, 32, 16, 223, 135, 77, 29, 44, 245, 113, 215, 20, 250, 220, 195, 200, 5, 167, 25, 64, 218, 132, 18, 92, 102, 88, 230, 14, 255, 96, 22, 82, 86, 207, 219, 202, 183, 94, 184, 56, 115, 50, 139 @@ -58,13 +59,13 @@ const uint8_t S[4][8][256] = { }, { { - 72, 201, 69, 0, 61, 170, 9, 230, 186, 34, 193, 183, 70, 218, 194, 54, 63, 246, 22, 228, 150, 232, 57, 67, 122, 197, 190, 231, 166, 165, 42, 32, 237, 13, 203, 105, 207, 103, 39, 213, 221, 3, 47, 80, 106, 182, 111, 1, 149, 157, 123, 108, 12, 18, 199, 94, 233, 38, 171, 167, 104, 98, 145, 71, 133, 40, 160, 65, 127, 115, 124, 109, 219, 196, 187, 155, 177, 101, 229, 143, 28, 64, 96, 33, 240, 60, 51, 173, 216, 19, 114, 17, 2, 189, 128, 249, 198, 159, 85, 220, 77, 92, 10, 253, 89, 88, 100, 191, 91, 37, 130, 188, 62, 242, 31, 8, 254, 181, 7, 66, 225, 148, 163, 23, 137, 21, 82, 209, 245, 119, 140, 152, 255, 73, 24, 116, 113, 176, 250, 50, 248, 146, 223, 239, 192, 99, 59, 78, 110, 211, 125, 84, 27, 55, 132, 16, 43, 14, 56, 241, 20, 184, 204, 118, 236, 121, 205, 252, 48, 53, 139, 247, 195, 36, 87, 11, 120, 126, 49, 251, 243, 35, 222, 76, 29, 52, 164, 178, 226, 168, 141, 74, 58, 144, 102, 6, 83, 235, 90, 134, 46, 107, 129, 214, 44, 117, 138, 217, 180, 238, 75, 210, 135, 185, 151, 215, 112, 79, 142, 95, 81, 174, 5, 161, 4, 131, 97, 15, 200, 25, 244, 154, 179, 175, 208, 224, 202, 212, 136, 86, 26, 162, 206, 158, 172, 234, 147, 153, 30, 68, 41, 156, 45, 227, 169, 93 + 255, 221, 243, 157, 134, 246, 197, 163, 230, 55, 96, 95, 130, 49, 227, 27, 147, 42, 48, 202, 45, 122, 90, 224, 53, 15, 150, 47, 94, 113, 82, 200, 215, 209, 35, 83, 73, 67, 12, 135, 216, 19, 186, 88, 189, 244, 167, 210, 174, 123, 79, 179, 138, 41, 236, 191, 184, 232, 43, 141, 39, 66, 85, 175, 102, 25, 152, 29, 128, 26, 254, 154, 64, 164, 173, 70, 10, 74, 252, 178, 250, 172, 33, 196, 170, 129, 120, 78, 65, 251, 107, 240, 108, 63, 180, 117, 40, 24, 187, 115, 144, 5, 110, 81, 69, 119, 231, 71, 198, 165, 75, 97, 17, 162, 6, 4, 58, 60, 212, 131, 32, 146, 148, 37, 248, 193, 56, 190, 222, 192, 80, 211, 218, 99, 201, 199, 46, 92, 13, 114, 50, 127, 1, 168, 208, 133, 219, 121, 109, 195, 239, 59, 207, 156, 125, 233, 8, 169, 31, 160, 103, 51, 213, 145, 253, 105, 155, 57, 44, 206, 247, 9, 11, 234, 111, 161, 14, 171, 185, 84, 116, 76, 249, 177, 28, 158, 124, 214, 104, 188, 118, 159, 151, 3, 22, 166, 241, 238, 126, 217, 89, 137, 176, 91, 225, 54, 68, 21, 204, 229, 226, 100, 7, 34, 182, 235, 62, 228, 101, 220, 203, 98, 30, 72, 136, 223, 153, 87, 23, 181, 86, 36, 183, 112, 142, 61, 139, 106, 242, 77, 205, 143, 194, 140, 38, 93, 20, 132, 2, 52, 18, 245, 16, 149, 237, 0 }, { - 255, 221, 243, 157, 134, 246, 197, 163, 230, 55, 96, 95, 130, 49, 227, 27, 147, 42, 48, 202, 45, 122, 90, 224, 53, 15, 150, 47, 94, 113, 82, 200, 215, 209, 35, 83, 73, 67, 12, 135, 216, 19, 186, 88, 189, 244, 167, 210, 174, 123, 79, 179, 138, 41, 236, 191, 184, 232, 43, 141, 39, 66, 85, 175, 102, 25, 152, 29, 128, 26, 254, 154, 64, 164, 173, 70, 10, 74, 252, 178, 250, 172, 33, 196, 170, 129, 120, 78, 65, 251, 107, 240, 108, 63, 180, 117, 40, 24, 187, 115, 144, 5, 110, 81, 69, 119, 231, 71, 198, 165, 75, 97, 17, 162, 6, 4, 58, 60, 212, 131, 32, 146, 148, 37, 248, 193, 56, 190, 222, 192, 80, 211, 218, 99, 201, 199, 46, 92, 13, 114, 50, 127, 1, 168, 208, 133, 219, 121, 109, 195, 239, 59, 207, 156, 125, 233, 8, 169, 31, 160, 103, 51, 213, 145, 253, 105, 155, 57, 44, 206, 247, 9, 11, 234, 111, 161, 14, 171, 185, 84, 116, 76, 249, 177, 28, 158, 124, 214, 104, 188, 118, 159, 151, 3, 22, 166, 241, 238, 126, 217, 89, 137, 176, 91, 225, 54, 68, 21, 204, 229, 226, 100, 7, 34, 182, 235, 62, 228, 101, 220, 203, 98, 30, 72, 136, 223, 153, 87, 23, 181, 86, 36, 183, 112, 142, 61, 139, 106, 242, 77, 205, 143, 194, 140, 38, 93, 20, 132, 2, 52, 18, 245, 16, 149, 237, 0 + 72, 201, 69, 0, 61, 170, 9, 230, 186, 34, 193, 183, 70, 218, 194, 54, 63, 246, 22, 228, 150, 232, 57, 67, 122, 197, 190, 231, 166, 165, 42, 32, 237, 13, 203, 105, 207, 103, 39, 213, 221, 3, 47, 80, 106, 182, 111, 1, 149, 157, 123, 108, 12, 18, 199, 94, 233, 38, 171, 167, 104, 98, 145, 71, 133, 40, 160, 65, 127, 115, 124, 109, 219, 196, 187, 155, 177, 101, 229, 143, 28, 64, 96, 33, 240, 60, 51, 173, 216, 19, 114, 17, 2, 189, 128, 249, 198, 159, 85, 220, 77, 92, 10, 253, 89, 88, 100, 191, 91, 37, 130, 188, 62, 242, 31, 8, 254, 181, 7, 66, 225, 148, 163, 23, 137, 21, 82, 209, 245, 119, 140, 152, 255, 73, 24, 116, 113, 176, 250, 50, 248, 146, 223, 239, 192, 99, 59, 78, 110, 211, 125, 84, 27, 55, 132, 16, 43, 14, 56, 241, 20, 184, 204, 118, 236, 121, 205, 252, 48, 53, 139, 247, 195, 36, 87, 11, 120, 126, 49, 251, 243, 35, 222, 76, 29, 52, 164, 178, 226, 168, 141, 74, 58, 144, 102, 6, 83, 235, 90, 134, 46, 107, 129, 214, 44, 117, 138, 217, 180, 238, 75, 210, 135, 185, 151, 215, 112, 79, 142, 95, 81, 174, 5, 161, 4, 131, 97, 15, 200, 25, 244, 154, 179, 175, 208, 224, 202, 212, 136, 86, 26, 162, 206, 158, 172, 234, 147, 153, 30, 68, 41, 156, 45, 227, 169, 93 }, { - 221, 210, 88, 178, 229, 239, 33, 81, 201, 136, 108, 196, 143, 63, 106, 148, 37, 145, 177, 172, 132, 213, 243, 102, 97, 232, 173, 100, 3, 235, 144, 59, 156, 76, 151, 242, 238, 154, 209, 115, 121, 237, 126, 58, 190, 13, 53, 103, 6, 188, 159, 152, 186, 248, 39, 95, 135, 67, 168, 224, 170, 7, 11, 38, 64, 25, 184, 55, 99, 31, 195, 155, 93, 153, 134, 171, 114, 149, 40, 194, 61, 181, 142, 253, 183, 216, 16, 65, 68, 164, 113, 50, 77, 193, 146, 215, 84, 120, 85, 105, 227, 199, 101, 104, 233, 51, 161, 220, 125, 231, 42, 118, 66, 27, 236, 30, 226, 110, 255, 4, 34, 176, 23, 162, 124, 214, 223, 49, 15, 122, 247, 147, 92, 207, 254, 197, 109, 5, 21, 89, 18, 140, 217, 211, 116, 9, 46, 60, 57, 86, 8, 180, 75, 107, 246, 48, 252, 222, 111, 244, 74, 69, 24, 17, 241, 150, 228, 14, 127, 230, 73, 250, 62, 56, 192, 212, 139, 225, 29, 138, 94, 41, 189, 204, 200, 129, 26, 157, 218, 71, 83, 208, 141, 234, 117, 78, 166, 191, 79, 128, 185, 82, 158, 0, 47, 131, 35, 87, 163, 54, 249, 22, 12, 133, 167, 245, 90, 203, 169, 240, 219, 174, 160, 45, 96, 98, 119, 32, 130, 80, 137, 202, 2, 28, 72, 20, 165, 70, 10, 44, 19, 123, 91, 182, 251, 1, 52, 179, 36, 206, 198, 187, 175, 112, 43, 205 + 116, 209, 232, 35, 139, 128, 105, 1, 46, 225, 255, 235, 213, 250, 51, 172, 8, 4, 169, 11, 246, 3, 125, 234, 73, 114, 245, 94, 16, 34, 22, 244, 7, 122, 37, 220, 83, 176, 217, 146, 10, 199, 54, 52, 195, 109, 66, 29, 108, 61, 74, 180, 92, 86, 12, 67, 5, 242, 18, 201, 248, 130, 149, 148, 41, 181, 33, 224, 230, 167, 0, 64, 27, 140, 100, 88, 252, 28, 200, 48, 214, 101, 63, 187, 161, 21, 24, 15, 166, 127, 228, 193, 185, 165, 43, 137, 117, 154, 49, 69, 205, 183, 93, 121, 6, 189, 240, 99, 87, 124, 222, 143, 210, 23, 55, 118, 236, 89, 206, 85, 113, 76, 239, 218, 26, 132, 157, 112, 17, 202, 150, 207, 179, 153, 226, 68, 170, 216, 57, 120, 174, 60, 141, 84, 159, 110, 197, 192, 168, 191, 115, 152, 25, 44, 156, 9, 188, 198, 62, 136, 82, 119, 50, 131, 144, 39, 253, 75, 254, 91, 45, 20, 135, 249, 173, 215, 145, 38, 96, 104, 151, 243, 72, 31, 231, 134, 19, 59, 56, 80, 40, 186, 178, 77, 147, 42, 70, 158, 194, 204, 123, 221, 241, 162, 65, 247, 171, 71, 208, 2, 36, 219, 13, 90, 79, 14, 133, 237, 30, 223, 106, 177, 111, 126, 238, 107, 233, 203, 227, 97, 102, 32, 164, 47, 251, 81, 95, 163, 98, 212, 78, 175, 160, 142, 53, 138, 190, 184, 196, 155, 182, 129, 103, 58, 211, 229 }, { 245, 210, 21, 226, 63, 197, 171, 228, 241, 86, 40, 74, 57, 65, 66, 195, 15, 88, 89, 182, 122, 134, 161, 229, 198, 193, 157, 62, 219, 246, 124, 230, 213, 127, 232, 92, 249, 115, 78, 87, 120, 99, 152, 253, 206, 147, 123, 173, 47, 167, 203, 224, 9, 94, 28, 209, 179, 72, 50, 104, 49, 12, 185, 8, 172, 237, 84, 103, 136, 168, 170, 156, 233, 58, 13, 155, 252, 239, 79, 160, 236, 29, 125, 100, 90, 166, 177, 97, 6, 22, 119, 178, 188, 18, 46, 235, 1, 26, 187, 150, 19, 23, 32, 242, 20, 38, 174, 164, 163, 118, 85, 48, 133, 200, 251, 111, 95, 116, 153, 121, 190, 98, 102, 51, 55, 7, 117, 148, 183, 202, 16, 17, 83, 71, 154, 144, 70, 3, 137, 39, 54, 204, 159, 132, 82, 208, 34, 255, 194, 199, 220, 186, 142, 181, 126, 80, 139, 45, 64, 231, 30, 75, 4, 35, 109, 67, 110, 218, 0, 205, 212, 141, 60, 184, 76, 165, 143, 41, 44, 14, 129, 33, 149, 248, 37, 189, 175, 215, 240, 196, 223, 254, 169, 130, 31, 112, 81, 43, 158, 36, 243, 27, 244, 24, 131, 135, 211, 53, 52, 101, 217, 25, 191, 77, 227, 221, 5, 138, 114, 93, 10, 180, 207, 68, 176, 216, 247, 140, 146, 225, 107, 2, 105, 59, 201, 91, 106, 192, 56, 151, 113, 238, 11, 61, 162, 214, 42, 234, 73, 250, 222, 69, 145, 96, 128, 108 diff --git a/main.cpp b/main.cpp index d85e5785..2423799a 100644 --- a/main.cpp +++ b/main.cpp @@ -197,7 +197,7 @@ HashInfo g_hashes[] = #endif { lookup3_test, 32, 0x3D83917A, "lookup3", "Bob Jenkins' lookup3", POOR }, { SuperFastHash_test, 32, 0xC4CB7C07, "superfast", "Paul Hsieh's SuperFastHash", POOR }, - { beamsplitter_64, 64, 0x044AF818, "beamsplitter", "A hash made only with S-boxes", POOR }, + { beamsplitter_64, 64, 0xAEC3D3E9, "beamsplitter", "A hash made only with S-boxes", POOR }, { MurmurOAAT_test, 32, 0x5363BD98, "MurmurOAAT", "Murmur one-at-a-time", POOR }, { Crap8_test, 32, 0x743E97A1, "Crap8", "Crap8", POOR }, { xxHash32_test, 32, 0xBA88B743, "xxHash32", "xxHash, 32-bit for x64", POOR },