veorq/SipHash logo

veorq/SipHash

Free

High-speed secure pseudorandom function for short messages

FreeFree tier
Type
Open Source

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

Optimized for speed on short messages
Cryptographically secure pseudorandom function (keyed hash)
Simple, portable reference C implementation
Multiple variants: SipHash-2-4, SipHash-4-8, SipHash-128, HalfSipHash (32-bit)
Defense against hash-flooding DoS attacks
Battle-tested in OS kernels, languages, libraries, and applications
Includes test vectors and debug mode

Pros & Cons

Pros
  • 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
Cons
  • 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

Best For

Preventing hash-collision denial-of-service attacksMessage authentication (MAC) with a secret keyShort-input hashing in data structures and network protocolsKeyed hash function for integrity verification

FAQ

What is SipHash?
SipHash is a family of pseudorandom functions (PRFs) designed for fast, secure hashing of short messages. It can be used as a keyed hash function or message authentication code (MAC).
Who created SipHash?
SipHash was designed in 2012 by Jean-Philippe Aumasson and Daniel J. Bernstein.
What are the main variants of SipHash?
The default variant is SipHash-2-4 (128-bit key, 64-bit output). Other variants include SipHash-4-8, SipHash-128 (128-bit tag), HalfSipHash (32-bit word, 64-bit key, 32- or 64-bit tag).
Where is SipHash used?
SipHash is integrated into operating systems (Linux kernel, OpenBSD, FreeBSD, FreeRTOS), programming languages (Perl, Python, Ruby), libraries (OpenSSL libcrypto, Sodium), and applications (Wireguard, Redis).
Is SipHash secure?
Yes, SipHash has been extensively cryptanalyzed with no signs of weakness. With at least 2 compression and 4 finalization rounds, it provides maximum expected PRF security for its key and output size.