aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-02-12 11:27:03 -0500
committerNick Mathewson <nickm@torproject.org>2014-02-12 11:27:41 -0500
commitf05820531a1e4bc5935609900f0067b2643f0529 (patch)
treefacedda3318793bd1b5ec3c73fc60080dba5fe29
parentf51df9bb93f889533e7480e6364899ce249fe45b (diff)
downloadtor-f05820531a1e4bc5935609900f0067b2643f0529.tar
tor-f05820531a1e4bc5935609900f0067b2643f0529.tar.gz
csiphash: Add functions to take a global key.
-rw-r--r--src/ext/csiphash.c14
-rw-r--r--src/ext/siphash.h3
2 files changed, 17 insertions, 0 deletions
diff --git a/src/ext/csiphash.c b/src/ext/csiphash.c
index 2f37a5f22..9a8833d10 100644
--- a/src/ext/csiphash.c
+++ b/src/ext/csiphash.c
@@ -132,3 +132,17 @@ uint64_t siphash24(const void *src, unsigned long src_sz, const struct sipkey *k
return (v0 ^ v1) ^ (v2 ^ v3);
}
+
+static int the_siphash_key_is_set = 0;
+static struct sipkey the_siphash_key;
+
+uint64_t siphash24g(const void *src, unsigned long src_sz) {
+ return siphash24(src, src_sz, &the_siphash_key);
+}
+
+void siphash_set_global_key(const struct sipkey *key)
+{
+ the_siphash_key.k0 = key->k0;
+ the_siphash_key.k1 = key->k1;
+ the_siphash_key_is_set = 1;
+}
diff --git a/src/ext/siphash.h b/src/ext/siphash.h
index ff372bc5d..964fe7df9 100644
--- a/src/ext/siphash.h
+++ b/src/ext/siphash.h
@@ -6,4 +6,7 @@ struct sipkey {
};
uint64_t siphash24(const void *src, unsigned long src_sz, const struct sipkey *key);
+void siphash_set_global_key(const struct sipkey *key);
+uint64_t siphash24g(const void *src, unsigned long src_sz);
+
#endif