diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-02-12 10:24:04 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-02-12 10:24:04 -0500 |
commit | 9605978eb6225a67f0682f6de990278644f8ea38 (patch) | |
tree | 8b941db7bf9f6cb82b761e612bad1ecc0ecdbcde /src | |
parent | f4656c0cc9c13d3ba9d069f97771e98f160a87f8 (diff) | |
download | tor-9605978eb6225a67f0682f6de990278644f8ea38.tar tor-9605978eb6225a67f0682f6de990278644f8ea38.tar.gz |
Get csiphash better integrated with our build system
Diffstat (limited to 'src')
-rw-r--r-- | src/common/include.am | 1 | ||||
-rw-r--r-- | src/ext/csiphash.c | 16 | ||||
-rw-r--r-- | src/ext/include.am | 3 |
3 files changed, 12 insertions, 8 deletions
diff --git a/src/common/include.am b/src/common/include.am index 814786b77..d0ea40ea6 100644 --- a/src/common/include.am +++ b/src/common/include.am @@ -61,6 +61,7 @@ LIBOR_A_SOURCES = \ src/common/util.c \ src/common/util_codedigest.c \ src/common/sandbox.c \ + src/ext/csiphash.c \ $(libor_extra_source) LIBOR_CRYPTO_A_SOURCES = \ 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) |