core: generate fixed fallback timestamp in _host_id_read_timestamp()
nm_hash_siphash42() uses a randomized seed like nm_hash*(). In this case, we want to always generate the same fake timestamp, based on the host-id. In practice, it doesn't really matter, because this is only the fallback path for something gone horribly wrong already.
This commit is contained in:
@@ -2711,7 +2711,7 @@ _host_id_read_timestamp(gboolean use_secret_key_file,
|
|||||||
|
|
||||||
#define EPOCH_TWO_YEARS (G_GINT64_CONSTANT(2 * 365 * 24 * 3600) * NM_UTILS_NSEC_PER_SEC)
|
#define EPOCH_TWO_YEARS (G_GINT64_CONSTANT(2 * 365 * 24 * 3600) * NM_UTILS_NSEC_PER_SEC)
|
||||||
|
|
||||||
v = nm_hash_siphash42(1156657133u, host_id, host_id_len);
|
v = c_siphash_hash(NM_HASH_SEED_16_U64(1156657133u), host_id, host_id_len);
|
||||||
|
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
*out_timestamp_ns =
|
*out_timestamp_ns =
|
||||||
|
@@ -56,6 +56,9 @@ void nm_hash_siphash42_init(CSipHash *h, guint static_seed);
|
|||||||
* Then, why not use c_siphash_hash() directly? Because this also uses the randomized,
|
* Then, why not use c_siphash_hash() directly? Because this also uses the randomized,
|
||||||
* per-run hash-seed like nm_hash_init(). So, you get siphash24 with a random
|
* per-run hash-seed like nm_hash_init(). So, you get siphash24 with a random
|
||||||
* seed (which is cached for the current run of the program).
|
* seed (which is cached for the current run of the program).
|
||||||
|
*
|
||||||
|
* WARNING: the static_seed gets randomized like with nm_hash*(). If you want a reproducible
|
||||||
|
* siphash42, use instead `c_siphash_hash(NM_HASH_SEED_16_U64(number), ptr, len)`.
|
||||||
*/
|
*/
|
||||||
static inline guint64
|
static inline guint64
|
||||||
nm_hash_siphash42(guint static_seed, const void *ptr, gsize n)
|
nm_hash_siphash42(guint static_seed, const void *ptr, gsize n)
|
||||||
|
Reference in New Issue
Block a user