Class SipHash
- Namespace
- Org.BouncyCastle.Crypto.Macs
- Assembly
- BouncyCastle.Cryptography.dll
Implementation of SipHash as specified in "SipHash: a fast short-input PRF", by Jean-Philippe Aumasson and Daniel J. Bernstein (https://131002.net/siphash/siphash.pdf).
public class SipHash : IMac
- Inheritance
-
SipHash
- Implements
- Inherited Members
Remarks
"SipHash is a family of PRFs SipHash-c-d where the integer parameters c and d are the number of compression rounds and the number of finalization rounds. A compression round is identical to a finalization round and this round function is called SipRound. Given a 128-bit key k and a (possibly empty) byte string m, SipHash-c-d returns a 64-bit value..."
Constructors
SipHash()
SipHash-2-4
public SipHash()
SipHash(int, int)
SipHash-c-d
public SipHash(int c, int d)
Parameters
Fields
c
protected readonly int c
Field Value
d
protected readonly int d
Field Value
k0
protected long k0
Field Value
k1
protected long k1
Field Value
m
protected long m
Field Value
v0
protected long v0
Field Value
v1
protected long v1
Field Value
v2
protected long v2
Field Value
v3
protected long v3
Field Value
wordCount
protected int wordCount
Field Value
wordPos
protected int wordPos
Field Value
Properties
AlgorithmName
The algorithm name.
public virtual string AlgorithmName { get; }
Property Value
Methods
ApplySipRounds(int)
protected virtual void ApplySipRounds(int n)
Parameters
nint
BlockUpdate(byte[], int, int)
Update the MAC with a block of bytes.
public virtual void BlockUpdate(byte[] input, int offset, int length)
Parameters
BlockUpdate(ReadOnlySpan<byte>)
Update the MAC with a span of bytes.
public virtual void BlockUpdate(ReadOnlySpan<byte> input)
Parameters
inputReadOnlySpan<byte>the span containing the data.
DoFinal()
public virtual long DoFinal()
Returns
DoFinal(byte[], int)
Perform final calculations, producing the result MAC.
public virtual int DoFinal(byte[] output, int outOff)
Parameters
outputbyte[]the byte array the MAC is to be copied into.
outOffintthe offset into the byte array the MAC is to start at.
Returns
- int
the number of bytes written
Remarks
This call leaves the MAC reset.
DoFinal(Span<byte>)
Perform final calculations, producing the result MAC.
public int DoFinal(Span<byte> output)
Parameters
Returns
- int
the number of bytes written
Remarks
This call leaves the MAC reset.
GetMacSize()
Return the size, in bytes, of the MAC produced by this implementation.
public virtual int GetMacSize()
Returns
- int
the size, in bytes, of the MAC produced by this implementation.
Init(ICipherParameters)
Initialise the MAC.
public virtual void Init(ICipherParameters parameters)
Parameters
parametersICipherParametersThe key or other data required by the MAC.
ProcessMessageWord()
protected virtual void ProcessMessageWord()
Reset()
Reset the MAC back to its initial state.
public virtual void Reset()
RotateLeft(long, int)
protected static long RotateLeft(long x, int n)
Parameters
Returns
Update(byte)
Update the MAC with a single byte.
public virtual void Update(byte input)
Parameters
inputbytethe input byte to be entered.