Lines Matching +full:key +full:- +full:2

1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
2 /* Copyright (C) 2016-2022 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
4 * SipHash: a fast short-input PRF
7 * This implementation is specifically for SipHash2-4 for a secure PRF
8 * and HalfSipHash1-3/SipHash1-3 for an insecure PRF only suitable for
17 #include <asm/word-at-a-time.h>
28 v3 ^= key->key[1]; \
29 v2 ^= key->key[0]; \
30 v1 ^= key->key[1]; \
31 v0 ^= key->key[0];
46 u64 __siphash_aligned(const void *data, size_t len, const siphash_key_t *key) in __siphash_aligned() argument
48 const u8 *end = data + len - (len % sizeof(u64)); in __siphash_aligned()
49 const u8 left = len & (sizeof(u64) - 1); in __siphash_aligned()
69 case 3: b |= ((u64)end[2]) << 16; fallthrough; in __siphash_aligned()
70 case 2: b |= le16_to_cpup(data); break; in __siphash_aligned()
79 u64 __siphash_unaligned(const void *data, size_t len, const siphash_key_t *key) in __siphash_unaligned() argument
81 const u8 *end = data + len - (len % sizeof(u64)); in __siphash_unaligned()
82 const u8 left = len & (sizeof(u64) - 1); in __siphash_unaligned()
102 case 3: b |= ((u64)end[2]) << 16; fallthrough; in __siphash_unaligned()
103 case 2: b |= get_unaligned_le16(end); break; in __siphash_unaligned()
112 * siphash_1u64 - compute 64-bit siphash PRF value of a u64
114 * @key: the siphash key
116 u64 siphash_1u64(const u64 first, const siphash_key_t *key) in siphash_1u64() argument
128 * siphash_2u64 - compute 64-bit siphash PRF value of 2 u64
131 * @key: the siphash key
133 u64 siphash_2u64(const u64 first, const u64 second, const siphash_key_t *key) in siphash_2u64() argument
149 * siphash_3u64 - compute 64-bit siphash PRF value of 3 u64
153 * @key: the siphash key
156 const siphash_key_t *key) in siphash_3u64() argument
176 * siphash_4u64 - compute 64-bit siphash PRF value of 4 u64
181 * @key: the siphash key
184 const u64 forth, const siphash_key_t *key) in siphash_4u64() argument
207 u64 siphash_1u32(const u32 first, const siphash_key_t *key) in siphash_1u32() argument
216 const siphash_key_t *key) in siphash_3u32() argument
230 /* Note that on 64-bit, we make HalfSipHash1-3 actually be SipHash1-3, for
231 * performance reasons. On 32-bit, below, we actually implement HalfSipHash1-3.
247 u32 __hsiphash_aligned(const void *data, size_t len, const hsiphash_key_t *key) in __hsiphash_aligned() argument
249 const u8 *end = data + len - (len % sizeof(u64)); in __hsiphash_aligned()
250 const u8 left = len & (sizeof(u64) - 1); in __hsiphash_aligned()
269 case 3: b |= ((u64)end[2]) << 16; fallthrough; in __hsiphash_aligned()
270 case 2: b |= le16_to_cpup(data); break; in __hsiphash_aligned()
280 const hsiphash_key_t *key) in __hsiphash_unaligned() argument
282 const u8 *end = data + len - (len % sizeof(u64)); in __hsiphash_unaligned()
283 const u8 left = len & (sizeof(u64) - 1); in __hsiphash_unaligned()
302 case 3: b |= ((u64)end[2]) << 16; fallthrough; in __hsiphash_unaligned()
303 case 2: b |= get_unaligned_le16(end); break; in __hsiphash_unaligned()
312 * hsiphash_1u32 - compute 64-bit hsiphash PRF value of a u32
314 * @key: the hsiphash key
316 u32 hsiphash_1u32(const u32 first, const hsiphash_key_t *key) in hsiphash_1u32() argument
325 * hsiphash_2u32 - compute 32-bit hsiphash PRF value of 2 u32
328 * @key: the hsiphash key
330 u32 hsiphash_2u32(const u32 first, const u32 second, const hsiphash_key_t *key) in hsiphash_2u32() argument
342 * hsiphash_3u32 - compute 32-bit hsiphash PRF value of 3 u32
346 * @key: the hsiphash key
349 const hsiphash_key_t *key) in hsiphash_3u32() argument
362 * hsiphash_4u32 - compute 32-bit hsiphash PRF value of 4 u32
367 * @key: the hsiphash key
370 const u32 forth, const hsiphash_key_t *key) in hsiphash_4u32() argument
393 v3 ^= key->key[1]; \
394 v2 ^= key->key[0]; \
395 v1 ^= key->key[1]; \
396 v0 ^= key->key[0];
409 u32 __hsiphash_aligned(const void *data, size_t len, const hsiphash_key_t *key) in __hsiphash_aligned() argument
411 const u8 *end = data + len - (len % sizeof(u32)); in __hsiphash_aligned()
412 const u8 left = len & (sizeof(u32) - 1); in __hsiphash_aligned()
422 case 3: b |= ((u32)end[2]) << 16; fallthrough; in __hsiphash_aligned()
423 case 2: b |= le16_to_cpup(data); break; in __hsiphash_aligned()
432 const hsiphash_key_t *key) in __hsiphash_unaligned() argument
434 const u8 *end = data + len - (len % sizeof(u32)); in __hsiphash_unaligned()
435 const u8 left = len & (sizeof(u32) - 1); in __hsiphash_unaligned()
445 case 3: b |= ((u32)end[2]) << 16; fallthrough; in __hsiphash_unaligned()
446 case 2: b |= get_unaligned_le16(end); break; in __hsiphash_unaligned()
454 * hsiphash_1u32 - compute 32-bit hsiphash PRF value of a u32
456 * @key: the hsiphash key
458 u32 hsiphash_1u32(const u32 first, const hsiphash_key_t *key) in hsiphash_1u32() argument
469 * hsiphash_2u32 - compute 32-bit hsiphash PRF value of 2 u32
472 * @key: the hsiphash key
474 u32 hsiphash_2u32(const u32 first, const u32 second, const hsiphash_key_t *key) in hsiphash_2u32() argument
488 * hsiphash_3u32 - compute 32-bit hsiphash PRF value of 3 u32
492 * @key: the hsiphash key
495 const hsiphash_key_t *key) in hsiphash_3u32() argument
512 * hsiphash_4u32 - compute 32-bit hsiphash PRF value of 4 u32
517 * @key: the hsiphash key
520 const u32 forth, const hsiphash_key_t *key) in hsiphash_4u32() argument