java.lang.Object
com.southernstorm.noise.crypto.Poly1305
- All Implemented Interfaces:
Destroyable, Cloneable
Simple implementation of the Poly1305 message authenticator.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final byte[]The message block being absorbed.private final int[]The final tag, in intermediate form.private final int[]The 130-bit accumulator, broken up into five 26-bit words.private final byte[]The 16-byte nonce of the final tag.private intBytes absorbed into the current block.private final int[]The secret key, in intermediate form.private final long[]Scratch space for the intermediate sums.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionclone()I2Pvoiddestroy()Destroys all sensitive state in the current object.voidfinish(byte[] token, int offset) Finishes the message authenticator and returns the 16-byte token.voidpad()Pads the input with zeroes to a multiple of 16 bytes.private voidprocessChunk(byte[] chunk, int offset, boolean finalChunk) Processes the next chunk of input data.voidreset(byte[] key, int offset) Resets the message authenticator with a new key.voidupdate(byte[] data, int offset, int length) Updates the message authenticator with more input data.
Field Details
nonce
private final byte[] nonceThe 16-byte nonce of the final tag.block
private final byte[] blockThe message block being absorbed.h
private final int[] hThe 130-bit accumulator, broken up into five 26-bit words.r
private final int[] rThe secret key, in intermediate form.c
private final int[] cThe final tag, in intermediate form.t
private final long[] tScratch space for the intermediate sums.posn
private int posnBytes absorbed into the current block.
Constructor Details
Poly1305
public Poly1305()Constructs a new Poly1305 message authenticator.
Method Details
reset
public void reset(byte[] key, int offset) Resets the message authenticator with a new key.- Parameters:
key- The buffer containing the 32 byte key.offset- The offset into the buffer of the first key byte.
update
public void update(byte[] data, int offset, int length) Updates the message authenticator with more input data.- Parameters:
data- The buffer containing the input data.offset- The offset of the first byte of input.length- The number of bytes of input.
pad
public void pad()Pads the input with zeroes to a multiple of 16 bytes.finish
public void finish(byte[] token, int offset) Finishes the message authenticator and returns the 16-byte token.- Parameters:
token- The buffer to receive the token.offset- The offset of the token in the buffer.
processChunk
private void processChunk(byte[] chunk, int offset, boolean finalChunk) Processes the next chunk of input data.- Parameters:
chunk- Buffer containing the input data chunk.offset- Offset of the first byte of the 16-byte chunk.finalChunk- Set to true if this is the final chunk.
destroy
public void destroy()Description copied from interface:DestroyableDestroys all sensitive state in the current object.- Specified by:
destroyin interfaceDestroyable
clone
I2P- Overrides:
clonein classObject- Throws:
CloneNotSupportedException