From 6d8e48a1e98fb285f16052be585fdf8005a76473 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 24 May 2022 20:41:58 +0200 Subject: -modify mingling to preserve less structure, breaks protocol slightly... --- src/block/block.c | 37 +++++++++++++++++++++++++++++-------- src/util/container_bloomfilter.c | 9 +++++---- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/src/block/block.c b/src/block/block.c index 2e3c1dc70..98095b51c 100644 --- a/src/block/block.c +++ b/src/block/block.c @@ -70,19 +70,40 @@ struct GNUNET_BLOCK_Context }; +GNUNET_NETWORK_STRUCT_BEGIN + + +/** + * Serialization to use in #GNUNET_BLOCK_mingle_hash. + */ +struct MinglePacker +{ + /** + * Original hash. + */ + struct GNUNET_HashCode in; + + /** + * Mingle value. + */ + uint32_t mingle GNUNET_PACKED; +}; + +GNUNET_NETWORK_STRUCT_END + void GNUNET_BLOCK_mingle_hash (const struct GNUNET_HashCode *in, uint32_t mingle_number, struct GNUNET_HashCode *hc) { - struct GNUNET_HashCode m; - - GNUNET_CRYPTO_hash (&mingle_number, - sizeof(uint32_t), - &m); - GNUNET_CRYPTO_hash_xor (&m, - in, - hc); + struct MinglePacker mp = { + .in = *in, + .mingle = mingle_number + }; + + GNUNET_CRYPTO_hash (&mp, + sizeof(mp), + hc); } diff --git a/src/util/container_bloomfilter.c b/src/util/container_bloomfilter.c index d89b46252..8a0487e04 100644 --- a/src/util/container_bloomfilter.c +++ b/src/util/container_bloomfilter.c @@ -358,11 +358,12 @@ make_empty_file (const struct GNUNET_DISK_FileHandle *fh, size_t size) * @param cls closure * @param bf the filter to manipulate * @param bit the current bit - * @return GNUNET_YES to continue, GNUNET_NO to stop early + * @return #GNUNET_YES to continue, #GNUNET_NO to stop early */ -typedef int (*BitIterator) (void *cls, - const struct GNUNET_CONTAINER_BloomFilter *bf, - unsigned int bit); +typedef int +(*BitIterator) (void *cls, + const struct GNUNET_CONTAINER_BloomFilter *bf, + unsigned int bit); /** -- cgit v1.2.3