java.lang.Object
com.southernstorm.noise.protocol.Noise
Utility functions for the Noise protocol library.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CipherStatecreateCipher(String name)Creates a cipher object from its Noise protocol name.static DHStateCreates a Diffie-Hellman object from its Noise protocol name.static MessageDigestcreateHash(String name)Creates a hash object from its Noise protocol name.static voidrandom(byte[] data)Generates random data using the system random number generator.static voidsetForceFallbacks(boolean force)Force the use of plain Java fallback crypto implementations.
-
Field Details
-
MAX_PACKET_LEN
public static final int MAX_PACKET_LENMaximum 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
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
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
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.
-