veorq/SipHash
FreeHigh-speed secure pseudorandom function for short messages
About veorq/SipHash
SipHash is a family of pseudorandom functions (PRFs) designed in 2012 by Jean-Philippe Aumasson and Daniel J. Bernstein, optimized for speed on short messages and intended as a defense against hash-flooding denial-of-service attacks. This repository provides a portable, simple reference C implementation of SipHash-2-4 (default 128-bit key, 64-bit output) and its variants, including SipHash-4-8, SipHash-128, and HalfSipHash (32-bit word version). SipHash offers cryptographic security, outperforms many insecure non-cryptographic hash functions on short inputs, and is battle-tested in operating systems (Linux kernel, OpenBSD, FreeBSD, FreeRTOS), programming languages (Perl, Python, Ruby), libraries (OpenSSL libcrypto, Sodium), and applications (Wireguard, Redis). The code is optimized for clarity and debugging, with included test vectors and a makefile for building and validation.
Key Features
Pros & Cons
- Faster than many cryptographic MACs on short inputs
- Competitive performance with insecure non-cryptographic hashes
- Proven security with extensive cryptanalysis by leading researchers
- Widely adopted in real-world systems (Linux, Python, Redis, etc.)
- Minimal code complexity and easy to integrate
- Not a general-purpose (keyless) hash; requires a secret key for security
- Output size limited to 64 or 128 bits (32/64 for HalfSipHash)
- Security bound by key size (128 bits); key management necessary
- Optimized primarily for short messages; may not be ideal for long inputs