This is a pure Ada implementation of the SipHash PRF.
It is based on the original paper and tested against the test values provided in the paper and in the reference C implementation.
SipHash was designed by Jean-Philippe Aumasson and Daniel J. Bernstein.
From the official website:
SipHash is a family of pseudorandom functions (a.k.a. keyed hash functions) optimized for speed on short messages.
Target applications include network traffic authentication and defense against hash-flooding DoS attacks.
SipHash is secure, fast, and simple (for real):
- SipHash is simpler and faster than previous cryptographic algorithms (e.g. MACs based on universal hashing)
- SipHash is competitive in performance with insecure non-cryptographic algorithms (e.g. MurmurHash)
We propose that hash tables switch to SipHash as a hash function. Users of SipHash already include FreeBSD, OpenDNS, Perl 5, Ruby, or Rust.
Block interface:
with SipHash.PRF;
[β¦]
package SipHash24 is new SipHash.PRF(Nb_Compression_Rounds => 2,
Nb_Finalization_Rounds => 4);
[β¦]
Output := SipHash24.Hash(Input, Key);
Streaming interface:
with SipHash.PRF;
[β¦]
package SipHash48 is new SipHash.PRF(Nb_Compression_Rounds => 4,
Nb_Finalization_Rounds => 8);
[β¦]
-- Initialization with the 128-bit secret key.
Hash : SipHash48.Object := SipHash48.Initialize(Key);
[β¦]
-- Processing of each byte of the input.
for I in Input'Range loop
SipHash48.Update(Hash, Input(I));
end loop;
-- Finalization to compute the hash value.
SipHash48.Finalize(Hash, Output);
In debug mode:
$ make
In release mode:
$ make BUILD_MODE=release
To run the tests:
$ make run_tests
J.-P. Aumasson and D. J. Bernstein, βSipHash: a fast short-input PRF.β 18-Sep-2012.
J.-P. Aumasson and D. J. Bernstein, "Reference C implementation"
This software is licensed under the BSD3 license.
Copyright (c) 2014, Sylvain Laperche [email protected]