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

public final class Noise extends Object
Utility functions for the Noise protocol library.
  • Field Details

    • MAX_PACKET_LEN

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

    • Noise

      public Noise()
  • Method Details

    • random

      public static void random(byte[] data)
      Generates random data using the system random number generator.
      Parameters:
      data - The data buffer to fill with random data.
    • setForceFallbacks

      public static void setForceFallbacks(boolean force)
      Force the use of plain Java fallback crypto implementations.
      Parameters:
      force - Set to true for force fallbacks, false to try to use the system implementation before falling back. This function is intended for testing purposes to toggle between the system JCA/JCE implementations and the plain Java fallback reference implementations.
    • createDH

      public static DHState createDH(String name) throws NoSuchAlgorithmException
      Creates a Diffie-Hellman object from its Noise protocol name.
      Parameters:
      name - The name of the DH algorithm; e.g. "25519", "448", etc.
      Returns:
      The Diffie-Hellman 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.
    • 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.