[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Get csiphash better integrated with our build system
commit 9605978eb6225a67f0682f6de990278644f8ea38
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Wed Feb 12 10:24:04 2014 -0500
Get csiphash better integrated with our build system
---
src/common/include.am | 1 +
src/ext/csiphash.c | 16 +++++++++-------
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 814786b..d0ea40e 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 0633977..5df41d7 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 ea7e58e..26e194e 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)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits