[cfe-dev] [libc++] Initial attempt to make a salted hash

Zhihao Yuan zy at miator.net
Fri Aug 30 10:58:20 PDT 2013


Hi,

Modern programming languages with built-in hash table
support usually has some mechanism to fight against
hash collision attack (DoS, use massive prepared input
with same hash code to slow down the service; the
problem is more severe in C++ since the unordered
containers use seperate chaining instead of open
addressing).  For example, Perl uses universal hashing,
Python3 uses salted hash.

Here is an initial attempt to implement a salted hash in
libc++, by using an unpredictable seed in
__murmur2_or_cityhash across the lifetime of a program,
and an simple demonstration -- if you run it multiple
times, the order of the elements within an unordered
container may change.

-- 
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://4bsd.biz/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: salted_hash.patch
Type: application/octet-stream
Size: 2409 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130830/9bc27677/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: demo.cc
Type: application/octet-stream
Size: 184 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130830/9bc27677/attachment-0001.obj>


More information about the cfe-dev mailing list