|
Bouncy Castle Cryptography Library 1.81 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.bouncycastle.crypto.macs.SipHash
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).
"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[]"
Field Summary | |
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 Summary | |
SipHash()
SipHash-2-4 |
|
SipHash(int c,
int d)
SipHash-c-d |
Method Summary | |
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. |
java.lang.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)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
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
Constructor Detail |
public SipHash()
public SipHash(int c, int d)
c
- the number of compression roundsd
- the number of finalization roundsMethod Detail |
public java.lang.String getAlgorithmName()
Mac
getAlgorithmName
in interface Mac
public int getMacSize()
Mac
getMacSize
in interface Mac
public void init(CipherParameters params) throws java.lang.IllegalArgumentException
Mac
init
in interface Mac
params
- the key and other data required by the MAC.
java.lang.IllegalArgumentException
- if the params argument is
inappropriate.public void update(byte input) throws java.lang.IllegalStateException
Mac
update
in interface Mac
input
- the byte to be processed.
java.lang.IllegalStateException
- if the MAC is not initialised.public void update(byte[] input, int offset, int length) throws DataLengthException, java.lang.IllegalStateException
update
in interface Mac
input
- the array containing the input.offset
- the index in the array the data begins at.length
- the length of the input starting at inOff.
java.lang.IllegalStateException
- if the MAC is not initialised.
DataLengthException
- if there isn't enough data in in.public long doFinal() throws DataLengthException, java.lang.IllegalStateException
DataLengthException
java.lang.IllegalStateException
public int doFinal(byte[] out, int outOff) throws DataLengthException, java.lang.IllegalStateException
Mac
doFinal leaves the MAC in the same state it was after the last init.
doFinal
in interface Mac
out
- 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.
java.lang.IllegalStateException
- if the MAC is not initialised.public void reset()
Mac
reset
in interface Mac
protected void processMessageWord()
protected void applySipRounds(int n)
protected static long rotateLeft(long x, int n)
|
Bouncy Castle Cryptography Library 1.81 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |