SipHash128 Class
Definition
- Namespace
- Bodu.Security.Cryptography
- Assembly
- Bodu.Security.Cryptography.dll
- Package
- Bodu.Security.Cryptography 1.2.0
- Source
- SipHash.128.cs
Computes a 128-bit keyed hash using the SipHash algorithm by Aumasson and Bernstein. Produces a 16-byte authentication tag from a 128-bit key, offering increased collision resistance over SipHash64 . This class cannot be inherited.
public sealed class SipHash128 : SipHash, ICryptoTransform, IDisposable
- Inheritance
-
SipHash128
- Implements
- Inherited Members
- Extension Methods
Examples
using Bodu.Security.Cryptography;
using var sip = new SipHash128 { Key = sessionKey };
byte[] tag = sip.ComputeHash(message);
Remarks
SipHash128 is parameterized as SipHash-c-d, where c is the number of compression rounds
and d is the number of finalization rounds. The default configuration corresponds to SipHash-2-4.
See SipHash for a description of the round structure.
Parameters at a glance.
- Tag size: 128 bits (16 bytes).
- Key size: 128 bits (16 bytes).
- Default parameterization: SipHash-2-4 (2 compression rounds, 4 finalization rounds).
- Multi-message key reuse is supported - unlike Poly1305.
When to choose SipHash128. Pick SipHash128 over SipHash64 when the wider 128-bit tag is required - multi-tenant hash tables with very large key spaces, fingerprint-style cache keys, or short-message authentication where 64 bits would be marginal. For protocol-level MACs over long messages prefer HMAC-SHA-256 or Blake2b-MAC.
Constructors
SipHash128()
Initializes a new instance of the SipHash128 class with a fixed 128-bit output size, the default
SipHash-2-4 parameterization, and a freshly generated random key.
public SipHash128()
Remarks
The instance is created with the following defaults:
| Property | Default Value |
|---|---|
| CompressionRounds | MinCompressionRounds (2) |
| FinalizationRounds | MinFinalizationRounds (4) |
| HashSize | 128 |
| Key | Cryptographically random 16-byte key containing no zero bytes. |
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |