AES Hash from Go

881 views
Skip to first unread message

Tahir

unread,
Sep 23, 2014, 12:33:03 PM9/23/14
to golan...@googlegroups.com
Hi All,

Might be a stupid question but I am playing around trying to implement some data structures and need a hashing algorithm.  Needs to be a little bit secure so as to mitigate DoS by abusing collisions. 

I am just wondering if there is a way to have access to the one that is used internally ?

Cheers,

T.

Tahir

unread,
Sep 23, 2014, 12:49:56 PM9/23/14
to golan...@googlegroups.com
(the hash pkg has only FNV, I could probably look into a Go Siphash implementation if there is no easy way to call the aes hash function from Go for now)

Skip Tavakkolian

unread,
Sep 23, 2014, 2:22:18 PM9/23/14
to Tahir, golang-nuts
wouldn't sha256 work?

btw, do you have a reference for AES-hash? the closest i've found appears to use another hash function -- Davies–Meyer -- to generate the symmetric key and a last block for the AES block cipher:


is this a standard?


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Steve McCoy

unread,
Sep 23, 2014, 2:34:01 PM9/23/14
to golan...@googlegroups.com
I'm not sure what you're asking for, because AES isn't a hash function and doesn't make a particularly good basis for one, either: http://security.stackexchange.com/questions/8048/why-aes-is-not-used-for-secure-hashing-instead-of-sha-x

Here's a siphash package: https://github.com/dchest/siphash

Tahir

unread,
Sep 23, 2014, 2:40:27 PM9/23/14
to golan...@googlegroups.com, welcometot...@gmail.com


On Tuesday, September 23, 2014 7:22:18 PM UTC+1, Skip wrote:
wouldn't sha256 work?


I don't think it would. sha256 is probably going to be too slow.
 
btw, do you have a reference for AES-hash? the closest i've found appears to use another hash function -- Davies–Meyer -- to generate the symmetric key and a last block for the AES block cipher:


is this a standard?


Tahir

unread,
Sep 23, 2014, 2:44:20 PM9/23/14
to golan...@googlegroups.com
It is not a hash function but it can be used as the basis to construct one that is pretty fast. Well fast if your CPU has the AES flag.

Keith Randall

unread,
Sep 23, 2014, 10:18:19 PM9/23/14
to golan...@googlegroups.com
Go uses a hash function called "aeshash" internally for hash maps.  It is not AES, but it uses the aesenc assembly instruction to compute hashes.  It is quite a bit faster than portable alternatives like murmurhash or cityhash.

 aeshash is only used if on x86 and if aes hardware instructions are available.

We do not want to export aeshash to user code.  It would defeat a lot of the DOS resistance of hash tables if user code could call it directly.  But feel free to copy the code and roll your own...

Tahir

unread,
Sep 24, 2014, 5:04:42 AM9/24/14
to golan...@googlegroups.com
Got it.

Thanks.
Reply all
Reply to author
Forward
0 new messages