#1 2021-02-12 17:19:54

From: France
Registered: 2010-06-21
Posts: 13,268

New AesNiHash32/AesNiHash64/AesNiHash128 Hashers for mORMot 2

Forum thread for comments about https://blog.synopse.info/?post/2021/02 … r-mORMot-2

I have just committed some new AesNiHash32/AesNiHash64/AesNiHash128 Hashers for mORMot 2.

They are using AES-NI and SSE4.1 opcodes on x86_64 and i386.
- it is faster than the fastest SSE4.1 crc32c and with a much higher stability
- logic extracted from the Go Runtime, and optimized for Delphi/FPC

Numbers on i386 and x86_64 are amazing: more than 15GB/s (GigaBytes) on my Core i3.
Regular crc32c with SSE4.1 is 2-3GB/s and optimized crc32c from Intel is slightly slower.

But the output of the AesNiHash is much safer, since it has much less collisions than crc32c.
It is based on the AES permutation hardware instructions of modern Intel/AMD CPUs, for both safety and performance.

Its purpose is NOT to replace crc32c or MD5 or SHA2 or SHA3. It is not to be used to compute a signature.
It is used internally to hash elements, e.g. strings, and store them into a Hash table - see e.g. our TDynArray or TSynDictionary.

In fact, the hashes are initialized with a new random AES key at startup, so everytime a process is launched, the hashes will changes.
It is a good idea to resists to DOS attacks.
See https://github.com/tkaitchuck/aHash/wik … OS-attacks

We re-implemented the Go RTL assembly, with some optimizations for our particular use.
So it is a proven algorithm, used on production by Google and a lot of companies.
Check aeshashbody in https://golang.org/src/runtime/asm_amd64.s


#2 2021-02-12 22:56:16

Registered: 2019-09-29
Posts: 86

Re: New AesNiHash32/AesNiHash64/AesNiHash128 Hashers for mORMot 2

Well done.


#3 2021-02-13 11:30:14

From: Slovenia
Registered: 2018-02-12
Posts: 202

Re: New AesNiHash32/AesNiHash64/AesNiHash128 Hashers for mORMot 2

This is a superb update!


Board footer

Powered by FluxBB