java.lang.Object
com.southernstorm.noise.crypto.Poly1305
All Implemented Interfaces:
Destroyable, Cloneable

public final class Poly1305extends Object implements Destroyable, Cloneable
Simple implementation of the Poly1305 message authenticator.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private 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 int
    Bytes 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

    Constructors
    Constructor
    Description
    Constructs a new Poly1305 message authenticator.
  • Method Summary

    Modifier and Type
    Method
    Description
    I2P
    void
    Destroys all sensitive state in the current object.
    void
    finish(byte[] token, int offset)
    Finishes the message authenticator and returns the 16-byte token.
    void
    pad()
    Pads the input with zeroes to a multiple of 16 bytes.
    private void
    processChunk(byte[] chunk, int offset, boolean finalChunk)
    Processes the next chunk of input data.
    void
    reset(byte[] key, int offset)
    Resets the message authenticator with a new key.
    void
    update(byte[] data, int offset, int length)
    Updates the message authenticator with more input data.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • nonce

      private final byte[] nonce
      The 16-byte nonce of the final tag.
    • block

      private final byte[] block
      The message block being absorbed.
    • h

      private final int[] h
      The 130-bit accumulator, broken up into five 26-bit words.
    • r

      private final int[] r
      The secret key, in intermediate form.
    • c

      private final int[] c
      The final tag, in intermediate form.
    • t

      private final long[] t
      Scratch space for the intermediate sums.
    • posn

      private int posn
      Bytes 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: Destroyable
      Destroys all sensitive state in the current object.
      Specified by:
      destroy in interface Destroyable
    • clone

      public Poly1305 clone() throws CloneNotSupportedException
      I2P
      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException