-
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. abstract voidcryptoSecretBoxXChaCha20Poly1305Keygen(Array<byte> key)Creates a random key for the XChaCha20Poly1305 variant. abstract booleancryptoSecretBoxXChaCha20Poly1305Easy(Array<byte> cipherText, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)Encrypts a message by the XChaCha20Poly1305 variant using a key generated by cryptoSecretBoxKeygen. abstract booleancryptoSecretBoxXChaCha20Poly1305OpenEasy(Array<byte> message, Array<byte> cipherText, int cipherTextLen, Array<byte> nonce, Array<byte> key)Decrypts and verifies a message using a key generatedby cryptoSecretBoxXChaCha20Poly1305Keygen. abstract booleancryptoSecretBoxXChaCha20Poly1305Detached(Array<byte> cipherText, Array<byte> mac, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)Encrypts a message using the XChaCha20Poly1305 variant. abstract booleancryptoSecretBoxXChaCha20Poly1305OpenDetached(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, using the XChaCha20Poly1305 variant. -
-
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.
-
cryptoSecretBoxXChaCha20Poly1305Keygen
abstract void cryptoSecretBoxXChaCha20Poly1305Keygen(Array<byte> key)
Creates a random key for the XChaCha20Poly1305 variant. 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 XCHACHA20POLY1305_KEYBYTES.
-
cryptoSecretBoxXChaCha20Poly1305Easy
abstract boolean cryptoSecretBoxXChaCha20Poly1305Easy(Array<byte> cipherText, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)
Encrypts a message by the XChaCha20Poly1305 variant 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 XCHACHA20POLY1305_NONCEBYTES generated by randomBytesBuf.key- The symmetric key generated by cryptoSecretBoxXChaCha20Poly1305Keygen.
-
cryptoSecretBoxXChaCha20Poly1305OpenEasy
abstract boolean cryptoSecretBoxXChaCha20Poly1305OpenEasy(Array<byte> message, Array<byte> cipherText, int cipherTextLen, Array<byte> nonce, Array<byte> key)
Decrypts and verifies a message using a key generatedby cryptoSecretBoxXChaCha20Poly1305Keygen.
- Parameters:
message- The message will be put into here once decrypted.cipherText- The cipher produced by cryptoSecretBoxXChaCha20Poly1305Easy.cipherTextLen- The cipher text length.nonce- This has to be the same nonce that was used whenencrypting using{@code cryptoSecretBoxXChaCha20Poly1305Easy}.key- The key generated by cryptoSecretBoxXChaCha20Poly1305Keygen.
-
cryptoSecretBoxXChaCha20Poly1305Detached
abstract boolean cryptoSecretBoxXChaCha20Poly1305Detached(Array<byte> cipherText, Array<byte> mac, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)
Encrypts a message using the XChaCha20Poly1305 variant. 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 XCHACHA20POLY1305_NONCEBYTES.key- The key generated by cryptoSecretBoxXChaCha20Poly1305Keygen.
-
cryptoSecretBoxXChaCha20Poly1305OpenDetached
abstract boolean cryptoSecretBoxXChaCha20Poly1305OpenDetached(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, using the XChaCha20Poly1305 variant.
- 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 cryptoSecretBoxXChaCha20Poly1305Detached.key- The key generated by cryptoSecretBoxXChaCha20Poly1305Keygen.
-
-
-
-