diff options
author | Thomas Haller <thaller@redhat.com> | 2018-05-30 13:19:07 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-05-31 15:59:38 +0200 |
commit | b8b6100c78a039c9ae02013860b1e1a93ac1783a (patch) | |
tree | 7eb9eabb25b9328313d36a29e392bfdb982f9365 /src/systemd | |
parent | b7426e91dbcbc9080e0018a43efd0aec1f5fc5ba (diff) | |
download | NetworkManager-b8b6100c78a039c9ae02013860b1e1a93ac1783a.tar.gz |
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".
Diffstat (limited to 'src/systemd')
-rw-r--r-- | src/systemd/sd-adapt/siphash24.h | 3 | ||||
-rw-r--r-- | src/systemd/src/basic/siphash24.h | 53 |
2 files changed, 53 insertions, 3 deletions
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 <inttypes.h> +#include <stddef.h> +#include <stdint.h> +#include <sys/types.h> + +#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]); |