From b8b6100c78a039c9ae02013860b1e1a93ac1783a Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 30 May 2018 13:19:07 +0200 Subject: all: replace systemd's siphash24 with c-siphash Originally, we used "nm-utils/siphash24.c", which was copied from systemd's source tree. It was both used by our own NetworkManager code, and by our internal systemd fork. Then, we added "shared/c-siphash" as a dependency for n-acd. Now, drop systemd's implementation and use c-siphash also for our internal purpose. Also, let systemd code use c-siphash, by patching "src/systemd/src/basic/siphash24.h". --- src/systemd/sd-adapt/siphash24.h | 3 --- src/systemd/src/basic/siphash24.h | 53 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 3 deletions(-) delete mode 100644 src/systemd/sd-adapt/siphash24.h create mode 100644 src/systemd/src/basic/siphash24.h (limited to 'src/systemd') diff --git a/src/systemd/sd-adapt/siphash24.h b/src/systemd/sd-adapt/siphash24.h deleted file mode 100644 index ac6e5a1d13..0000000000 --- a/src/systemd/sd-adapt/siphash24.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -#include "nm-utils/siphash24.h" diff --git a/src/systemd/src/basic/siphash24.h b/src/systemd/src/basic/siphash24.h new file mode 100644 index 0000000000..77bb9a8c07 --- /dev/null +++ b/src/systemd/src/basic/siphash24.h @@ -0,0 +1,53 @@ +#pragma once + +#include +#include +#include +#include + +#if 0 /* NM_IGNORED */ +struct siphash { + uint64_t v0; + uint64_t v1; + uint64_t v2; + uint64_t v3; + uint64_t padding; + size_t inlen; +}; +#else /* NM_IGNORED */ +struct siphash { + CSipHash _csiphash; +}; + +static inline void +siphash24_init (struct siphash *state, const uint8_t k[16]) +{ + c_siphash_init ((CSipHash *) state, k); +} + +static inline void +siphash24_compress (const void *in, size_t inlen, struct siphash *state) +{ + c_siphash_append ((CSipHash *) state, in, inlen); +} + +static inline uint64_t +siphash24_finalize (struct siphash *state) +{ + return c_siphash_finalize ((CSipHash *) state); +} + +static inline uint64_t +siphash24 (const void *in, size_t inlen, const uint8_t k[16]) +{ + return c_siphash_hash (k, in, inlen); +} +#endif /* NM_IGNORED */ + +void siphash24_init(struct siphash *state, const uint8_t k[16]); +void siphash24_compress(const void *in, size_t inlen, struct siphash *state); +#define siphash24_compress_byte(byte, state) siphash24_compress((const uint8_t[]) { (byte) }, 1, (state)) + +uint64_t siphash24_finalize(struct siphash *state); + +uint64_t siphash24(const void *in, size_t inlen, const uint8_t k[16]); -- cgit v1.2.1