Tor 0.4.9.2-alpha-dev
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
siphash.h
1/* Copyright (c) 2020 tevador <tevador@gmail.com> */
2/* See LICENSE for licensing information */
3
4#ifndef SIPHASH_H
5#define SIPHASH_H
6
7#include <stdint.h>
8#include <hashx.h>
9
10#define ROTL(x, b) (((x) << (b)) | ((x) >> (64 - (b))))
11#define SIPROUND(v0, v1, v2, v3) \
12 do { \
13 v0 += v1; v2 += v3; v1 = ROTL(v1, 13); \
14 v3 = ROTL(v3, 16); v1 ^= v0; v3 ^= v2; \
15 v0 = ROTL(v0, 32); v2 += v1; v0 += v3; \
16 v1 = ROTL(v1, 17); v3 = ROTL(v3, 21); \
17 v1 ^= v2; v3 ^= v0; v2 = ROTL(v2, 32); \
18 } while (0)
19
20typedef struct siphash_state {
21 uint64_t v0, v1, v2, v3;
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28HASHX_PRIVATE uint64_t hashx_siphash13_ctr(uint64_t input, const siphash_state* keys);
29HASHX_PRIVATE void hashx_siphash24_ctr_state512(const siphash_state* keys, uint64_t input, uint64_t state_out[8]);
30
31#ifdef __cplusplus
32}
33#endif
34
35#endif