On Wed, Mar 20, 2013 at 6:42 AM, Jan-Willem Maessen <span dir="ltr">&lt;<a href="mailto:jmaessen@alum.mit.edu" target="_blank">jmaessen@alum.mit.edu</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="gmail_quote"><div class="im">On Wed, Mar 20, 2013 at 6:02 AM, Gábor Lehel <span dir="ltr">&lt;<a href="mailto:illissius@gmail.com" target="_blank">illissius@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div dir="ltr"><div>Compatibility issues aside, is there any reason newtypes aren&#39;t a good solution here?</div></div></blockquote><div><br></div></div><div>Well, the tricky bit is that there are really two distinct uses of hashing in the field in general and under discussion here in particular.  The first (which is the one that&#39;s important for unordered-containers and almost all practical uses of hashing *within* a program) is to provide fast keys for hash tables, where the hash function is backed by equality checks and the like and is thus a question of performance rather than correctness.  For this a reasonably good, but not necessarily cryptographically secure, hashing method is more than sufficient.</div>

</div></blockquote><div><br></div><div>hashable is definitely defined for this use case. Unfortunately there&#39;s a class of DsS attacks (hash flooding) that work like this:</div><div><br></div><div>1. The application (e.g. a webserver) stores some user input in a hash table (e.g. the HTTP headers received in the request).</div>

<div>2. The application uses a weak hash function (i.e. a non-cryptographic hash function) in the hash table.</div><div>3. The user feeds the application a set of keys that all collide, making the hash table behave as O(n) or even O(n^2), thereby DoS:ing the server.</div>

<div><br></div><div>SipHash is one way to address these kinds of attacks. There are other means as well. For example, many general DoS protection mechanisms (timeouts, IP banning, etc) also work on these kind of attacks.</div>

<div><br></div><div>-- Johan</div><div><br></div></div>