about summary refs log tree commit diff
path: root/shared/nm-utils/nm-hash-utils.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2018-06-04 00:08:31 +0200
committerMichael Biebl <biebl@debian.org>2018-06-04 00:08:31 +0200
commit0dd9df69fdbd475c48a0c8d5b0a1882550fe7321 (patch)
tree249cf25643b1fe408e10679bb61613bc6540e894 /shared/nm-utils/nm-hash-utils.c
parent2e94a3b93171ab3fb95bf689aab1664d23988809 (diff)
parent04bc9e1cd3544445d883ad29ea108c1645c8e7b7 (diff)
Update upstream source from tag 'upstream/1.11.4'
Update to upstream version '1.11.4'
with Debian dir d0638aa2e32d5bae4e8daa021b9a66b7c4d6647e
Diffstat (limited to 'shared/nm-utils/nm-hash-utils.c')
-rw-r--r--shared/nm-utils/nm-hash-utils.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/shared/nm-utils/nm-hash-utils.c b/shared/nm-utils/nm-hash-utils.c
index 8d8c21ce..4bc12b7c 100644
--- a/shared/nm-utils/nm-hash-utils.c
+++ b/shared/nm-utils/nm-hash-utils.c
@@ -28,8 +28,6 @@
 #include "nm-shared-utils.h"
 #include "nm-random-utils.h"
 
-#include "siphash24.c"
-
 /*****************************************************************************/
 
 #define HASH_KEY_SIZE 16u
@@ -49,7 +47,7 @@ _get_hash_key_init (void)
 	} g_arr _nm_alignas (guint64);
 	static gsize g_lock;
 	const guint8 *g;
-	struct siphash siph_state;
+	CSipHash siph_state;
 	uint64_t h;
 	guint *p;
 
@@ -66,9 +64,9 @@ _get_hash_key_init (void)
 		/* use siphash() of the key-size, to mangle the first guint. Otherwise,
 		 * the first guint has only the entropy that nm_utils_random_bytes()
 		 * generated for the first 4 bytes and relies on a good random generator. */
-		siphash24_init (&siph_state, g_arr.v8);
-		siphash24_compress (g_arr.v8, sizeof (g_arr.v8), &siph_state);
-		h = siphash24_finalize (&siph_state);
+		c_siphash_init (&siph_state, g_arr.v8);
+		c_siphash_append (&siph_state, g_arr.v8, sizeof (g_arr.v8));
+		h = c_siphash_finalize (&siph_state);
 		p = (guint *) g_arr.v8;
 		if (sizeof (guint) < sizeof (h))
 			*p = *p ^ ((guint) (h & 0xFFFFFFFFu)) ^ ((guint) (h >> 32));
@@ -97,10 +95,10 @@ guint
 nm_hash_static (guint static_seed)
 {
 	/* note that we only xor the static_seed with the key.
-	 * We don't use siphash24(), which would mix the bits better.
+	 * We don't use siphash, which would mix the bits better.
 	 * Note that this doesn't matter, because static_seed is not
 	 * supposed to be a value that you are hashing (for that, use
-	 * full siphash24()).
+	 * full siphash).
 	 * Instead, different callers may set a different static_seed
 	 * so that nm_hash_str(NULL) != nm_hash_ptr(NULL).
 	 *
@@ -121,7 +119,7 @@ nm_hash_init (NMHashState *state, guint static_seed)
 	g = _get_hash_key ();
 	memcpy (seed, g, HASH_KEY_SIZE);
 	seed[0] ^= static_seed;
-	siphash24_init (&state->_state, (const guint8 *) seed);
+	c_siphash_init (&state->_state, (const guint8 *) seed);
 }
 
 guint