]>
Commit | Line | Data |
---|---|---|
1 | /* SPDX-License-Identifier: CC0-1.0 */ | |
2 | ||
3 | #pragma once | |
4 | ||
5 | #include "forward.h" | |
6 | ||
7 | struct siphash { | |
8 | uint64_t v0; | |
9 | uint64_t v1; | |
10 | uint64_t v2; | |
11 | uint64_t v3; | |
12 | uint64_t padding; | |
13 | size_t inlen; | |
14 | }; | |
15 | ||
16 | void siphash24_init(struct siphash *state, const uint8_t k[static 16]); | |
17 | void siphash24_compress(const void *in, size_t inlen, struct siphash *state); | |
18 | #define siphash24_compress_byte(byte, state) siphash24_compress((const uint8_t[]) { (byte) }, 1, (state)) | |
19 | #define siphash24_compress_typesafe(in, state) \ | |
20 | siphash24_compress(&(in), sizeof(typeof(in)), (state)) | |
21 | ||
22 | static inline void siphash24_compress_boolean(bool in, struct siphash *state) { | |
23 | siphash24_compress_byte(in, state); | |
24 | } | |
25 | ||
26 | static inline void siphash24_compress_usec_t(usec_t in, struct siphash *state) { | |
27 | uint64_t u = htole64(in); | |
28 | siphash24_compress_typesafe(u, state); | |
29 | } | |
30 | ||
31 | static inline void siphash24_compress_safe(const void *in, size_t inlen, struct siphash *state) { | |
32 | if (inlen == 0) | |
33 | return; | |
34 | ||
35 | siphash24_compress(in, inlen, state); | |
36 | } | |
37 | ||
38 | void siphash24_compress_string(const char *in, struct siphash *state); | |
39 | ||
40 | uint64_t siphash24_finalize(struct siphash *state); | |
41 | ||
42 | uint64_t siphash24(const void *in, size_t inlen, const uint8_t k[static 16]); | |
43 | ||
44 | uint64_t siphash24_string(const char *s, const uint8_t k[static 16]); |