diff options
Diffstat (limited to 'src/ext')
-rw-r--r-- | src/ext/csiphash.c | 16 | ||||
-rw-r--r-- | src/ext/include.am | 3 |
2 files changed, 11 insertions, 8 deletions
diff --git a/src/ext/csiphash.c b/src/ext/csiphash.c index 0633977f9..5df41d71f 100644 --- a/src/ext/csiphash.c +++ b/src/ext/csiphash.c @@ -29,7 +29,8 @@ Jean-Philippe Aumasson (https://131002.net/siphash/siphash24.c) */ -#include <stdint.h> +#include "torint.h" +#include "siphash.h" #if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \ __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ @@ -58,7 +59,6 @@ #endif - #define ROTATE(x, b) (uint64_t)( ((x) << (b)) | ( (x) >> (64 - (b))) ) #define HALF_ROUND(a,b,c,d,s,t) \ @@ -74,13 +74,15 @@ HALF_ROUND(v2,v1,v0,v3,17,21); -uint64_t siphash24(const void *src, unsigned long src_sz, const char key[16]) { - const uint64_t *_key = (uint64_t *)key; - uint64_t k0 = _le64toh(_key[0]); - uint64_t k1 = _le64toh(_key[1]); +uint64_t siphash24(const void *src, unsigned long src_sz, const struct sipkey *key) { + uint64_t k0 = key->k0; + uint64_t k1 = key->k1; uint64_t b = (uint64_t)src_sz << 56; const uint64_t *in = (uint64_t*)src; + uint64_t t; + uint8_t *pt, *m; + uint64_t v0 = k0 ^ 0x736f6d6570736575ULL; uint64_t v1 = k1 ^ 0x646f72616e646f6dULL; uint64_t v2 = k0 ^ 0x6c7967656e657261ULL; @@ -94,7 +96,7 @@ uint64_t siphash24(const void *src, unsigned long src_sz, const char key[16]) { v0 ^= mi; } - uint64_t t = 0; uint8_t *pt = (uint8_t *)&t; uint8_t *m = (uint8_t *)in; + t = 0; pt = (uint8_t*)&t; m = (uint8_t*)in; switch (src_sz) { case 7: pt[6] = m[6]; case 6: pt[5] = m[5]; diff --git a/src/ext/include.am b/src/ext/include.am index ea7e58e79..26e194e88 100644 --- a/src/ext/include.am +++ b/src/ext/include.am @@ -10,7 +10,8 @@ EXTHEADERS = \ src/ext/strlcat.c \ src/ext/strlcpy.c \ src/ext/tinytest_macros.h \ - src/ext/tor_queue.h + src/ext/tor_queue.h \ + src/ext/siphash.h noinst_HEADERS+= $(EXTHEADERS) |