java.lang.Object
com.southernstorm.noise.protocol.Noise

public final class Noiseextends Object
Utility functions for the Noise protocol library.

Provides factory methods for creating Noise protocol cipher and hash instances, along with internal utility functions for byte array management.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Maximum length for Noise packets.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Every member here is static and the class holds no fields, so an instance carries nothing; it exists only to give the utility class a documented entry point.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    (package private) static byte[]
    copySubArray(byte[] data, int offset, int length)
    Makes a copy of part of an array.
    Creates a cipher object from its Noise protocol name.
    Creates a hash object from its Noise protocol name.
    (package private) static void
    destroy(byte[] array)
    Destroys the contents of a byte array.
    (package private) static void
    I2P Release a hash object back to the pool.
    (package private) static void
    Throws an instance of AEADBadTagException.

    Methods inherited from class Object

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

    • MAX_PACKET_LEN

      public static final int MAX_PACKET_LEN
      Maximum length for Noise packets.
      See Also:
  • Constructor Details

    • Noise

      public Noise()
      Every member here is static and the class holds no fields, so an instance carries nothing; it exists only to give the utility class a documented entry point.
  • Method Details

    • createCipher

      public static CipherState createCipher(String name) throws NoSuchAlgorithmException
      Creates a cipher object from its Noise protocol name.
      Parameters:
      name - The name of the cipher algorithm; e.g. "AESGCM", "ChaChaPoly", etc.
      Returns:
      The cipher object if the name is recognized.
      Throws:
      NoSuchAlgorithmException - The name is not recognized as a valid Noise protocol name, or there is no cryptography provider in the system that implements the algorithm.
    • createHash

      public static MessageDigest createHash(String name) throws NoSuchAlgorithmException
      Creates a hash object from its Noise protocol name.
      Parameters:
      name - The name of the hash algorithm; e.g. "SHA256", "BLAKE2s", etc.
      Returns:
      The hash object if the name is recognized.
      Throws:
      NoSuchAlgorithmException - The name is not recognized as a valid Noise protocol name, or there is no cryptography provider in the system that implements the algorithm.
    • releaseHash

      static void releaseHash(MessageDigest hash)
      I2P Release a hash object back to the pool.
      Parameters:
      hash - the hash object to release
    • destroy

      static void destroy(byte[] array)
      Destroys the contents of a byte array.
      Parameters:
      array - The array whose contents should be destroyed.
    • copySubArray

      static byte[] copySubArray(byte[] data, int offset, int length)
      Makes a copy of part of an array.
      Parameters:
      data - The buffer containing the data to copy.
      offset - Offset of the first byte to copy.
      length - The number of bytes to copy.
      Returns:
      A new array with a copy of the sub-array.
    • throwBadTagException

      static void throwBadTagException() throws BadPaddingException
      Throws an instance of AEADBadTagException.
      Throws:
      BadPaddingException - The AEAD exception. If the underlying JDK does not have the AEADBadTagException class, then this function will instead throw an instance of the superclass BadPaddingException.