public class SipHash extends Object implements Mac
"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..."
| Modifier and Type | Field and Description |
|---|---|
protected int |
c |
protected int |
d |
protected long |
k0 |
protected long |
k1 |
protected long |
m |
protected long |
v0 |
protected long |
v1 |
protected long |
v2 |
protected long |
v3 |
protected int |
wordCount |
protected int |
wordPos |
| Constructor and Description |
|---|
SipHash()
SipHash-2-4
|
SipHash(int c,
int d)
SipHash-c-d
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
applySipRounds(int n) |
long |
doFinal() |
int |
doFinal(byte[] out,
int outOff)
Compute the final stage of the MAC writing the output to the out
parameter.
|
String |
getAlgorithmName()
Return the name of the algorithm the MAC implements.
|
int |
getMacSize()
Return the block size for this MAC (in bytes).
|
void |
init(CipherParameters params)
Initialise the MAC.
|
protected void |
processMessageWord() |
void |
reset()
Reset the MAC.
|
protected static long |
rotateLeft(long x,
int n) |
void |
update(byte input)
add a single byte to the mac for processing.
|
void |
update(byte[] input,
int offset,
int length) |
protected final int c
protected final int d
protected long k0
protected long k1
protected long v0
protected long v1
protected long v2
protected long v3
protected long m
protected int wordPos
protected int wordCount
public SipHash()
public SipHash(int c,
int d)
c - the number of compression roundsd - the number of finalization roundspublic String getAlgorithmName()
MacgetAlgorithmName in interface Macpublic int getMacSize()
MacgetMacSize in interface Macpublic void init(CipherParameters params) throws IllegalArgumentException
Macinit in interface Macparams - the key and other data required by the MAC.IllegalArgumentException - if the params argument is
inappropriate.public void update(byte input)
throws IllegalStateException
Macupdate in interface Macinput - the byte to be processed.IllegalStateException - if the MAC is not initialised.public void update(byte[] input,
int offset,
int length)
throws DataLengthException,
IllegalStateException
update in interface Macinput - the array containing the input.offset - the index in the array the data begins at.length - the length of the input starting at inOff.DataLengthException - if there isn't enough data in in.IllegalStateException - if the MAC is not initialised.public long doFinal()
throws DataLengthException,
IllegalStateException
public int doFinal(byte[] out,
int outOff)
throws DataLengthException,
IllegalStateException
MacdoFinal leaves the MAC in the same state it was after the last init.
doFinal in interface Macout - the array the MAC is to be output to.outOff - the offset into the out buffer the output is to start at.DataLengthException - if there isn't enough space in out.IllegalStateException - if the MAC is not initialised.public void reset()
Macprotected void processMessageWord()
protected void applySipRounds(int n)
protected static long rotateLeft(long x,
int n)
Copyright © 2015–2020 The veraPDF Consortium. All rights reserved.