mirror of
https://github.com/systemd/systemd.git
synced 2024-11-08 02:57:16 +03:00
siphash24: split out the finalization step
This commit is contained in:
parent
708684ef22
commit
9e77e048d4
@ -72,6 +72,16 @@ static void siphash_init(struct siphash *state, const uint8_t k[16]) {
|
|||||||
state->v3 = 0x7465646279746573ULL ^ k1;
|
state->v3 = 0x7465646279746573ULL ^ k1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static u64 siphash24_finalize(struct siphash *state) {
|
||||||
|
state->v2 ^= 0xff;
|
||||||
|
SIPROUND(state);
|
||||||
|
SIPROUND(state);
|
||||||
|
SIPROUND(state);
|
||||||
|
SIPROUND(state);
|
||||||
|
|
||||||
|
return state->v0 ^ state->v1 ^ state->v2 ^ state->v3;
|
||||||
|
}
|
||||||
|
|
||||||
/* SipHash-2-4 */
|
/* SipHash-2-4 */
|
||||||
void siphash24(uint8_t out[8], const void *_in, size_t inlen, const uint8_t k[16])
|
void siphash24(uint8_t out[8], const void *_in, size_t inlen, const uint8_t k[16])
|
||||||
{
|
{
|
||||||
@ -137,11 +147,8 @@ void siphash24(uint8_t out[8], const void *_in, size_t inlen, const uint8_t k[16
|
|||||||
printf( "(%3d) v2 %08x %08x\n", ( int )inlen, ( u32 )( state.v2 >> 32 ), ( u32 )state.v2 );
|
printf( "(%3d) v2 %08x %08x\n", ( int )inlen, ( u32 )( state.v2 >> 32 ), ( u32 )state.v2 );
|
||||||
printf( "(%3d) v3 %08x %08x\n", ( int )inlen, ( u32 )( state.v3 >> 32 ), ( u32 )state.v3 );
|
printf( "(%3d) v3 %08x %08x\n", ( int )inlen, ( u32 )( state.v3 >> 32 ), ( u32 )state.v3 );
|
||||||
#endif
|
#endif
|
||||||
state.v2 ^= 0xff;
|
|
||||||
SIPROUND(&state);
|
b = siphash24_finalize(&state);
|
||||||
SIPROUND(&state);
|
|
||||||
SIPROUND(&state);
|
|
||||||
SIPROUND(&state);
|
|
||||||
b = state.v0 ^ state.v1 ^ state.v2 ^ state.v3;
|
|
||||||
U64TO8_LE( out, b );
|
U64TO8_LE( out, b );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user