diff options
| author | Michael Biebl <biebl@debian.org> | 2018-09-08 17:44:52 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2018-09-08 17:44:52 +0200 |
| commit | d8cad4490d54acb162ad218a8a682ab379bb8bcc (patch) | |
| tree | 140abd545d62a1b0144be27c93ad8edb021e4311 /shared/nm-utils/nm-hash-utils.h | |
| parent | e3bc109cd0eb97346c448f591af518d85dbee21b (diff) | |
| parent | 8f7a3cbbdd0c0a48277c341dd3a8ec8743ae9735 (diff) | |
Update upstream source from tag 'upstream/1.13.90'
Update to upstream version '1.13.90' with Debian dir d7d3d98e1240df49343a72511602da7099232e10
Diffstat (limited to 'shared/nm-utils/nm-hash-utils.h')
| -rw-r--r-- | shared/nm-utils/nm-hash-utils.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/shared/nm-utils/nm-hash-utils.h b/shared/nm-utils/nm-hash-utils.h index b7742e0f..b797fb75 100644 --- a/shared/nm-utils/nm-hash-utils.h +++ b/shared/nm-utils/nm-hash-utils.h @@ -57,6 +57,11 @@ nm_hash_update (NMHashState *state, const void *ptr, gsize n) nm_assert (ptr); nm_assert (n > 0); + /* Note: the data passed in here might be sensitive data (secrets), + * that we should nm_explicty_zero() afterwards. However, since + * we are using siphash24 with a random key, that is not really + * necessary. Something to keep in mind, if we ever move away from + * this hash implementation. */ c_siphash_append (&state->_state, ptr, n); } @@ -168,7 +173,7 @@ nm_hash_update_mem (NMHashState *state, const void *ptr, gsize n) * instead. */ nm_hash_update (state, &n, sizeof (n)); if (n > 0) - c_siphash_append (&state->_state, ptr, n); + nm_hash_update (state, ptr, n); } static inline void @@ -209,6 +214,15 @@ guint nm_direct_hash (gconstpointer str); guint nm_hash_str (const char *str); guint nm_str_hash (gconstpointer str); +#define nm_hash_val(static_seed, val) \ + ({ \ + NMHashState _h; \ + \ + nm_hash_init (&_h, static_seed); \ + nm_hash_update_val (&_h, val); \ + nm_hash_complete (&_h); \ + }) + /*****************************************************************************/ /* nm_pstr_*() are for hashing keys that are pointers to strings, |