]>
Commit | Line | Data |
---|---|---|
9bf3b535 LP |
1 | #pragma once |
2 | ||
3 | #include <inttypes.h> | |
11c3a366 TA |
4 | #include <stddef.h> |
5 | #include <stdint.h> | |
a53f90ca | 6 | #include <string.h> |
9bf3b535 LP |
7 | #include <sys/types.h> |
8 | ||
7c57f504 | 9 | struct siphash { |
6059dab8 LP |
10 | uint64_t v0; |
11 | uint64_t v1; | |
12 | uint64_t v2; | |
13 | uint64_t v3; | |
14 | uint64_t padding; | |
15 | size_t inlen; | |
7c57f504 TG |
16 | }; |
17 | ||
3042bbeb | 18 | void siphash24_init(struct siphash *state, const uint8_t k[static 16]); |
7c57f504 | 19 | void siphash24_compress(const void *in, size_t inlen, struct siphash *state); |
d5115566 LP |
20 | #define siphash24_compress_byte(byte, state) siphash24_compress((const uint8_t[]) { (byte) }, 1, (state)) |
21 | ||
6c04fccb YW |
22 | static inline void siphash24_compress_boolean(bool in, struct siphash *state) { |
23 | uint8_t i = in; | |
24 | ||
25 | siphash24_compress(&i, sizeof i, state); | |
26 | } | |
27 | ||
933f9cae | 28 | uint64_t siphash24_finalize(struct siphash *state); |
7c57f504 | 29 | |
3042bbeb | 30 | uint64_t siphash24(const void *in, size_t inlen, const uint8_t k[static 16]); |
a53f90ca | 31 | |
3042bbeb | 32 | static inline uint64_t siphash24_string(const char *s, const uint8_t k[static 16]) { |
a53f90ca LP |
33 | return siphash24(s, strlen(s) + 1, k); |
34 | } |