public final class Noise extends Object
Provides factory methods for creating Noise protocol cipher and hash instances, along with internal utility functions for byte array management.
| Modifier and Type | Field and Description |
|---|---|
static int | MAX_PACKET_LENMaximum length for Noise packets. |
| Constructor and Description |
|---|
Noise() |
| Modifier and Type | Method and Description |
|---|---|
(package private) static byte[] | copySubArray(byte[] data,
int offset,
int length)Makes a copy of part of an array. |
static CipherState | createCipher(String name)Creates a cipher object from its Noise protocol name. |
static MessageDigest | createHash(String 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 | releaseHash(MessageDigest hash)I2P Release a hash object back to the pool. |
(package private) static void | throwBadTagException()Throws an instance of AEADBadTagException. |
public static final int MAX_PACKET_LEN
static byte[] copySubArray(byte[] data,
int offset,
int length)data - The buffer containing the data to copy.offset - Offset of the first byte to copy.length - The number of bytes to copy.public static CipherState createCipher(String name) throws NoSuchAlgorithmException
name - The name of the cipher algorithm; e.g. "AESGCM", "ChaChaPoly", etc.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.public static MessageDigest createHash(String name) throws NoSuchAlgorithmException
name - The name of the hash algorithm; e.g. "SHA256", "BLAKE2s", etc.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.static void destroy(byte[] array)
array - The array whose contents should be destroyed.static void releaseHash(MessageDigest hash)
hash - the hash object to releasestatic void throwBadTagException()
throws BadPaddingExceptionBadPaddingException - 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.