From: Ryan Lortie Date: Wed, 25 Jan 2012 15:09:09 +0000 (-0500) Subject: GHash: add note about randomness in hashing X-Git-Tag: 2.31.14~38 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=12060df9f17a48cd4c7fda27a0af70c17c308ad9;p=platform%2Fupstream%2Fglib.git GHash: add note about randomness in hashing To clarify our statements about being robust against outside attackers degrading the performance of your hashtable. --- diff --git a/glib/ghash.c b/glib/ghash.c index 92c16c9..b058d17 100644 --- a/glib/ghash.c +++ b/glib/ghash.c @@ -165,6 +165,11 @@ * Using g_str_hash() in that situation might make your application * vulerable to Algorithmic Complexity Attacks. * + * The key to choosing a good hash is unpredictability. Even + * cryptographic hashes are very easy to find collisions for when the + * remainder is taken modulo a somewhat predictable prime number. There + * must be an element of randomness that an attacker is unable to guess. + * * Returns: the hash value corresponding to the key */