]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
csiphash: Add functions to take a global key.
authorNick Mathewson <nickm@torproject.org>
Wed, 12 Feb 2014 16:27:03 +0000 (11:27 -0500)
committerNick Mathewson <nickm@torproject.org>
Wed, 12 Feb 2014 16:27:41 +0000 (11:27 -0500)
src/ext/csiphash.c
src/ext/siphash.h

index 2f37a5f22419c59b365c88f7362e147c8ae4818f..9a8833d104f2fc1daa8abd605b6574db21c101ef 100644 (file)
@@ -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;
+}
index ff372bc5d4b74e6d63a7cb76aaa7d65015ebbee9..964fe7df995e798ac8da330ae6f939e88d1bab1d 100644 (file)
@@ -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