Line data Source code
1 : #pragma once 2 : 3 : #include <inttypes.h> 4 : #include <stddef.h> 5 : #include <stdint.h> 6 : #include <string.h> 7 : #include <sys/types.h> 8 : 9 : struct siphash { 10 : uint64_t v0; 11 : uint64_t v1; 12 : uint64_t v2; 13 : uint64_t v3; 14 : uint64_t padding; 15 : size_t inlen; 16 : }; 17 : 18 : void siphash24_init(struct siphash *state, const uint8_t k[static 16]); 19 : void siphash24_compress(const void *in, size_t inlen, struct siphash *state); 20 : void siphash24_compress_boolean(bool in, struct siphash *state); 21 : #define siphash24_compress_byte(byte, state) siphash24_compress((const uint8_t[]) { (byte) }, 1, (state)) 22 : 23 : uint64_t siphash24_finalize(struct siphash *state); 24 : 25 : uint64_t siphash24(const void *in, size_t inlen, const uint8_t k[static 16]); 26 : 27 0 : static inline uint64_t siphash24_string(const char *s, const uint8_t k[static 16]) { 28 0 : return siphash24(s, strlen(s) + 1, k); 29 : }