-
public interface SecretBox.Native
-
-
Method Summary
Modifier and Type Method Description abstract voidcryptoSecretBoxKeygen(Array<byte> key)Creates a random key. abstract booleancryptoSecretBoxEasy(Array<byte> cipherText, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)Encrypts a message using a key generated by cryptoSecretBoxKeygen. abstract booleancryptoSecretBoxOpenEasy(Array<byte> message, Array<byte> cipherText, int cipherTextLen, Array<byte> nonce, Array<byte> key)Decrypts and verifies a message using a key generatedby cryptoSecretBoxKeygen. abstract booleancryptoSecretBoxDetached(Array<byte> cipherText, Array<byte> mac, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)Encrypts a message. abstract booleancryptoSecretBoxOpenDetached(Array<byte> message, Array<byte> cipherText, Array<byte> mac, int cipherTextLen, Array<byte> nonce, Array<byte> key)Decrypts a message with the mac and the cipher providedseparately. -
-
Method Detail
-
cryptoSecretBoxKeygen
abstract void cryptoSecretBoxKeygen(Array<byte> key)
Creates a random key. It is equivalent to calling randomBytesBuf but improves codeclarity and can prevent misuse by ensuringthat the provided key length isalways correct.
- Parameters:
key- The key which is of size KEYBYTES.
-
cryptoSecretBoxEasy
abstract boolean cryptoSecretBoxEasy(Array<byte> cipherText, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)
Encrypts a message using a key generated by cryptoSecretBoxKeygen.
- Parameters:
cipherText- The cipher text.message- The message to encrypt.messageLen- The message byte array length.nonce- A nonce of size NONCEBYTES generated by randomBytesBuf.key- The symmetric key generated by cryptoSecretBoxKeygen.
-
cryptoSecretBoxOpenEasy
abstract boolean cryptoSecretBoxOpenEasy(Array<byte> message, Array<byte> cipherText, int cipherTextLen, Array<byte> nonce, Array<byte> key)
Decrypts and verifies a message using a key generatedby cryptoSecretBoxKeygen.
- Parameters:
message- The message will be put into here once decrypted.cipherText- The cipher produced by cryptoSecretBoxEasy.cipherTextLen- The cipher text length.nonce- This has to be the same nonce that was used whenencrypting using{@code cryptoSecretBoxEasy}.key- The key generated by cryptoSecretBoxKeygen.
-
cryptoSecretBoxDetached
abstract boolean cryptoSecretBoxDetached(Array<byte> cipherText, Array<byte> mac, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)
Encrypts a message. Alongside the cipher a mac isreturned which can be stored in separate locations.
- Parameters:
cipherText- The encrypted message of length{@code messageLen}.mac- The mac.message- The message to encrypt.messageLen- The message's length.nonce- A randomly generated nonce of size NONCEBYTES.key- The key generated by cryptoSecretBoxKeygen.
-
cryptoSecretBoxOpenDetached
abstract boolean cryptoSecretBoxOpenDetached(Array<byte> message, Array<byte> cipherText, Array<byte> mac, int cipherTextLen, Array<byte> nonce, Array<byte> key)
Decrypts a message with the mac and the cipher providedseparately.
- Parameters:
message- The message length which is the same size as{@code cipherTextLen}.cipherText- The cipher.mac- The mac.cipherTextLen- The cipher text length.nonce- The nonce that was used in cryptoSecretBoxDetached.key- The key generated by cryptoSecretBoxKeygen.
-
-
-
-