public abstract class LazySodium extends java.lang.Object implements Base, Random, AEAD.Native, AEAD.Lazy, GenericHash.Native, GenericHash.Lazy, ShortHash.Native, ShortHash.Lazy, SecureMemory.Native, SecureMemory.Lazy, Auth.Native, Auth.Lazy, SecretStream.Native, SecretStream.Lazy, Stream.Native, Stream.Lazy, Padding.Native, Padding.Lazy, Helpers.Native, Helpers.Lazy, PwHash.Native, PwHash.Lazy, Hash.Native, Hash.Lazy, Sign.Native, Sign.Lazy, Box.Native, Box.Lazy, SecretBox.Native, SecretBox.Lazy, KeyExchange.Native, KeyExchange.Lazy, KeyDerivation.Native, KeyDerivation.Lazy, DiffieHellman.Native, DiffieHellman.Lazy
| Modifier and Type | Field and Description |
|---|---|
protected java.nio.charset.Charset |
charset |
protected MessageEncoder |
messageEncoder |
| Constructor and Description |
|---|
LazySodium() |
LazySodium(java.nio.charset.Charset charset) |
LazySodium(java.nio.charset.Charset charset,
MessageEncoder messageEncoder) |
LazySodium(MessageEncoder messageEncoder) |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
bytes(java.lang.String s)
Convert a string to directly bytes.
|
KeyPair |
convertKeyPairEd25519ToCurve25519(KeyPair ed25519KeyPair)
Converts a ed25519 keypair to a curve25519 keypair.
|
boolean |
convertPublicKeyEd25519ToCurve25519(byte[] curve,
byte[] ed)
Converts a public ed25519 key to a public curve25519 key.
|
boolean |
convertSecretKeyEd25519ToCurve25519(byte[] curve,
byte[] ed)
Converts a secret ed25519 key to a secret curve25519 key.
|
boolean |
cryptoAeadAES256GCMDecrypt(byte[] message,
long[] messageLen,
byte[] nSec,
byte[] cipher,
long cipherLen,
byte[] additionalData,
long additionalDataLen,
byte[] nPub,
byte[] key) |
boolean |
cryptoAeadAES256GCMDecryptDetached(byte[] message,
byte[] nSec,
byte[] cipher,
long cipherLen,
byte[] mac,
byte[] additionalData,
long additionalDataLen,
byte[] nPub,
byte[] key) |
boolean |
cryptoAeadAES256GCMEncrypt(byte[] cipher,
long[] cipherLen,
byte[] message,
long messageLen,
byte[] additionalData,
long additionalDataLen,
byte[] nSec,
byte[] nPub,
byte[] key) |
boolean |
cryptoAeadAES256GCMEncryptDetached(byte[] cipher,
byte[] mac,
long[] macLenAddress,
byte[] message,
long messageLen,
byte[] additionalData,
long additionalDataLen,
byte[] nSec,
byte[] nPub,
byte[] key) |
boolean |
cryptoAeadAES256GCMIsAvailable() |
void |
cryptoAeadAES256GCMKeygen(byte[] key) |
boolean |
cryptoAeadChaCha20Poly1305Decrypt(byte[] m,
long[] mLen,
byte[] nSec,
byte[] c,
long cLen,
byte[] ad,
long adLen,
byte[] nPub,
byte[] k) |
boolean |
cryptoAeadChaCha20Poly1305DecryptDetached(byte[] m,
byte[] nSec,
byte[] c,
long cLen,
byte[] mac,
byte[] ad,
long adLen,
byte[] nPub,
byte[] k) |
boolean |
cryptoAeadChaCha20Poly1305Encrypt(byte[] c,
long[] cLen,
byte[] m,
long mLen,
byte[] ad,
long adLen,
byte[] nSec,
byte[] nPub,
byte[] k) |
boolean |
cryptoAeadChaCha20Poly1305EncryptDetached(byte[] c,
byte[] mac,
long[] macLenAddress,
byte[] m,
long mLen,
byte[] ad,
long adLen,
byte[] nSec,
byte[] nPub,
byte[] k) |
boolean |
cryptoAeadChaCha20Poly1305IetfDecrypt(byte[] m,
long[] mLen,
byte[] nSec,
byte[] c,
long cLen,
byte[] ad,
long adLen,
byte[] nPub,
byte[] k) |
boolean |
cryptoAeadChaCha20Poly1305IetfDecryptDetached(byte[] m,
byte[] nSec,
byte[] c,
long cLen,
byte[] mac,
byte[] ad,
long adLen,
byte[] nPub,
byte[] k) |
boolean |
cryptoAeadChaCha20Poly1305IetfEncrypt(byte[] c,
long[] cLen,
byte[] m,
long mLen,
byte[] ad,
long adLen,
byte[] nSec,
byte[] nPub,
byte[] k) |
boolean |
cryptoAeadChaCha20Poly1305IetfEncryptDetached(byte[] c,
byte[] mac,
long[] macLenAddress,
byte[] m,
long mLen,
byte[] ad,
long adLen,
byte[] nSec,
byte[] nPub,
byte[] k) |
void |
cryptoAeadChaCha20Poly1305IetfKeygen(byte[] key) |
void |
cryptoAeadChaCha20Poly1305Keygen(byte[] key) |
boolean |
cryptoAeadXChaCha20Poly1305IetfDecrypt(byte[] m,
long[] mLen,
byte[] nSec,
byte[] c,
long cLen,
byte[] ad,
long adLen,
byte[] nPub,
byte[] k) |
boolean |
cryptoAeadXChaCha20Poly1305IetfDecryptDetached(byte[] m,
byte[] nSec,
byte[] c,
long cLen,
byte[] mac,
byte[] ad,
long adLen,
byte[] nPub,
byte[] k) |
boolean |
cryptoAeadXChaCha20Poly1305IetfEncrypt(byte[] c,
long[] cLen,
byte[] m,
long mLen,
byte[] ad,
long adLen,
byte[] nSec,
byte[] nPub,
byte[] k) |
boolean |
cryptoAeadXChaCha20Poly1305IetfEncryptDetached(byte[] c,
byte[] mac,
long[] macLenAddress,
byte[] m,
long mLen,
byte[] ad,
long adLen,
byte[] nSec,
byte[] nPub,
byte[] k) |
void |
cryptoAeadXChaCha20Poly1305IetfKeygen(byte[] k) |
boolean |
cryptoAuth(byte[] tag,
byte[] in,
long inLen,
byte[] key)
Computes a tag for the message in, whose length is inLen bytes, and the key k.
|
java.lang.String |
cryptoAuth(java.lang.String message,
Key key)
Computes a tag for the message in.
|
java.lang.String |
cryptoAuthHMACSha(Auth.Type type,
java.lang.String in,
Key key) |
boolean |
cryptoAuthHMACSha256(byte[] out,
byte[] in,
long inLen,
byte[] k) |
boolean |
cryptoAuthHMACSha256Final(Auth.StateHMAC256 state,
byte[] out) |
boolean |
cryptoAuthHMACSha256Init(Auth.StateHMAC256 state,
byte[] key,
int keyLen) |
void |
cryptoAuthHMACSha256Keygen(byte[] key) |
boolean |
cryptoAuthHMACSha256Update(Auth.StateHMAC256 state,
byte[] in,
long inLen) |
boolean |
cryptoAuthHMACSha256Verify(byte[] h,
byte[] in,
long inLen,
byte[] k) |
boolean |
cryptoAuthHMACSha512(byte[] out,
byte[] in,
long inLen,
byte[] k) |
boolean |
cryptoAuthHMACSha512256(byte[] out,
byte[] in,
long inLen,
byte[] k) |
boolean |
cryptoAuthHMACSha512256Final(Auth.StateHMAC512256 state,
byte[] out) |
boolean |
cryptoAuthHMACSha512256Init(Auth.StateHMAC512256 state,
byte[] key,
int keyLen) |
void |
cryptoAuthHMACSha512256Keygen(byte[] key) |
boolean |
cryptoAuthHMACSha512256Update(Auth.StateHMAC512256 state,
byte[] in,
long inLen) |
boolean |
cryptoAuthHMACSha512256Verify(byte[] h,
byte[] in,
long inLen,
byte[] k) |
boolean |
cryptoAuthHMACSha512Final(Auth.StateHMAC512 state,
byte[] out) |
boolean |
cryptoAuthHMACSha512Init(Auth.StateHMAC512 state,
byte[] key,
int keyLen) |
void |
cryptoAuthHMACSha512Keygen(byte[] key) |
boolean |
cryptoAuthHMACSha512Update(Auth.StateHMAC512 state,
byte[] in,
long inLen) |
boolean |
cryptoAuthHMACSha512Verify(byte[] h,
byte[] in,
long inLen,
byte[] k) |
java.lang.String |
cryptoAuthHMACShaFinal(Auth.StateHMAC256 state) |
java.lang.String |
cryptoAuthHMACShaFinal(Auth.StateHMAC512 state) |
java.lang.String |
cryptoAuthHMACShaFinal(Auth.StateHMAC512256 state) |
boolean |
cryptoAuthHMACShaInit(Auth.StateHMAC256 state,
Key key) |
boolean |
cryptoAuthHMACShaInit(Auth.StateHMAC512256 state,
Key key) |
boolean |
cryptoAuthHMACShaInit(Auth.StateHMAC512 state,
Key key) |
Key |
cryptoAuthHMACShaKeygen(Auth.Type type) |
boolean |
cryptoAuthHMACShaUpdate(Auth.StateHMAC256 state,
java.lang.String in) |
boolean |
cryptoAuthHMACShaUpdate(Auth.StateHMAC512256 state,
java.lang.String in) |
boolean |
cryptoAuthHMACShaUpdate(Auth.StateHMAC512 state,
java.lang.String in) |
boolean |
cryptoAuthHMACShaVerify(Auth.Type type,
java.lang.String h,
java.lang.String in,
Key key) |
Key |
cryptoAuthKeygen()
Generate an authentication key.
|
void |
cryptoAuthKeygen(byte[] k)
Generate an authentication key.
|
boolean |
cryptoAuthVerify(byte[] tag,
byte[] in,
long inLen,
byte[] key)
Verifies that the tag stored at h is a
valid tag for the message in whose length
is inLen bytes, and the key k.
|
boolean |
cryptoAuthVerify(java.lang.String tag,
java.lang.String message,
Key key)
Verifies that the tag
valid tag for the message.
|
java.lang.String |
cryptoBoxBeforeNm(byte[] publicKey,
byte[] secretKey)
If you send several messages to the same receiver or receive several messages from the
same sender, you can gain speed by calculating
the shared key only once, and reusing it in subsequent operations.
|
boolean |
cryptoBoxBeforeNm(byte[] k,
byte[] publicKey,
byte[] secretKey) |
java.lang.String |
cryptoBoxBeforeNm(KeyPair keyPair)
If you send several messages to the same receiver or receive several messages from the
same sender, you can gain speed by calculating
the shared key only once, and reusing it in subsequent operations.
|
boolean |
cryptoBoxDetached(byte[] cipherText,
byte[] mac,
byte[] message,
long messageLen,
byte[] nonce,
byte[] publicKey,
byte[] secretKey) |
boolean |
cryptoBoxDetachedAfterNm(byte[] cipherText,
byte[] mac,
byte[] message,
long messageLen,
byte[] nonce,
byte[] key) |
DetachedEncrypt |
cryptoBoxDetachedAfterNm(java.lang.String message,
byte[] nonce,
java.lang.String sharedSecretKey)
Encrypt a message but allow for storage of
the mac separately.
|
boolean |
cryptoBoxEasy(byte[] cipherText,
byte[] message,
long messageLen,
byte[] nonce,
byte[] publicKey,
byte[] secretKey) |
java.lang.String |
cryptoBoxEasy(java.lang.String message,
byte[] nonce,
KeyPair keyPair)
Encrypts a message.
|
boolean |
cryptoBoxEasyAfterNm(byte[] cipherText,
byte[] message,
long messageLen,
byte[] nonce,
byte[] key) |
java.lang.String |
cryptoBoxEasyAfterNm(java.lang.String message,
byte[] nonce,
java.lang.String sharedSecretKey)
Encrypt a message.
|
KeyPair |
cryptoBoxKeypair()
Generate a secret and public key.
|
boolean |
cryptoBoxKeypair(byte[] publicKey,
byte[] secretKey) |
boolean |
cryptoBoxOpenDetached(byte[] message,
byte[] cipherText,
byte[] mac,
long cipherTextLen,
byte[] nonce,
byte[] publicKey,
byte[] secretKey) |
boolean |
cryptoBoxOpenDetachedAfterNm(byte[] message,
byte[] cipherText,
byte[] mac,
long cipherTextLen,
byte[] nonce,
byte[] key) |
DetachedDecrypt |
cryptoBoxOpenDetachedAfterNm(DetachedEncrypt detachedEncrypt,
byte[] nonce,
java.lang.String sharedSecretKey)
Decrypt a message.
|
boolean |
cryptoBoxOpenEasy(byte[] message,
byte[] cipherText,
long cipherTextLen,
byte[] nonce,
byte[] publicKey,
byte[] secretKey) |
java.lang.String |
cryptoBoxOpenEasy(java.lang.String cipherText,
byte[] nonce,
KeyPair keyPair)
Decrypts a previously encrypted message.
|
boolean |
cryptoBoxOpenEasyAfterNm(byte[] message,
byte[] cipher,
long cLen,
byte[] nonce,
byte[] key) |
java.lang.String |
cryptoBoxOpenEasyAfterNm(java.lang.String cipher,
byte[] nonce,
java.lang.String sharedSecretKey)
Decrypt a message.
|
boolean |
cryptoBoxSeal(byte[] cipher,
byte[] message,
long messageLen,
byte[] publicKey) |
java.lang.String |
cryptoBoxSealEasy(java.lang.String message,
Key publicKey)
Encrypts a message.
|
boolean |
cryptoBoxSealOpen(byte[] m,
byte[] cipher,
long cipherLen,
byte[] publicKey,
byte[] secretKey) |
java.lang.String |
cryptoBoxSealOpenEasy(java.lang.String cipherText,
KeyPair keyPair)
Decrypts a previously encrypted message.
|
KeyPair |
cryptoBoxSeedKeypair(byte[] seed)
Generate a public and secret key deterministically.
|
boolean |
cryptoBoxSeedKeypair(byte[] publicKey,
byte[] secretKey,
byte[] seed) |
boolean |
cryptoGenericHash(byte[] out,
int outLen,
byte[] in,
long inLen)
Hash a byte array without a key.
|
boolean |
cryptoGenericHash(byte[] out,
int outLen,
byte[] in,
long inLen,
byte[] key,
int keyLen)
Hash a byte array.
|
java.lang.String |
cryptoGenericHash(java.lang.String in)
Hash a string without a key.
|
java.lang.String |
cryptoGenericHash(java.lang.String in,
Key key)
Hash a string with a key, so later on you
can verify the hashed string with the key.
|
boolean |
cryptoGenericHashFinal(byte[] state,
byte[] out,
int outLen)
Now that the hash has finalised, the hash can
be put into
out. |
java.lang.String |
cryptoGenericHashFinal(byte[] state,
int outLen)
Finalise the hashing operation.
|
boolean |
cryptoGenericHashInit(byte[] state,
byte[] key,
int keyLength,
int outLen)
Hash multiple parts of a message.
|
boolean |
cryptoGenericHashInit(byte[] state,
int outLen)
Hash multiple parts of a message without a key
|
boolean |
cryptoGenericHashInit(byte[] state,
Key key,
int outLen)
Initialise a multi-part hashing operation.
|
Key |
cryptoGenericHashKeygen()
Generate a hashing key.
|
void |
cryptoGenericHashKeygen(byte[] k)
Generate a key.
|
Key |
cryptoGenericHashKeygen(int size)
Generate a hashing key with a size.
|
int |
cryptoGenericHashStateBytes() |
boolean |
cryptoGenericHashUpdate(byte[] state,
byte[] in,
long inLen)
Update a multi-part hashing with another part.
|
boolean |
cryptoGenericHashUpdate(byte[] state,
java.lang.String in)
Hash a part of a multi-part hash.
|
boolean |
cryptoHashSha256(byte[] out,
byte[] in,
long inLen) |
java.lang.String |
cryptoHashSha256(java.lang.String message) |
java.lang.String |
cryptoHashSha256Final(Hash.State256 state) |
boolean |
cryptoHashSha256Final(Hash.State256 state,
byte[] out) |
boolean |
cryptoHashSha256Init(Hash.State256 state) |
boolean |
cryptoHashSha256Update(Hash.State256 state,
byte[] in,
long inLen) |
boolean |
cryptoHashSha256Update(Hash.State256 state,
java.lang.String messagePart) |
boolean |
cryptoHashSha512(byte[] out,
byte[] in,
long inLen) |
java.lang.String |
cryptoHashSha512(java.lang.String message) |
java.lang.String |
cryptoHashSha512Final(Hash.State512 state) |
boolean |
cryptoHashSha512Final(Hash.State512 state,
byte[] out) |
boolean |
cryptoHashSha512Init(Hash.State512 state) |
boolean |
cryptoHashSha512Update(Hash.State512 state,
byte[] in,
long inLen) |
boolean |
cryptoHashSha512Update(Hash.State512 state,
java.lang.String messagePart) |
int |
cryptoKdfDeriveFromKey(byte[] subKey,
int subKeyLen,
long subKeyId,
byte[] context,
byte[] masterKey)
Derive a subkey from a master key.
|
Key |
cryptoKdfDeriveFromKey(int lengthOfSubKey,
long subKeyId,
java.lang.String context,
Key masterKey)
Derive a subkey from a master key.
|
Key |
cryptoKdfKeygen()
Auto generates a master key and returns
it in string format.
|
void |
cryptoKdfKeygen(byte[] masterKey)
Creates a master key.
|
boolean |
cryptoKxClientSessionKeys(byte[] rx,
byte[] tx,
byte[] clientPk,
byte[] clientSk,
byte[] serverPk)
This function computes a pair of shared keys
(rx and tx) using the client's public key clientPk,
the client's secret key clientSk and the server's public key serverPk.
|
SessionPair |
cryptoKxClientSessionKeys(Key clientPk,
Key clientSk,
Key serverPk)
Generate a client's session keys.
|
SessionPair |
cryptoKxClientSessionKeys(KeyPair clientKeyPair,
KeyPair serverKeyPair)
Generate a client's session keys.
|
KeyPair |
cryptoKxKeypair()
Generate a public and secret key.
|
KeyPair |
cryptoKxKeypair(byte[] seed)
Deterministically generate a public and secret key.
|
boolean |
cryptoKxKeypair(byte[] publicKey,
byte[] secretKey)
Generate a public and a secret key.
|
boolean |
cryptoKxSeedKeypair(byte[] publicKey,
byte[] secretKey,
byte[] seed)
Deterministically generate a public and secret key.
|
boolean |
cryptoKxServerSessionKeys(byte[] rx,
byte[] tx,
byte[] serverPk,
byte[] serverSk,
byte[] clientPk)
This function computes a pair of shared keys
(rx and tx) using the client's public key clientPk,
the server's secret key serverSk and the server's public key serverPk.
|
SessionPair |
cryptoKxServerSessionKeys(Key serverPk,
Key serverSk,
Key clientPk)
Computes a pair of shared keys (server-side)
(rx and tx) using the client's public key clientPk,
the server's secret key serverSk and the server's public key serverPk.
|
SessionPair |
cryptoKxServerSessionKeys(KeyPair serverKeyPair,
KeyPair clientKeyPair)
Generate a server's session keys.
|
boolean |
cryptoPwHash(byte[] outputHash,
int outputHashLen,
byte[] password,
int passwordLen,
byte[] salt,
long opsLimit,
com.sun.jna.NativeLong memLimit,
PwHash.Alg alg)
Based on a password you provide, hash that
password and put the output into
outputHash. |
java.lang.String |
cryptoPwHash(java.lang.String password,
int lengthOfHash,
byte[] salt,
long opsLimit,
com.sun.jna.NativeLong memLimit,
PwHash.Alg alg)
Hashes a given password.
|
boolean |
cryptoPwHashStr(byte[] outputStr,
byte[] password,
int passwordLen,
long opsLimit,
com.sun.jna.NativeLong memLimit)
Hashes a password and stores it into an array.
|
java.lang.String |
cryptoPwHashStr(java.lang.String password,
long opsLimit,
com.sun.jna.NativeLong memLimit)
The most minimal way of hashing a given password.
|
boolean |
cryptoPwHashStrNeedsRehash(byte[] hash,
long opsLimit,
com.sun.jna.NativeLong memLimit)
Checks whether the hash needs a rehash.
|
java.lang.String |
cryptoPwHashStrRemoveNulls(java.lang.String password,
long opsLimit,
com.sun.jna.NativeLong memLimit)
Hashes a string and removes all the null bytes.
|
boolean |
cryptoPwHashStrVerify(byte[] hash,
byte[] password,
int passwordLen)
Verifies a hashed password.
|
boolean |
cryptoPwHashStrVerify(java.lang.String hash,
java.lang.String password)
Verifies a password.
|
boolean |
cryptoScalarMult(byte[] shared,
byte[] secretKey,
byte[] publicKey) |
Key |
cryptoScalarMult(Key secretKey,
Key publicKey)
Generate a shared key from another user's public key
and a secret key.
|
boolean |
cryptoScalarMultBase(byte[] publicKey,
byte[] secretKey) |
Key |
cryptoScalarMultBase(Key secretKey)
Generate a public key from a private key.
|
boolean |
cryptoSecretBoxDetached(byte[] cipherText,
byte[] mac,
byte[] message,
long messageLen,
byte[] nonce,
byte[] key)
Encrypts a message.
|
DetachedEncrypt |
cryptoSecretBoxDetached(java.lang.String message,
byte[] nonce,
Key key)
Encrypts a message with the mac separately
|
boolean |
cryptoSecretBoxEasy(byte[] cipherText,
byte[] message,
long messageLen,
byte[] nonce,
byte[] key)
Encrypts a message using a key generated by
SecretBox.Native.cryptoSecretBoxKeygen(byte[]). |
java.lang.String |
cryptoSecretBoxEasy(java.lang.String message,
byte[] nonce,
Key key)
Encrypts a message.
|
Key |
cryptoSecretBoxKeygen()
Generates a secret symmetric key.
|
void |
cryptoSecretBoxKeygen(byte[] key)
Creates a random key.
|
boolean |
cryptoSecretBoxOpenDetached(byte[] message,
byte[] cipherText,
byte[] mac,
long cipherTextLen,
byte[] nonce,
byte[] key)
Decrypts a message with the mac and the cipher provided
separately.
|
java.lang.String |
cryptoSecretBoxOpenDetached(DetachedEncrypt cipherAndMac,
byte[] nonce,
Key key)
Decrypts a message.
|
boolean |
cryptoSecretBoxOpenEasy(byte[] message,
byte[] cipherText,
long cipherTextLen,
byte[] nonce,
byte[] key)
Decrypts and verifies a message using a key generated
by
SecretBox.Native.cryptoSecretBoxKeygen(byte[]). |
java.lang.String |
cryptoSecretBoxOpenEasy(java.lang.String cipher,
byte[] nonce,
Key key)
Decrypts a message.
|
SecretStream.State |
cryptoSecretStreamInitPull(byte[] header,
Key key)
Initialises decryption using a state and a key.
|
boolean |
cryptoSecretStreamInitPull(SecretStream.State state,
byte[] header,
byte[] key)
Initialises decryption using a state and a key.
|
SecretStream.State |
cryptoSecretStreamInitPush(byte[] header,
Key key)
Initialise encryption.
|
boolean |
cryptoSecretStreamInitPush(SecretStream.State state,
byte[] header,
byte[] key)
Initialises encryption with a state and a key.
|
Key |
cryptoSecretStreamKeygen()
Generates a key.
|
void |
cryptoSecretStreamKeygen(byte[] key)
Generate a secret stream key.
|
boolean |
cryptoSecretStreamPull(SecretStream.State state,
byte[] message,
byte[] tag,
byte[] cipher,
long cipherLen)
Decrypt a message without additional data.
|
boolean |
cryptoSecretStreamPull(SecretStream.State state,
byte[] message,
long[] messageAddress,
byte[] tag,
byte[] cipher,
long cipherLen,
byte[] additionalData,
long additionalDataLen)
Decrypt a message.
|
java.lang.String |
cryptoSecretStreamPull(SecretStream.State state,
java.lang.String cipher,
byte[] tag)
Decrypt a message without additional data.
|
boolean |
cryptoSecretStreamPush(SecretStream.State state,
byte[] cipher,
byte[] message,
long messageLen,
byte tag)
Encrypt a
message. |
boolean |
cryptoSecretStreamPush(SecretStream.State state,
byte[] cipher,
long[] cipherAddr,
byte[] message,
long messageLen,
byte tag)
Encrypt a
message. |
boolean |
cryptoSecretStreamPush(SecretStream.State state,
byte[] cipher,
long[] cipherAddr,
byte[] message,
long messageLen,
byte[] additionalData,
long additionalDataLen,
byte tag)
Encrypt a
message. |
java.lang.String |
cryptoSecretStreamPush(SecretStream.State state,
java.lang.String message,
byte tag)
Encrypt a
message. |
void |
cryptoSecretStreamRekey(SecretStream.State state)
Explicitly rekeys.
|
boolean |
cryptoShortHash(byte[] out,
byte[] in,
long inLen,
byte[] key)
Short-input hash some text.
|
java.lang.String |
cryptoShortHash(java.lang.String in,
Key key)
Hash a short message using a key.
|
Key |
cryptoShortHashKeygen()
Generate a 64-bit key for short-input hashing.
|
void |
cryptoShortHashKeygen(byte[] k)
Output a 64-bit key.
|
boolean |
cryptoSign(byte[] signedMessage,
byte[] message,
long messageLen,
byte[] secretKey)
Sign a message.
|
java.lang.String |
cryptoSign(java.lang.String message,
Key secretKey)
Sign a message.
|
java.lang.String |
cryptoSign(java.lang.String message,
java.lang.String secretKey)
Sign a message.
|
boolean |
cryptoSignDetached(byte[] signature,
byte[] message,
long messageLen,
byte[] secretKey)
Returns a signature for a message.
|
java.lang.String |
cryptoSignDetached(java.lang.String message,
Key secretKey)
Returns a signature for a message.
|
boolean |
cryptoSignEd25519SkToPk(byte[] publicKey,
byte[] ed)
Extracts the ed25519 public key from a secret ed25519 key.
|
boolean |
cryptoSignEd25519SkToSeed(byte[] seed,
byte[] ed)
Extracts the seed value from a secret ed25519 key.
|
boolean |
cryptoSignFinalCreate(Sign.StateCryptoSign state,
byte[] sig,
com.sun.jna.Pointer sigLen,
byte[] sk)
This function computes a signature for the previously supplied message,
using the secret key sk and puts it into sig.
|
boolean |
cryptoSignFinalVerify(Sign.StateCryptoSign state,
byte[] sig,
byte[] pk)
Verifies that sig is a valid signature for the message whose
content has been previously supplied using crypto_update(),
using the public key pk.
|
boolean |
cryptoSignInit(Sign.StateCryptoSign state)
Useful for signing a multi-part message (Ed25519ph).
|
KeyPair |
cryptoSignKeypair()
Generate a signing keypair (ed25519).
|
boolean |
cryptoSignKeypair(byte[] publicKey,
byte[] secretKey)
Generate a signing keypair (ed25519).
|
boolean |
cryptoSignOpen(byte[] message,
byte[] signedMessage,
long signedMessageLen,
byte[] publicKey)
Verify a signed message.
|
java.lang.String |
cryptoSignOpen(java.lang.String signedMessage,
Key publicKey)
Checks that a message is validly signed by a public key.
|
KeyPair |
cryptoSignSecretKeyPair(Key secretKey)
Generate a signing keypair (ed25519), given a secret ed25519 key.
|
KeyPair |
cryptoSignSeedKeypair(byte[] seed)
Generate a signing keypair deterministically.
|
boolean |
cryptoSignSeedKeypair(byte[] publicKey,
byte[] secretKey,
byte[] seed)
Deterministically generate a public and secret key.
|
boolean |
cryptoSignUpdate(Sign.StateCryptoSign state,
byte[] chunk,
long chunkLength)
Add a new chunk of length chunkLen bytes to the
message that will eventually be signed.
|
boolean |
cryptoSignVerifyDetached(byte[] signature,
byte[] message,
int messageLen,
byte[] publicKey)
Verifies that
signature is valid for the
message. |
boolean |
cryptoSignVerifyDetached(java.lang.String signature,
java.lang.String message,
Key publicKey)
Verifies that
signature is valid for the
message. |
byte[] |
cryptoStream(byte[] nonce,
Key key,
Stream.Method method) |
boolean |
cryptoStreamChaCha20(byte[] c,
long cLen,
byte[] nonce,
byte[] key) |
boolean |
cryptoStreamChaCha20Ietf(byte[] c,
long cLen,
byte[] nonce,
byte[] key) |
void |
cryptoStreamChaCha20IetfKeygen(byte[] key) |
boolean |
cryptoStreamChaCha20IetfXor(byte[] cipher,
byte[] message,
long messageLen,
byte[] nonce,
byte[] key) |
boolean |
cryptoStreamChacha20IetfXorIc(byte[] cipher,
byte[] message,
long messageLen,
byte[] nonce,
long ic,
byte[] key) |
void |
cryptoStreamChaCha20Keygen(byte[] key) |
boolean |
cryptoStreamChaCha20Xor(byte[] cipher,
byte[] message,
long messageLen,
byte[] nonce,
byte[] key) |
boolean |
cryptoStreamChacha20XorIc(byte[] cipher,
byte[] message,
long messageLen,
byte[] nonce,
long ic,
byte[] key) |
protected byte[] |
cryptoStreamDefaultXorIc(byte[] messageBytes,
byte[] nonce,
long ic,
Key key,
Stream.Method method) |
Key |
cryptoStreamKeygen(Stream.Method method) |
boolean |
cryptoStreamSalsa20(byte[] c,
long cLen,
byte[] nonce,
byte[] key) |
void |
cryptoStreamSalsa20Keygen(byte[] key) |
boolean |
cryptoStreamSalsa20Xor(byte[] cipher,
byte[] message,
long messageLen,
byte[] nonce,
byte[] key) |
boolean |
cryptoStreamSalsa20XorIc(byte[] cipher,
byte[] message,
long messageLen,
byte[] nonce,
long ic,
byte[] key) |
java.lang.String |
cryptoStreamXor(java.lang.String message,
byte[] nonce,
Key key,
Stream.Method method) |
java.lang.String |
cryptoStreamXorDecrypt(java.lang.String cipher,
byte[] nonce,
Key key,
Stream.Method method) |
java.lang.String |
cryptoStreamXorIc(java.lang.String message,
byte[] nonce,
long ic,
Key key,
Stream.Method method) |
java.lang.String |
cryptoStreamXorIcDecrypt(java.lang.String cipher,
byte[] nonce,
long ic,
Key key,
Stream.Method method) |
boolean |
cryptoStreamXSalsa20(byte[] c,
long cLen,
byte[] nonce,
byte[] key) |
void |
cryptoStreamXSalsa20Keygen(byte[] key) |
boolean |
cryptoStreamXSalsa20Xor(byte[] cipher,
byte[] message,
long messageLen,
byte[] nonce,
byte[] key) |
java.lang.String |
decrypt(java.lang.String cipher,
java.lang.String additionalData,
byte[] nSec,
byte[] nPub,
Key k,
AEAD.Method method) |
java.lang.String |
decrypt(java.lang.String cipher,
java.lang.String additionalData,
byte[] nPub,
Key k,
AEAD.Method method) |
DetachedDecrypt |
decryptDetached(DetachedEncrypt detachedEncrypt,
java.lang.String additionalData,
byte[] nSec,
byte[] nPub,
Key k,
AEAD.Method method) |
java.lang.String |
encrypt(java.lang.String m,
java.lang.String additionalData,
byte[] nSec,
byte[] nPub,
Key k,
AEAD.Method method) |
java.lang.String |
encrypt(java.lang.String m,
java.lang.String additionalData,
byte[] nPub,
Key k,
AEAD.Method method) |
DetachedEncrypt |
encryptDetached(java.lang.String m,
java.lang.String additionalData,
byte[] nSec,
byte[] nPub,
Key k,
AEAD.Method method) |
abstract Sodium |
getSodium() |
Key |
keygen(AEAD.Method method) |
static java.lang.Integer |
longToInt(long lng) |
static void |
main(java.lang.String[] args) |
byte[] |
nonce(int size)
Get a random number of bytes to use in a nonce.
|
byte[] |
randomBytesBuf(int size)
Get a random number of bytes.
|
byte[] |
randomBytesDeterministic(int size,
byte[] seed)
Get deterministically random bytes given a seed.
|
long |
randomBytesRandom()
Return a unsigned int byte 0 and 0xffffffff included.
|
long |
randomBytesUniform(int upperBound)
Returns an unpredictable value between 0 and upperBound (excluded).
|
byte[] |
removeNulls(byte[] bs)
Remove all the null bytes from the
end of a byte array.
|
<T> T |
res(int res,
T object) |
com.sun.jna.Pointer |
sodiumAllocArray(int count,
int size)
Returns a pointer from which
count objects that are size bytes of memory each can be accessed.
|
java.lang.String |
sodiumBin2Hex(byte[] bin)
Binary to hexadecimal.
|
void |
sodiumFree(com.sun.jna.Pointer p)
Unlocks and deallocates memory allocated using
SecureMemory.Native.sodiumMalloc(int) or SecureMemory.Native.sodiumAllocArray(int, int)}. |
byte[] |
sodiumHex2Bin(java.lang.String hex)
Hexadecimal to binary.
|
int |
sodiumInit() |
com.sun.jna.Pointer |
sodiumMalloc(int size)
Returns a pointer from which exactly
size contiguous bytes of memory can be accessed.
|
boolean |
sodiumMemZero(byte[] pnt,
int len)
The sodium_memzero() function tries to effectively zero len bytes starting at pnt,
even if optimizations are being applied to the code.
|
boolean |
sodiumMLock(byte[] array,
int len)
Locks at least len bytes of memory from the array.
|
boolean |
sodiumMProtectNoAccess(com.sun.jna.Pointer ptr)
Makes a region allocated using
SecureMemory.Native.sodiumMalloc(int) or SecureMemory.Native.sodiumAllocArray(int, int)}
inaccessible. |
boolean |
sodiumMProtectReadOnly(com.sun.jna.Pointer ptr)
Marks a region allocated using
SecureMemory.Native.sodiumMalloc(int) or SecureMemory.Native.sodiumAllocArray(int, int)}
as read-only. |
boolean |
sodiumMProtectReadWrite(com.sun.jna.Pointer ptr)
Marks a region allocated using
SecureMemory.Native.sodiumMalloc(int) or SecureMemory.Native.sodiumAllocArray(int, int)}
as readable and writable, after having been protected using
SecureMemory.Native.sodiumMProtectReadOnly(Pointer) or SecureMemory.Native.sodiumMProtectNoAccess(Pointer)}/ |
boolean |
sodiumMUnlock(byte[] array,
int len)
Unlocks at least len bytes of memory from the array.
|
boolean |
sodiumPad(com.sun.jna.ptr.IntByReference paddedBuffLen,
com.sun.jna.Pointer buf,
int unpaddedBufLen,
int blockSize,
int maxBufLen)
Adds extra padding to a buffer
buf whose
original size is unpaddedBufLen in order
to extend its total length to a multiple of blocksize. |
boolean |
sodiumUnpad(com.sun.jna.ptr.IntByReference unPaddedBuffLen,
com.sun.jna.Pointer buf,
int paddedBufLen,
int blockSize)
Computes the original, unpadded length of a message previously padded using
Padding.Native.sodiumPad(IntByReference, Pointer, int, int, int). |
java.lang.String |
str(byte[] bs)
Converts a byte array to a string
using a charset.
|
java.lang.String |
str(byte[] bs,
java.nio.charset.Charset charset)
Convert a byte array to a string with a charset.
|
boolean |
successful(int res) |
static byte[] |
toBin(java.lang.String hex)
Hexadecimal string to bytes.
|
byte[] |
toBinary(java.lang.String hex) |
static java.lang.String |
toHex(byte[] bin)
Bytes to hexadecimal.
|
java.lang.String |
toHexStr(byte[] bs) |
boolean |
wrongLen(byte[] bs,
int shouldBe) |
boolean |
wrongLen(int byteLength,
int shouldBe) |
boolean |
wrongLen(int byteLength,
long shouldBe) |
protected final java.nio.charset.Charset charset
protected final MessageEncoder messageEncoder
public LazySodium(java.nio.charset.Charset charset,
MessageEncoder messageEncoder)
public LazySodium()
public LazySodium(java.nio.charset.Charset charset)
public LazySodium(MessageEncoder messageEncoder)
public static java.lang.Integer longToInt(long lng)
public int sodiumInit()
sodiumInit in interface Helpers.Nativepublic java.lang.String sodiumBin2Hex(byte[] bin)
Helpers.LazysodiumBin2Hex in interface Helpers.Lazybin - The binary bytes you want to convert to a string.public byte[] sodiumHex2Bin(java.lang.String hex)
Helpers.LazysodiumHex2Bin in interface Helpers.Lazyhex - Hexadecimal string (a string that's
made up of the characters 0123456789ABCDEF)
to convert to a binary array.public java.lang.String toHexStr(byte[] bs)
public byte[] toBinary(java.lang.String hex)
public static java.lang.String toHex(byte[] bin)
sodiumBin2Hex(byte[]) but static.bin - Byte array.public static byte[] toBin(java.lang.String hex)
sodiumHex2Bin(String)} but static.hex - Hexadecimal string to convert to bytes.public long randomBytesRandom()
RandomrandomBytesRandom in interface Randompublic byte[] randomBytesBuf(int size)
RandomrandomBytesBuf in interface Randomsize - The length of the byte array to return.public byte[] nonce(int size)
Randomnonce in interface Randomsize - The size of the byte array to return.Random.randomBytesBuf(int)public long randomBytesUniform(int upperBound)
RandomrandomBytesUniform in interface Randompublic byte[] randomBytesDeterministic(int size,
byte[] seed)
RandomrandomBytesDeterministic in interface Randomsize - Size of byte array to return.seed - Seed to provide.public boolean sodiumPad(com.sun.jna.ptr.IntByReference paddedBuffLen,
com.sun.jna.Pointer buf,
int unpaddedBufLen,
int blockSize,
int maxBufLen)
Padding.Nativebuf whose
original size is unpaddedBufLen in order
to extend its total length to a multiple of blocksize.sodiumPad in interface Padding.NativepaddedBuffLen - New length of buffer.buf - The buffer byte array.unpaddedBufLen - The length of buf with no padding.blockSize - Block size.maxBufLen - The absolute maximum you want this buffer length
to be.maxBufLen.public boolean sodiumUnpad(com.sun.jna.ptr.IntByReference unPaddedBuffLen,
com.sun.jna.Pointer buf,
int paddedBufLen,
int blockSize)
Padding.NativePadding.Native.sodiumPad(IntByReference, Pointer, int, int, int). The original length is put into
unpaddedBufLen.sodiumUnpad in interface Padding.NativeunPaddedBuffLen - This will be populated with the unpadded buffer length.buf - The buffer.paddedBufLen - The padded buffer size.blockSize - The block size.public boolean sodiumMemZero(byte[] pnt,
int len)
SecureMemory.NativesodiumMemZero in interface SecureMemory.Nativepnt - The byte array to zero out.len - How many bytes to zero out.public boolean sodiumMLock(byte[] array,
int len)
SecureMemory.NativesodiumMLock in interface SecureMemory.Nativearray - Array to lock.len - Number of bytes to lock.public boolean sodiumMUnlock(byte[] array,
int len)
SecureMemory.NativesodiumMUnlock in interface SecureMemory.Nativearray - Array to unlock.len - Number of bytes to unlock.public com.sun.jna.Pointer sodiumMalloc(int size)
SecureMemory.NativesodiumMalloc in interface SecureMemory.Nativesize - The size of the byte array to allocate.public com.sun.jna.Pointer sodiumAllocArray(int count,
int size)
SecureMemory.NativeSecureMemory.Native.sodiumMalloc(int) but
also protects against arithmetic overflows when count * size exceeds SIZE_MAX.sodiumAllocArray in interface SecureMemory.Nativecount - Number of objectssize - Size of those objectspublic void sodiumFree(com.sun.jna.Pointer p)
SecureMemory.NativeSecureMemory.Native.sodiumMalloc(int) or SecureMemory.Native.sodiumAllocArray(int, int)}.sodiumFree in interface SecureMemory.Nativep - The pointer to which an array shall be freed.public boolean sodiumMProtectNoAccess(com.sun.jna.Pointer ptr)
SecureMemory.NativeSecureMemory.Native.sodiumMalloc(int) or SecureMemory.Native.sodiumAllocArray(int, int)}
inaccessible. It cannot be read or written, but the data is preserved.sodiumMProtectNoAccess in interface SecureMemory.Nativeptr - The pointer to a region to decline access to.public boolean sodiumMProtectReadOnly(com.sun.jna.Pointer ptr)
SecureMemory.NativeSecureMemory.Native.sodiumMalloc(int) or SecureMemory.Native.sodiumAllocArray(int, int)}
as read-only.
Attempting to modify the data will cause the process to terminate.sodiumMProtectReadOnly in interface SecureMemory.Nativeptr - Pointer to the region.public boolean sodiumMProtectReadWrite(com.sun.jna.Pointer ptr)
SecureMemory.NativeSecureMemory.Native.sodiumMalloc(int) or SecureMemory.Native.sodiumAllocArray(int, int)}
as readable and writable, after having been protected using
SecureMemory.Native.sodiumMProtectReadOnly(Pointer) or SecureMemory.Native.sodiumMProtectNoAccess(Pointer)}/sodiumMProtectReadWrite in interface SecureMemory.Nativeptr - Pointer to the region.public void cryptoKdfKeygen(byte[] masterKey)
KeyDerivation.NativecryptoKdfKeygen in interface KeyDerivation.NativemasterKey - The byte array to populate. Should be
KeyDerivation.MASTER_KEY_BYTES.public int cryptoKdfDeriveFromKey(byte[] subKey,
int subKeyLen,
long subKeyId,
byte[] context,
byte[] masterKey)
KeyDerivation.NativecryptoKdfDeriveFromKey in interface KeyDerivation.NativesubKey - The subkey.subKeyLen - The length of the subkey. Should be
from KeyDerivation.BYTES_MIN to KeyDerivation.BYTES_MAX.subKeyId - ID of subkey.context - The context of the subkey. Must be KeyDerivation.CONTEXT_BYTES.masterKey - The generated master key from KeyDerivation.Native.cryptoKdfKeygen(byte[]). Must be KeyDerivation.MASTER_KEY_BYTES.public Key cryptoKdfKeygen()
KeyDerivation.LazycryptoKdfKeygen in interface KeyDerivation.Lazypublic Key cryptoKdfDeriveFromKey(int lengthOfSubKey, long subKeyId, java.lang.String context, Key masterKey) throws SodiumException
KeyDerivation.LazycryptoKdfDeriveFromKey in interface KeyDerivation.LazylengthOfSubKey - The length of the subkey. Should be
from KeyDerivation.BYTES_MIN to KeyDerivation.BYTES_MAX.subKeyId - The ID of the subkey.context - The context of the subkey. Must be KeyDerivation.CONTEXT_BYTES.masterKey - The generated master key from KeyDerivation.Lazy.cryptoKdfKeygen().Helpers.Lazy.sodiumBin2Hex(byte[]).SodiumException - If any of the lengths were not correct.public boolean cryptoKxKeypair(byte[] publicKey,
byte[] secretKey)
KeyExchange.NativecryptoKxKeypair in interface KeyExchange.NativepublicKey - Public key will be populated here of size KeyExchange.PUBLICKEYBYTES.secretKey - Secret key will be populated here of size KeyExchange.SECRETKEYBYTES.public boolean cryptoKxSeedKeypair(byte[] publicKey,
byte[] secretKey,
byte[] seed)
KeyExchange.NativecryptoKxSeedKeypair in interface KeyExchange.NativepublicKey - Public key will be populated here of size KeyExchange.PUBLICKEYBYTES.secretKey - Secret key will be populated here of size KeyExchange.SECRETKEYBYTES.seed - A random seed of size KeyExchange.SEEDBYTES.public boolean cryptoKxClientSessionKeys(byte[] rx,
byte[] tx,
byte[] clientPk,
byte[] clientSk,
byte[] serverPk)
KeyExchange.NativecryptoKxClientSessionKeys in interface KeyExchange.Nativerx - Shared key 1 of size KeyExchange.SESSIONKEYBYTES. This
should be used as an encryption key
to SEND data to the server.tx - Shared key 2 of size KeyExchange.SESSIONKEYBYTES. This
should be used as an encryption key to SEND
data to the client FROM the server.clientPk - Client public key of size KeyExchange.PUBLICKEYBYTES.clientSk - Client secret key of size KeyExchange.SECRETKEYBYTES.serverPk - Server public key of size KeyExchange.PUBLICKEYBYTES.public boolean cryptoKxServerSessionKeys(byte[] rx,
byte[] tx,
byte[] serverPk,
byte[] serverSk,
byte[] clientPk)
KeyExchange.NativecryptoKxServerSessionKeys in interface KeyExchange.Nativerx - Shared key 1 of size KeyExchange.SESSIONKEYBYTES. This
should be used as an encryption key
to SEND data to the client.tx - Shared key 2 of size KeyExchange.SESSIONKEYBYTES. This
should be used as an encryption key to SEND
data to the client FROM the client.serverPk - Server public key of size KeyExchange.PUBLICKEYBYTES.serverSk - Server secret key of size KeyExchange.SECRETKEYBYTES.clientPk - Client public key of size KeyExchange.PUBLICKEYBYTES.public KeyPair cryptoKxKeypair()
KeyExchange.LazycryptoKxKeypair in interface KeyExchange.Lazypublic KeyPair cryptoKxKeypair(byte[] seed)
KeyExchange.LazycryptoKxKeypair in interface KeyExchange.Lazyseed - A random seed of size KeyExchange.SEEDBYTES.public SessionPair cryptoKxClientSessionKeys(KeyPair clientKeyPair, KeyPair serverKeyPair) throws SodiumException
KeyExchange.LazycryptoKxClientSessionKeys in interface KeyExchange.LazyclientKeyPair - Provide the client's public and private key.serverKeyPair - Provide the server's public key only.SodiumException - Not provided the correct keys, or generation
of session keys failed.public SessionPair cryptoKxServerSessionKeys(Key serverPk, Key serverSk, Key clientPk) throws SodiumException
KeyExchange.LazycryptoKxServerSessionKeys in interface KeyExchange.LazyserverPk - Server public key of size KeyExchange.PUBLICKEYBYTES.serverSk - Server secret key of size KeyExchange.SECRETKEYBYTES.clientPk - Client public key of size KeyExchange.PUBLICKEYBYTES.SodiumExceptionpublic SessionPair cryptoKxClientSessionKeys(Key clientPk, Key clientSk, Key serverPk) throws SodiumException
KeyExchange.LazycryptoKxClientSessionKeys in interface KeyExchange.LazyclientPk - Client public key of size KeyExchange.PUBLICKEYBYTES.clientSk - Client secret key of size KeyExchange.SECRETKEYBYTES.serverPk - Server public key of size KeyExchange.PUBLICKEYBYTES.SodiumException - If the size of any of the keys are wrong.KeyExchange.Native.cryptoKxClientSessionKeys(byte[], byte[], byte[], byte[], byte[])public SessionPair cryptoKxServerSessionKeys(KeyPair serverKeyPair, KeyPair clientKeyPair) throws SodiumException
KeyExchange.LazycryptoKxServerSessionKeys in interface KeyExchange.LazyserverKeyPair - Provide the server's public and private key.clientKeyPair - Provide the client's public key only.SodiumException - Not provided the correct keys, or generation
of session keys failed.public boolean cryptoPwHash(byte[] outputHash,
int outputHashLen,
byte[] password,
int passwordLen,
byte[] salt,
long opsLimit,
com.sun.jna.NativeLong memLimit,
PwHash.Alg alg)
PwHash.NativeoutputHash.
Take note that the output of this does NOT output a traditional
Argon 2 string as the underlying native implementation calls argon2id_hash_raw
instead of argon2id_hash_encoded. If you want an Argon 2 encoded string please refer
to PwHash.Native.cryptoPwHashStr(byte[], byte[], int, long, NativeLong) instead.cryptoPwHash in interface PwHash.NativeoutputHash - Where to store the resulting password hash.outputHashLen - The password hash's length. Must be at least PwHash.BYTES_MIN.password - The password that you want to hash.passwordLen - The length of the password's bytes.salt - A salt that's randomly generated.opsLimit - The number of cycles to perform whilst hashing.
Between PwHash.OPSLIMIT_MIN and PwHash.OPSLIMIT_MAX.memLimit - The amount of memory to use.
Between PwHash.MEMLIMIT_MIN and PwHash.MEMLIMIT_MAX.alg - The algorithm to use. Please use PwHash.Alg.PWHASH_ALG_ARGON2ID13 for now.public boolean cryptoPwHashStr(byte[] outputStr,
byte[] password,
int passwordLen,
long opsLimit,
com.sun.jna.NativeLong memLimit)
PwHash.NativecryptoPwHashStr in interface PwHash.NativeoutputStr - An array to hold the hash. Must be at least PwHash.STR_BYTES.password - A password that you want to hash.passwordLen - The password's byte length.opsLimit - The number of cycles to perform whilst hashing.
Between PwHash.OPSLIMIT_MIN and PwHash.OPSLIMIT_MAX.memLimit - The amount of memory to use.
Between PwHash.MEMLIMIT_MIN and PwHash.MEMLIMIT_MAX.PwHash.Native.cryptoPwHashStrVerify(byte[], byte[], int)public boolean cryptoPwHashStrVerify(byte[] hash,
byte[] password,
int passwordLen)
PwHash.NativecryptoPwHashStrVerify in interface PwHash.Nativehash - The hash of the password.password - The password to check if it equals the hash's password.passwordLen - The checking password's length.public boolean cryptoPwHashStrNeedsRehash(byte[] hash,
long opsLimit,
com.sun.jna.NativeLong memLimit)
PwHash.NativecryptoPwHashStrNeedsRehash in interface PwHash.Nativehash - The hash.opsLimit - The operations limit used.memLimit - The memory limit used.public java.lang.String cryptoPwHash(java.lang.String password,
int lengthOfHash,
byte[] salt,
long opsLimit,
com.sun.jna.NativeLong memLimit,
PwHash.Alg alg)
throws SodiumException
PwHash.LazycryptoPwHash in interface PwHash.Lazypassword - The password to hash.lengthOfHash - The hash size that you want.
Anything between PwHash.BYTES_MIN and PwHash.BYTES_MAXsalt - A salt to use with the hash, generated randomly.opsLimit - The number of cycles to perform whilst hashing.
Between PwHash.OPSLIMIT_MIN and PwHash.OPSLIMIT_MAX.memLimit - The amount of memory to use.
Between PwHash.MEMLIMIT_MIN and PwHash.MEMLIMIT_MAX.alg - The algorithm to use. Defaults to PwHash.Alg.PWHASH_ALG_ARGON2ID13.SodiumException - If the password is too short or the opsLimit is not correct.public java.lang.String cryptoPwHashStr(java.lang.String password,
long opsLimit,
com.sun.jna.NativeLong memLimit)
throws SodiumException
PwHash.LazyPwHash.Alg.cryptoPwHashStr in interface PwHash.Lazypassword - The password string to hash.opsLimit - The number of cycles to perform whilst hashing.
Between PwHash.OPSLIMIT_MIN
and PwHash.OPSLIMIT_MAX.memLimit - The amount of memory to use.
Between PwHash.MEMLIMIT_MIN
and PwHash.MEMLIMIT_MAX.SodiumException - If the password could not be hashed.public java.lang.String cryptoPwHashStrRemoveNulls(java.lang.String password,
long opsLimit,
com.sun.jna.NativeLong memLimit)
throws SodiumException
PwHash.LazyPwHash.Alg.cryptoPwHashStrRemoveNulls in interface PwHash.Lazypassword - The password string to hash.opsLimit - The number of cycles to perform whilst hashing.
Between PwHash.OPSLIMIT_MIN
and PwHash.OPSLIMIT_MAX.memLimit - The amount of memory to use.
Between PwHash.MEMLIMIT_MIN
and PwHash.MEMLIMIT_MAX.SodiumException - If the password could not be hashed.public boolean cryptoPwHashStrVerify(java.lang.String hash,
java.lang.String password)
PwHash.LazycryptoPwHashStrVerify in interface PwHash.Lazyhash - The hash. Must be hexadecimal Helpers.Lazy.sodiumBin2Hex(byte[]).password - The password.public boolean cryptoHashSha256(byte[] out,
byte[] in,
long inLen)
cryptoHashSha256 in interface Hash.Nativepublic boolean cryptoHashSha256Init(Hash.State256 state)
cryptoHashSha256Init in interface Hash.LazycryptoHashSha256Init in interface Hash.Nativepublic boolean cryptoHashSha256Update(Hash.State256 state, byte[] in, long inLen)
cryptoHashSha256Update in interface Hash.Nativepublic boolean cryptoHashSha256Final(Hash.State256 state, byte[] out)
cryptoHashSha256Final in interface Hash.Nativepublic boolean cryptoHashSha512(byte[] out,
byte[] in,
long inLen)
cryptoHashSha512 in interface Hash.Nativepublic boolean cryptoHashSha512Init(Hash.State512 state)
cryptoHashSha512Init in interface Hash.LazycryptoHashSha512Init in interface Hash.Nativepublic boolean cryptoHashSha512Update(Hash.State512 state, byte[] in, long inLen)
cryptoHashSha512Update in interface Hash.Nativepublic boolean cryptoHashSha512Final(Hash.State512 state, byte[] out)
cryptoHashSha512Final in interface Hash.Nativepublic java.lang.String cryptoHashSha256(java.lang.String message)
throws SodiumException
cryptoHashSha256 in interface Hash.LazySodiumExceptionpublic java.lang.String cryptoHashSha512(java.lang.String message)
throws SodiumException
cryptoHashSha512 in interface Hash.LazySodiumExceptionpublic boolean cryptoHashSha256Update(Hash.State256 state, java.lang.String messagePart)
cryptoHashSha256Update in interface Hash.Lazypublic java.lang.String cryptoHashSha256Final(Hash.State256 state) throws SodiumException
cryptoHashSha256Final in interface Hash.LazySodiumExceptionpublic boolean cryptoHashSha512Update(Hash.State512 state, java.lang.String messagePart)
cryptoHashSha512Update in interface Hash.Lazypublic java.lang.String cryptoHashSha512Final(Hash.State512 state) throws SodiumException
cryptoHashSha512Final in interface Hash.LazySodiumExceptionpublic void cryptoSecretBoxKeygen(byte[] key)
SecretBox.NativeRandom.randomBytesBuf(int) but improves code
clarity and can prevent misuse by ensuring
that the provided key length is
always correct.cryptoSecretBoxKeygen in interface SecretBox.Nativekey - The key which is of size SecretBox.KEYBYTES.public boolean cryptoSecretBoxEasy(byte[] cipherText,
byte[] message,
long messageLen,
byte[] nonce,
byte[] key)
SecretBox.NativeSecretBox.Native.cryptoSecretBoxKeygen(byte[]).cryptoSecretBoxEasy in interface SecretBox.NativecipherText - The cipher text. Should be at least SecretBox.MACBYTES + messageLen.message - The message to encrypt.messageLen - The message byte array length.nonce - A nonce of size SecretBox.NONCEBYTES generated by Random.randomBytesBuf(int).key - The symmetric key generated by SecretBox.Native.cryptoSecretBoxKeygen(byte[]).public boolean cryptoSecretBoxOpenEasy(byte[] message,
byte[] cipherText,
long cipherTextLen,
byte[] nonce,
byte[] key)
SecretBox.NativeSecretBox.Native.cryptoSecretBoxKeygen(byte[]).cryptoSecretBoxOpenEasy in interface SecretBox.Nativemessage - The message will be put into here once decrypted.cipherText - The cipher produced by SecretBox.Native.cryptoSecretBoxEasy(byte[], byte[], long, byte[], byte[]).cipherTextLen - The cipher text length.nonce - This has to be the same nonce that was used when
encrypting using cryptoSecretBoxEasy.key - The key generated by SecretBox.Native.cryptoSecretBoxKeygen(byte[]).public boolean cryptoSecretBoxDetached(byte[] cipherText,
byte[] mac,
byte[] message,
long messageLen,
byte[] nonce,
byte[] key)
SecretBox.NativecryptoSecretBoxDetached in interface SecretBox.NativecipherText - The encrypted message of length messageLen.mac - The mac.message - The message to encrypt.messageLen - The message's length.nonce - A randomly generated nonce of size SecretBox.NONCEBYTES. Use Random.randomBytesBuf(int).key - The key generated by SecretBox.Native.cryptoSecretBoxKeygen(byte[]).public boolean cryptoSecretBoxOpenDetached(byte[] message,
byte[] cipherText,
byte[] mac,
long cipherTextLen,
byte[] nonce,
byte[] key)
SecretBox.NativecryptoSecretBoxOpenDetached in interface SecretBox.Nativemessage - The message length which is the same size as cipherTextLen.cipherText - The cipher.mac - The mac.cipherTextLen - The cipher text length.nonce - The nonce that was used in SecretBox.Native.cryptoSecretBoxDetached(byte[], byte[], byte[], long, byte[], byte[]).key - The key generated by SecretBox.Native.cryptoSecretBoxKeygen(byte[]).public Key cryptoSecretBoxKeygen()
SecretBox.LazycryptoSecretBoxKeygen in interface SecretBox.LazyHelpers.Lazy.sodiumBin2Hex(byte[]).public java.lang.String cryptoSecretBoxEasy(java.lang.String message,
byte[] nonce,
Key key)
throws SodiumException
SecretBox.LazycryptoSecretBoxEasy in interface SecretBox.Lazymessage - The message to encrypt.nonce - A randomly generated nonce of size SecretBox.NONCEBYTES. Use Random.randomBytesBuf(int).key - The key. A hexadecimal string that's been through Helpers.Lazy.sodiumBin2Hex(byte[]).Helpers.Lazy.sodiumBin2Hex(byte[])'ified.SodiumExceptionpublic java.lang.String cryptoSecretBoxOpenEasy(java.lang.String cipher,
byte[] nonce,
Key key)
throws SodiumException
SecretBox.LazycryptoSecretBoxOpenEasy in interface SecretBox.Lazycipher - The hexadecimal cipher text. See Helpers.Lazy.sodiumBin2Hex(byte[]).nonce - The nonce that was used when you encrypted with SecretBox.Lazy.cryptoSecretBoxEasy(String, byte[], Key).key - The key. A hexadecimal string that's been through Helpers.Lazy.sodiumBin2Hex(byte[]).SodiumExceptionpublic DetachedEncrypt cryptoSecretBoxDetached(java.lang.String message, byte[] nonce, Key key) throws SodiumException
SecretBox.LazycryptoSecretBoxDetached in interface SecretBox.Lazymessage - The message to encrypt.nonce - A randomly generated nonce of size SecretBox.NONCEBYTES. Use Random.randomBytesBuf(int).key - The key. A hexadecimal string that's been through Helpers.Lazy.sodiumBin2Hex(byte[]).Helpers.Lazy.sodiumBin2Hex(byte[])'ified.SodiumExceptionpublic java.lang.String cryptoSecretBoxOpenDetached(DetachedEncrypt cipherAndMac, byte[] nonce, Key key) throws SodiumException
SecretBox.LazycryptoSecretBoxOpenDetached in interface SecretBox.LazycipherAndMac - The hexadecimal cipher text. See Helpers.Lazy.sodiumBin2Hex(byte[]).nonce - The nonce that was used when you encrypted with SecretBox.Lazy.cryptoSecretBoxEasy(String, byte[], Key).key - The key. A hexadecimal string that's been through Helpers.Lazy.sodiumBin2Hex(byte[]).SodiumExceptionpublic boolean cryptoScalarMultBase(byte[] publicKey,
byte[] secretKey)
cryptoScalarMultBase in interface DiffieHellman.Nativepublic Key cryptoScalarMultBase(Key secretKey)
DiffieHellman.LazycryptoScalarMultBase in interface DiffieHellman.LazysecretKey - Provide the secret key.public boolean cryptoScalarMult(byte[] shared,
byte[] secretKey,
byte[] publicKey)
cryptoScalarMult in interface DiffieHellman.Nativepublic Key cryptoScalarMult(Key secretKey, Key publicKey)
DiffieHellman.LazycryptoScalarMult in interface DiffieHellman.LazysecretKey - Another user's public key.publicKey - A secret key.public boolean cryptoBoxKeypair(byte[] publicKey,
byte[] secretKey)
cryptoBoxKeypair in interface Box.Nativepublic boolean cryptoBoxSeedKeypair(byte[] publicKey,
byte[] secretKey,
byte[] seed)
cryptoBoxSeedKeypair in interface Box.Nativepublic boolean cryptoBoxEasy(byte[] cipherText,
byte[] message,
long messageLen,
byte[] nonce,
byte[] publicKey,
byte[] secretKey)
cryptoBoxEasy in interface Box.Nativepublic boolean cryptoBoxOpenEasy(byte[] message,
byte[] cipherText,
long cipherTextLen,
byte[] nonce,
byte[] publicKey,
byte[] secretKey)
cryptoBoxOpenEasy in interface Box.Nativepublic boolean cryptoBoxDetached(byte[] cipherText,
byte[] mac,
byte[] message,
long messageLen,
byte[] nonce,
byte[] publicKey,
byte[] secretKey)
cryptoBoxDetached in interface Box.Nativepublic boolean cryptoBoxOpenDetached(byte[] message,
byte[] cipherText,
byte[] mac,
long cipherTextLen,
byte[] nonce,
byte[] publicKey,
byte[] secretKey)
cryptoBoxOpenDetached in interface Box.Nativepublic boolean cryptoBoxBeforeNm(byte[] k,
byte[] publicKey,
byte[] secretKey)
cryptoBoxBeforeNm in interface Box.Nativepublic boolean cryptoBoxEasyAfterNm(byte[] cipherText,
byte[] message,
long messageLen,
byte[] nonce,
byte[] key)
cryptoBoxEasyAfterNm in interface Box.Nativepublic boolean cryptoBoxOpenEasyAfterNm(byte[] message,
byte[] cipher,
long cLen,
byte[] nonce,
byte[] key)
cryptoBoxOpenEasyAfterNm in interface Box.Nativepublic boolean cryptoBoxDetachedAfterNm(byte[] cipherText,
byte[] mac,
byte[] message,
long messageLen,
byte[] nonce,
byte[] key)
cryptoBoxDetachedAfterNm in interface Box.Nativepublic boolean cryptoBoxOpenDetachedAfterNm(byte[] message,
byte[] cipherText,
byte[] mac,
long cipherTextLen,
byte[] nonce,
byte[] key)
cryptoBoxOpenDetachedAfterNm in interface Box.Nativepublic boolean cryptoBoxSeal(byte[] cipher,
byte[] message,
long messageLen,
byte[] publicKey)
cryptoBoxSeal in interface Box.Nativepublic boolean cryptoBoxSealOpen(byte[] m,
byte[] cipher,
long cipherLen,
byte[] publicKey,
byte[] secretKey)
cryptoBoxSealOpen in interface Box.Nativepublic KeyPair cryptoBoxKeypair() throws SodiumException
Box.LazycryptoBoxKeypair in interface Box.LazySodiumExceptionpublic KeyPair cryptoBoxSeedKeypair(byte[] seed) throws SodiumException
Box.LazycryptoBoxSeedKeypair in interface Box.Lazyseed - The seed to generate the key.SodiumExceptionpublic java.lang.String cryptoBoxEasy(java.lang.String message,
byte[] nonce,
KeyPair keyPair)
throws SodiumException
Box.LazycryptoBoxEasy in interface Box.Lazymessage - The message.nonce - The nonce of size Box.NONCEBYTES.keyPair - A keypair.Helpers.Lazy.sodiumBin2Hex(byte[])'ified cipher text.SodiumExceptionpublic java.lang.String cryptoBoxOpenEasy(java.lang.String cipherText,
byte[] nonce,
KeyPair keyPair)
throws SodiumException
Box.LazycryptoBoxOpenEasy in interface Box.LazycipherText - Encrypted via Box.Lazy.cryptoBoxEasy(String, byte[], KeyPair)
and then Helpers.Lazy.sodiumBin2Hex(byte[])'ified.nonce - The nonce of size Box.NONCEBYTES.keyPair - A keypair.SodiumExceptionpublic java.lang.String cryptoBoxBeforeNm(byte[] publicKey,
byte[] secretKey)
throws SodiumException
Box.LazycryptoBoxBeforeNm in interface Box.LazypublicKey - A public key as generated by Box.Lazy.cryptoBoxKeypair().secretKey - A secret key as generated by Box.Lazy.cryptoBoxKeypair().SodiumException - Incorrect key lengths.public java.lang.String cryptoBoxBeforeNm(KeyPair keyPair) throws SodiumException
Box.LazycryptoBoxBeforeNm in interface Box.LazykeyPair - A public and secret key as generated by Box.Lazy.cryptoBoxKeypair().SodiumException - Incorrect key lengths.public java.lang.String cryptoBoxEasyAfterNm(java.lang.String message,
byte[] nonce,
java.lang.String sharedSecretKey)
throws SodiumException
Box.LazycryptoBoxEasyAfterNm in interface Box.Lazymessage - The message for encryption.nonce - A randomly generated nonce via Random.nonce(int)}.sharedSecretKey - The shared secret key as generated via Box.Lazy.cryptoBoxBeforeNm(KeyPair).SodiumException - Incorrect key lengths or enc error.public java.lang.String cryptoBoxOpenEasyAfterNm(java.lang.String cipher,
byte[] nonce,
java.lang.String sharedSecretKey)
throws SodiumException
Box.LazycryptoBoxOpenEasyAfterNm in interface Box.Lazycipher - The cipher text to be decrypted.nonce - The same nonce used to encrypt the cipher - Box.Lazy.cryptoBoxEasyAfterNm(String, byte[], String).sharedSecretKey - The shared secret key as generated via Box.Lazy.cryptoBoxBeforeNm(KeyPair).SodiumException - Incorrect key lengths or decryption error.public DetachedEncrypt cryptoBoxDetachedAfterNm(java.lang.String message, byte[] nonce, java.lang.String sharedSecretKey) throws SodiumException
Box.LazycryptoBoxDetachedAfterNm in interface Box.Lazymessage - The message to encrypt.nonce - A randomly generated nonce via Random.nonce(int)}.sharedSecretKey - The shared secret key as generated via Box.Lazy.cryptoBoxBeforeNm(KeyPair).SodiumException - Incorrect key lengths or enc error.public DetachedDecrypt cryptoBoxOpenDetachedAfterNm(DetachedEncrypt detachedEncrypt, byte[] nonce, java.lang.String sharedSecretKey) throws SodiumException
Box.LazycryptoBoxOpenDetachedAfterNm in interface Box.LazydetachedEncrypt - The cipher and mac used to decrypted the message.nonce - The same nonce used to encrypt - Box.Lazy.cryptoBoxDetachedAfterNm(String, byte[], String)}.sharedSecretKey - The shared secret key as generated via Box.Lazy.cryptoBoxBeforeNm(KeyPair).mac.SodiumException - Incorrect key lengths or decryption error.public java.lang.String cryptoBoxSealEasy(java.lang.String message,
Key publicKey)
throws SodiumException
Box.LazycryptoBoxSealEasy in interface Box.Lazymessage - The message.publicKey - A public key.Helpers.Lazy.sodiumBin2Hex(byte[])'ified cipher text.SodiumExceptionpublic java.lang.String cryptoBoxSealOpenEasy(java.lang.String cipherText,
KeyPair keyPair)
throws SodiumException
Box.LazycryptoBoxSealOpenEasy in interface Box.LazycipherText - Encrypted via Box.Lazy.cryptoBoxSealEasy(String, Key)
and then Helpers.Lazy.sodiumBin2Hex(byte[])'ified.keyPair - A keypair.SodiumExceptionpublic boolean cryptoSignInit(Sign.StateCryptoSign state)
Sign.NativecryptoSignInit in interface Sign.Nativestate - The state.public boolean cryptoSignUpdate(Sign.StateCryptoSign state, byte[] chunk, long chunkLength)
Sign.NativecryptoSignUpdate in interface Sign.Nativestate - The state.chunk - A part of the long message.chunkLength - Message length.public boolean cryptoSignFinalCreate(Sign.StateCryptoSign state, byte[] sig, com.sun.jna.Pointer sigLen, byte[] sk)
Sign.NativecryptoSignFinalCreate in interface Sign.Nativestate - The state.sig - Resultant signature.sigLen - Signature length.sk - Secret key.public boolean cryptoSignFinalVerify(Sign.StateCryptoSign state, byte[] sig, byte[] pk)
Sign.NativecryptoSignFinalVerify in interface Sign.Nativestate - The state.sig - Resultant signature.pk - Secret key.public boolean cryptoSignKeypair(byte[] publicKey,
byte[] secretKey)
Sign.NativecryptoSignKeypair in interface Sign.NativepublicKey - Public key.secretKey - Secret key.public boolean cryptoSignSeedKeypair(byte[] publicKey,
byte[] secretKey,
byte[] seed)
Sign.NativecryptoSignSeedKeypair in interface Sign.NativepublicKey - Public key.secretKey - Secret key.seed - The seed used to generate the keys.public boolean cryptoSign(byte[] signedMessage,
byte[] message,
long messageLen,
byte[] secretKey)
Sign.NativecryptoSign in interface Sign.NativesignedMessage - Signed message will be placed here.
It is Sign.BYTES + messageLen
long.message - The message.messageLen - The message length.secretKey - The secret key.public boolean cryptoSignOpen(byte[] message,
byte[] signedMessage,
long signedMessageLen,
byte[] publicKey)
Sign.NativecryptoSignOpen in interface Sign.Nativemessage - The message will be placed in here.signedMessage - The signed message.signedMessageLen - The signed message length.publicKey - Public key.public boolean cryptoSignDetached(byte[] signature,
byte[] message,
long messageLen,
byte[] secretKey)
Sign.NativeSign.Native.cryptoSign(byte[], byte[], long, byte[]) for that.cryptoSignDetached in interface Sign.Nativesignature - The signature will be added to this byte array.message - The message to sign.messageLen - The message length.secretKey - The secret key.public boolean cryptoSignVerifyDetached(byte[] signature,
byte[] message,
int messageLen,
byte[] publicKey)
Sign.Nativesignature is valid for the
message.cryptoSignVerifyDetached in interface Sign.Nativesignature - The signature.message - The message.messageLen - The message length.publicKey - The public key that signed the message.Sign.Native.cryptoSignDetached(byte[], byte[], long, byte[])public boolean convertPublicKeyEd25519ToCurve25519(byte[] curve,
byte[] ed)
Sign.NativeconvertPublicKeyEd25519ToCurve25519 in interface Sign.Nativecurve - The array in which the generated key will be placed.ed - The public key in ed25519.public boolean convertSecretKeyEd25519ToCurve25519(byte[] curve,
byte[] ed)
Sign.NativeconvertSecretKeyEd25519ToCurve25519 in interface Sign.Nativecurve - The array in which the generated key will be placed.ed - The secret key in ed25519.public boolean cryptoSignEd25519SkToSeed(byte[] seed,
byte[] ed)
Sign.NativecryptoSignEd25519SkToSeed in interface Sign.Nativeseed - The array in which the seed value will be placed. Must be Sign.ED25519_SEEDBYTES bytes long.ed - The secret key in ed25519.public boolean cryptoSignEd25519SkToPk(byte[] publicKey,
byte[] ed)
Sign.NativecryptoSignEd25519SkToPk in interface Sign.NativepublicKey - The array in which the public key will be placed. Must be Sign.PUBLICKEYBYTES bytes long.ed - The secret key in ed25519.public KeyPair cryptoSignKeypair() throws SodiumException
Sign.LazycryptoSignKeypair in interface Sign.LazySodiumExceptionpublic KeyPair cryptoSignSeedKeypair(byte[] seed) throws SodiumException
Sign.LazycryptoSignSeedKeypair in interface Sign.Lazyseed - The seed to generate keys.SodiumExceptionpublic KeyPair cryptoSignSecretKeyPair(Key secretKey) throws SodiumException
Sign.LazycryptoSignSecretKeyPair in interface Sign.LazysecretKey - The ed25519 secret key.SodiumExceptionpublic java.lang.String cryptoSign(java.lang.String message,
java.lang.String secretKey)
throws SodiumException
Sign.LazycryptoSign in interface Sign.Lazymessage - The message to sign.secretKey - The secret key.Helpers.Lazy.sodiumBin2Hex(byte[])-ified signed message.SodiumExceptionpublic java.lang.String cryptoSign(java.lang.String message,
Key secretKey)
throws SodiumException
Sign.LazycryptoSign in interface Sign.Lazymessage - The message to sign.secretKey - The secret key.Helpers.Lazy.sodiumBin2Hex(byte[])-ified signed message.SodiumExceptionpublic java.lang.String cryptoSignOpen(java.lang.String signedMessage,
Key publicKey)
Sign.LazycryptoSignOpen in interface Sign.LazysignedMessage - The signed message.publicKey - The public key that signed the message.public java.lang.String cryptoSignDetached(java.lang.String message,
Key secretKey)
throws SodiumException
Sign.LazySign.Lazy.cryptoSign(String, String) for that.cryptoSignDetached in interface Sign.Lazymessage - The message to sign.secretKey - The secret key.SodiumException - If could not sign.public boolean cryptoSignVerifyDetached(java.lang.String signature,
java.lang.String message,
Key publicKey)
Sign.Lazysignature is valid for the
message.cryptoSignVerifyDetached in interface Sign.Lazysignature - The signature.message - The message.publicKey - The public key that signed the message.Sign.Lazy.cryptoSignDetached(String, Key)public KeyPair convertKeyPairEd25519ToCurve25519(KeyPair ed25519KeyPair) throws SodiumException
Sign.LazyconvertKeyPairEd25519ToCurve25519 in interface Sign.Lazyed25519KeyPair - The key pair.SodiumException - If conversion was unsuccessful.public void cryptoSecretStreamKeygen(byte[] key)
SecretStream.NativecryptoSecretStreamKeygen in interface SecretStream.Nativekey - The key of size SecretStream.KEYBYTES.public boolean cryptoSecretStreamInitPush(SecretStream.State state, byte[] header, byte[] key)
SecretStream.NativecryptoSecretStreamInitPush in interface SecretStream.Nativestate - State to be used in other cryptoSecretStreamPush() functions.header - The header of size SecretStream.HEADERBYTES.key - The key as generated by SecretStream.Native.cryptoSecretStreamKeygen(byte[]).public boolean cryptoSecretStreamPush(SecretStream.State state, byte[] cipher, long[] cipherAddr, byte[] message, long messageLen, byte tag)
SecretStream.Nativemessage. This is like cryptoSecretStreamPush
but without additional data.cryptoSecretStreamPush in interface SecretStream.Nativestate - State.cipher - The resulting cipher of size SecretStream.ABYTES + messageLen.cipherAddr - The cipher address will be stored here if not null.message - The message to encrypt.messageLen - The message length.tag - The tag.public boolean cryptoSecretStreamPush(SecretStream.State state, byte[] cipher, byte[] message, long messageLen, byte tag)
SecretStream.Nativemessage. This is like cryptoSecretStreamPush
but without additional data or an address to store the cipher.cryptoSecretStreamPush in interface SecretStream.Nativestate - State as initialised in cryptoSecretStreamInitPush.cipher - The resulting cipher of size SecretStream.ABYTES + messageLen.message - The message to encrypt.messageLen - The message length.tag - The tag.public boolean cryptoSecretStreamPush(SecretStream.State state, byte[] cipher, long[] cipherAddr, byte[] message, long messageLen, byte[] additionalData, long additionalDataLen, byte tag)
SecretStream.Nativemessage.cryptoSecretStreamPush in interface SecretStream.Nativestate - State as initialised in cryptoSecretStreamInitPush.cipher - The resulting cipher of size SecretStream.ABYTES + messageLen.cipherAddr - The cipher address will be stored here if not null.message - The message to encrypt.messageLen - The message length.additionalData - Additional data.additionalDataLen - Additional data length.tag - The tag.public boolean cryptoSecretStreamInitPull(SecretStream.State state, byte[] header, byte[] key)
SecretStream.NativecryptoSecretStreamInitPull in interface SecretStream.Nativestate - State to be used in other cryptoSecretStreamPush() functions.header - The header of size SecretStream.HEADERBYTES.key - The key as generated by SecretStream.Native.cryptoSecretStreamKeygen(byte[]).public boolean cryptoSecretStreamPull(SecretStream.State state, byte[] message, long[] messageAddress, byte[] tag, byte[] cipher, long cipherLen, byte[] additionalData, long additionalDataLen)
SecretStream.NativecryptoSecretStreamPull in interface SecretStream.Nativestate - The state as put into cryptoSecretStreamInitPull.message - The message of size cipherLen - SecretStream.ABYTES.messageAddress - The place to store the message.tag - The tag.cipher - The resulting encrypted message.cipherLen - The cipher length.additionalData - Any authenticated data.additionalDataLen - Authenticated data length.public boolean cryptoSecretStreamPull(SecretStream.State state, byte[] message, byte[] tag, byte[] cipher, long cipherLen)
SecretStream.NativecryptoSecretStreamPull in interface SecretStream.Nativestate - The state as put into cryptoSecretStreamInitPull.message - The message of size cipherLen - SecretStream.ABYTES.tag - The tag.cipher - The resulting encrypted message.cipherLen - The cipher length.public Key cryptoSecretStreamKeygen()
SecretStream.LazycryptoSecretStreamKeygen in interface SecretStream.LazyHelpers.Lazy.sodiumBin2Hex(byte[]).public SecretStream.State cryptoSecretStreamInitPush(byte[] header, Key key) throws SodiumException
SecretStream.LazycryptoSecretStreamInitPush in interface SecretStream.Lazyheader - Header to supply.key - The key as generated by SecretStream.Lazy.cryptoSecretStreamKeygen().SodiumExceptionpublic java.lang.String cryptoSecretStreamPush(SecretStream.State state, java.lang.String message, byte tag) throws SodiumException
SecretStream.Lazymessage.cryptoSecretStreamPush in interface SecretStream.Lazystate - State as initialised in SecretStream.Lazy.cryptoSecretStreamInitPush(byte[], Key).message - The message to encrypt.tag - The tag.SodiumExceptionpublic SecretStream.State cryptoSecretStreamInitPull(byte[] header, Key key) throws SodiumException
SecretStream.LazycryptoSecretStreamInitPull in interface SecretStream.Lazyheader - The header of size SecretStream.HEADERBYTES.key - The key as generated by SecretStream.Lazy.cryptoSecretStreamKeygen()}.SodiumExceptionpublic java.lang.String cryptoSecretStreamPull(SecretStream.State state, java.lang.String cipher, byte[] tag) throws SodiumException
SecretStream.LazycryptoSecretStreamPull in interface SecretStream.Lazystate - The state as generated by SecretStream.Lazy.cryptoSecretStreamInitPull(byte[], Key).cipher - The resulting encrypted message.tag - The tag.SodiumExceptionpublic void cryptoSecretStreamRekey(SecretStream.State state)
SecretStream.NativecryptoSecretStreamRekey in interface SecretStream.LazycryptoSecretStreamRekey in interface SecretStream.Nativestate - The state to update.public void cryptoStreamChaCha20Keygen(byte[] key)
cryptoStreamChaCha20Keygen in interface Stream.Nativepublic boolean cryptoStreamChaCha20(byte[] c,
long cLen,
byte[] nonce,
byte[] key)
cryptoStreamChaCha20 in interface Stream.Nativepublic boolean cryptoStreamChaCha20Xor(byte[] cipher,
byte[] message,
long messageLen,
byte[] nonce,
byte[] key)
cryptoStreamChaCha20Xor in interface Stream.Nativepublic boolean cryptoStreamChacha20XorIc(byte[] cipher,
byte[] message,
long messageLen,
byte[] nonce,
long ic,
byte[] key)
cryptoStreamChacha20XorIc in interface Stream.Nativepublic void cryptoStreamChaCha20IetfKeygen(byte[] key)
cryptoStreamChaCha20IetfKeygen in interface Stream.Nativepublic boolean cryptoStreamChaCha20Ietf(byte[] c,
long cLen,
byte[] nonce,
byte[] key)
cryptoStreamChaCha20Ietf in interface Stream.Nativepublic boolean cryptoStreamChaCha20IetfXor(byte[] cipher,
byte[] message,
long messageLen,
byte[] nonce,
byte[] key)
cryptoStreamChaCha20IetfXor in interface Stream.Nativepublic boolean cryptoStreamChacha20IetfXorIc(byte[] cipher,
byte[] message,
long messageLen,
byte[] nonce,
long ic,
byte[] key)
cryptoStreamChacha20IetfXorIc in interface Stream.Nativepublic void cryptoStreamSalsa20Keygen(byte[] key)
cryptoStreamSalsa20Keygen in interface Stream.Nativepublic boolean cryptoStreamSalsa20(byte[] c,
long cLen,
byte[] nonce,
byte[] key)
cryptoStreamSalsa20 in interface Stream.Nativepublic boolean cryptoStreamSalsa20Xor(byte[] cipher,
byte[] message,
long messageLen,
byte[] nonce,
byte[] key)
cryptoStreamSalsa20Xor in interface Stream.Nativepublic boolean cryptoStreamSalsa20XorIc(byte[] cipher,
byte[] message,
long messageLen,
byte[] nonce,
long ic,
byte[] key)
cryptoStreamSalsa20XorIc in interface Stream.Nativepublic void cryptoStreamXSalsa20Keygen(byte[] key)
cryptoStreamXSalsa20Keygen in interface Stream.Nativepublic boolean cryptoStreamXSalsa20(byte[] c,
long cLen,
byte[] nonce,
byte[] key)
cryptoStreamXSalsa20 in interface Stream.Nativepublic boolean cryptoStreamXSalsa20Xor(byte[] cipher,
byte[] message,
long messageLen,
byte[] nonce,
byte[] key)
cryptoStreamXSalsa20Xor in interface Stream.Nativepublic Key cryptoStreamKeygen(Stream.Method method)
cryptoStreamKeygen in interface Stream.Lazypublic byte[] cryptoStream(byte[] nonce,
Key key,
Stream.Method method)
cryptoStream in interface Stream.Lazypublic java.lang.String cryptoStreamXor(java.lang.String message,
byte[] nonce,
Key key,
Stream.Method method)
cryptoStreamXor in interface Stream.Lazypublic java.lang.String cryptoStreamXorDecrypt(java.lang.String cipher,
byte[] nonce,
Key key,
Stream.Method method)
cryptoStreamXorDecrypt in interface Stream.Lazypublic java.lang.String cryptoStreamXorIc(java.lang.String message,
byte[] nonce,
long ic,
Key key,
Stream.Method method)
cryptoStreamXorIc in interface Stream.Lazypublic java.lang.String cryptoStreamXorIcDecrypt(java.lang.String cipher,
byte[] nonce,
long ic,
Key key,
Stream.Method method)
cryptoStreamXorIcDecrypt in interface Stream.Lazyprotected byte[] cryptoStreamDefaultXorIc(byte[] messageBytes,
byte[] nonce,
long ic,
Key key,
Stream.Method method)
public boolean cryptoAuth(byte[] tag,
byte[] in,
long inLen,
byte[] key)
Auth.NativecryptoAuth in interface Auth.Nativetag - Tag of size Auth.BYTES.in - A message.inLen - Message size.key - The key as generated by Auth.Native.cryptoAuthKeygen(byte[]).public boolean cryptoAuthVerify(byte[] tag,
byte[] in,
long inLen,
byte[] key)
Auth.NativecryptoAuthVerify in interface Auth.Nativetag - The tag.in - The message.inLen - Message bytes.key - The key as generated by Auth.Native.cryptoAuthKeygen(byte[]).public void cryptoAuthKeygen(byte[] k)
Auth.NativecryptoAuthKeygen in interface Auth.Nativek - Auth key of size Auth.KEYBYTES.public Key cryptoAuthKeygen()
Auth.LazycryptoAuthKeygen in interface Auth.Lazypublic java.lang.String cryptoAuth(java.lang.String message,
Key key)
throws SodiumException
Auth.LazycryptoAuth in interface Auth.Lazymessage - A message.key - The key as generated by Auth.Lazy.cryptoAuthKeygen().SodiumExceptionpublic boolean cryptoAuthVerify(java.lang.String tag,
java.lang.String message,
Key key)
Auth.LazycryptoAuthVerify in interface Auth.Lazytag - The tag.key - The key as generated by Auth.Lazy.cryptoAuthKeygen().public void cryptoAuthHMACSha256Keygen(byte[] key)
cryptoAuthHMACSha256Keygen in interface Auth.Nativepublic boolean cryptoAuthHMACSha256(byte[] out,
byte[] in,
long inLen,
byte[] k)
cryptoAuthHMACSha256 in interface Auth.Nativepublic boolean cryptoAuthHMACSha256Verify(byte[] h,
byte[] in,
long inLen,
byte[] k)
cryptoAuthHMACSha256Verify in interface Auth.Nativepublic boolean cryptoAuthHMACSha256Init(Auth.StateHMAC256 state, byte[] key, int keyLen)
cryptoAuthHMACSha256Init in interface Auth.Nativepublic boolean cryptoAuthHMACSha256Update(Auth.StateHMAC256 state, byte[] in, long inLen)
cryptoAuthHMACSha256Update in interface Auth.Nativepublic boolean cryptoAuthHMACSha256Final(Auth.StateHMAC256 state, byte[] out)
cryptoAuthHMACSha256Final in interface Auth.Nativepublic void cryptoAuthHMACSha512Keygen(byte[] key)
cryptoAuthHMACSha512Keygen in interface Auth.Nativepublic boolean cryptoAuthHMACSha512(byte[] out,
byte[] in,
long inLen,
byte[] k)
cryptoAuthHMACSha512 in interface Auth.Nativepublic boolean cryptoAuthHMACSha512Verify(byte[] h,
byte[] in,
long inLen,
byte[] k)
cryptoAuthHMACSha512Verify in interface Auth.Nativepublic boolean cryptoAuthHMACSha512Init(Auth.StateHMAC512 state, byte[] key, int keyLen)
cryptoAuthHMACSha512Init in interface Auth.Nativepublic boolean cryptoAuthHMACSha512Update(Auth.StateHMAC512 state, byte[] in, long inLen)
cryptoAuthHMACSha512Update in interface Auth.Nativepublic boolean cryptoAuthHMACSha512Final(Auth.StateHMAC512 state, byte[] out)
cryptoAuthHMACSha512Final in interface Auth.Nativepublic void cryptoAuthHMACSha512256Keygen(byte[] key)
cryptoAuthHMACSha512256Keygen in interface Auth.Nativepublic boolean cryptoAuthHMACSha512256(byte[] out,
byte[] in,
long inLen,
byte[] k)
cryptoAuthHMACSha512256 in interface Auth.Nativepublic boolean cryptoAuthHMACSha512256Verify(byte[] h,
byte[] in,
long inLen,
byte[] k)
cryptoAuthHMACSha512256Verify in interface Auth.Nativepublic boolean cryptoAuthHMACSha512256Init(Auth.StateHMAC512256 state, byte[] key, int keyLen)
cryptoAuthHMACSha512256Init in interface Auth.Nativepublic boolean cryptoAuthHMACSha512256Update(Auth.StateHMAC512256 state, byte[] in, long inLen)
cryptoAuthHMACSha512256Update in interface Auth.Nativepublic boolean cryptoAuthHMACSha512256Final(Auth.StateHMAC512256 state, byte[] out)
cryptoAuthHMACSha512256Final in interface Auth.Nativepublic Key cryptoAuthHMACShaKeygen(Auth.Type type)
cryptoAuthHMACShaKeygen in interface Auth.Lazypublic java.lang.String cryptoAuthHMACSha(Auth.Type type, java.lang.String in, Key key)
cryptoAuthHMACSha in interface Auth.Lazypublic boolean cryptoAuthHMACShaVerify(Auth.Type type, java.lang.String h, java.lang.String in, Key key)
cryptoAuthHMACShaVerify in interface Auth.Lazypublic boolean cryptoAuthHMACShaInit(Auth.StateHMAC256 state, Key key)
cryptoAuthHMACShaInit in interface Auth.Lazypublic boolean cryptoAuthHMACShaUpdate(Auth.StateHMAC256 state, java.lang.String in)
cryptoAuthHMACShaUpdate in interface Auth.Lazypublic java.lang.String cryptoAuthHMACShaFinal(Auth.StateHMAC256 state) throws SodiumException
cryptoAuthHMACShaFinal in interface Auth.LazySodiumExceptionpublic boolean cryptoAuthHMACShaInit(Auth.StateHMAC512 state, Key key)
cryptoAuthHMACShaInit in interface Auth.Lazypublic boolean cryptoAuthHMACShaUpdate(Auth.StateHMAC512 state, java.lang.String in)
cryptoAuthHMACShaUpdate in interface Auth.Lazypublic java.lang.String cryptoAuthHMACShaFinal(Auth.StateHMAC512 state) throws SodiumException
cryptoAuthHMACShaFinal in interface Auth.LazySodiumExceptionpublic boolean cryptoAuthHMACShaInit(Auth.StateHMAC512256 state, Key key)
cryptoAuthHMACShaInit in interface Auth.Lazypublic boolean cryptoAuthHMACShaUpdate(Auth.StateHMAC512256 state, java.lang.String in)
cryptoAuthHMACShaUpdate in interface Auth.Lazypublic java.lang.String cryptoAuthHMACShaFinal(Auth.StateHMAC512256 state) throws SodiumException
cryptoAuthHMACShaFinal in interface Auth.LazySodiumExceptionpublic boolean cryptoShortHash(byte[] out,
byte[] in,
long inLen,
byte[] key)
ShortHash.NativecryptoShortHash in interface ShortHash.Nativeout - The hashed text of size ShortHash.SIPHASH24_BYTES or
ShortHash.SIPHASHX24_BYTES depending on in size.in - The short-input text to hash of size ShortHash.BYTES or of size ShortHash.SIPHASHX24_BYTES.inLen - The length of the short-input.key - The key generated via ShortHash.Native.cryptoShortHashKeygen(byte[]).public void cryptoShortHashKeygen(byte[] k)
ShortHash.NativecryptoShortHashKeygen in interface ShortHash.Nativek - The key of size ShortHash.SIPHASH24_KEYBYTES.public java.lang.String cryptoShortHash(java.lang.String in,
Key key)
throws SodiumException
ShortHash.LazycryptoShortHash in interface ShortHash.Lazyin - The short message to hash.key - The key generated via ShortHash.Lazy.cryptoShortHashKeygen().ShortHash.BYTES.SodiumExceptionpublic Key cryptoShortHashKeygen()
ShortHash.LazycryptoShortHashKeygen in interface ShortHash.Lazypublic boolean cryptoGenericHash(byte[] out,
int outLen,
byte[] in,
long inLen,
byte[] key,
int keyLen)
GenericHash.NativecryptoGenericHash in interface GenericHash.Nativeout - A place to store the resulting byte array.
You may choose the output size, however the minimum
recommended output size is GenericHash.BYTES.
You may also specify a value
between GenericHash.BYTES_MIN and GenericHash.BYTES_MAX.outLen - Size of out.in - The text to hash.inLen - The size of in.key - The key generated by GenericHash.Native.cryptoGenericHashKeygen(byte[]).keyLen - The length of the key.public boolean cryptoGenericHash(byte[] out,
int outLen,
byte[] in,
long inLen)
GenericHash.NativecryptoGenericHash in interface GenericHash.Nativeout - A place to store the resulting byte array.
You may choose the output size, however the minimum
recommended output size is GenericHash.BYTES.
You may also specify a value
between GenericHash.BYTES_MIN and GenericHash.BYTES_MAX.outLen - Size of out.in - The text to hash.inLen - The size of in.GenericHash.Native.cryptoGenericHash(byte[], int, byte[], long, byte[], int)public boolean cryptoGenericHashInit(byte[] state,
byte[] key,
int keyLength,
int outLen)
GenericHash.NativecryptoGenericHashInit in interface GenericHash.Nativestate - The state which holds the key
in memory for further hashing.key - The key generated by GenericHash.Native.cryptoGenericHashKeygen(byte[]).keyLength - Length of the key.outLen - The size of the hash array. Please
see the param out in
GenericHash.Native.cryptoGenericHash(byte[], int, byte[], long, byte[], int)
for more information.public boolean cryptoGenericHashInit(byte[] state,
int outLen)
GenericHash.NativecryptoGenericHashInit in interface GenericHash.Nativestate - The state which holds the current state
in memory for further hashing.outLen - The size of the hash array. Please
see the param out in
GenericHash.Native.cryptoGenericHash(byte[], int, byte[], long, byte[], int)
for more information.public boolean cryptoGenericHashUpdate(byte[] state,
byte[] in,
long inLen)
GenericHash.NativecryptoGenericHashUpdate in interface GenericHash.Nativestate - The state.in - Another hash part.inLen - The length if the hash part.public boolean cryptoGenericHashFinal(byte[] state,
byte[] out,
int outLen)
GenericHash.Nativeout.cryptoGenericHashFinal in interface GenericHash.Nativestate - The state.out - The final hash.outLen - The length of the hash.public int cryptoGenericHashStateBytes()
cryptoGenericHashStateBytes in interface GenericHash.Nativepublic void cryptoGenericHashKeygen(byte[] k)
GenericHash.Nativek.cryptoGenericHashKeygen in interface GenericHash.Nativek - A place to store the generated key
of size GenericHash.KEYBYTES. Though,
it may be between GenericHash.KEYBYTES
and GenericHash.KEYBYTES_MAX.public Key cryptoGenericHashKeygen()
GenericHash.LazycryptoGenericHashKeygen in interface GenericHash.Lazypublic Key cryptoGenericHashKeygen(int size) throws SodiumException
GenericHash.LazycryptoGenericHashKeygen in interface GenericHash.Lazysize - The size of the hashing key between
GenericHash.KEYBYTES and GenericHash.KEYBYTES_MAX.SodiumExceptionpublic java.lang.String cryptoGenericHash(java.lang.String in,
Key key)
throws SodiumException
GenericHash.LazyPwHash.Lazy.cryptoPwHashStr(String, long, NativeLong)}
instead.cryptoGenericHash in interface GenericHash.Lazyin - The string to hash.key - Can be null.SodiumExceptionpublic java.lang.String cryptoGenericHash(java.lang.String in)
throws SodiumException
GenericHash.LazycryptoGenericHash in interface GenericHash.Lazyin - The string to hash.SodiumExceptionpublic boolean cryptoGenericHashInit(byte[] state,
Key key,
int outLen)
GenericHash.LazycryptoGenericHashInit in interface GenericHash.Lazystate - The state which holds the key and operation.key - The key as generated by GenericHash.Lazy.cryptoGenericHashKeygen().outLen - The size of the final hash.public boolean cryptoGenericHashUpdate(byte[] state,
java.lang.String in)
GenericHash.LazycryptoGenericHashUpdate in interface GenericHash.Lazystate - State as put into GenericHash.Lazy.cryptoGenericHashInit(byte[], Key, int).in - A part of a string to hash.public java.lang.String cryptoGenericHashFinal(byte[] state,
int outLen)
throws SodiumException
GenericHash.LazycryptoGenericHashFinal in interface GenericHash.Lazystate - State as put into GenericHash.Lazy.cryptoGenericHashInit(byte[], Key, int).outLen - The size of the final hash.SodiumExceptionpublic void cryptoAeadChaCha20Poly1305Keygen(byte[] key)
cryptoAeadChaCha20Poly1305Keygen in interface AEAD.Nativepublic boolean cryptoAeadChaCha20Poly1305Encrypt(byte[] c,
long[] cLen,
byte[] m,
long mLen,
byte[] ad,
long adLen,
byte[] nSec,
byte[] nPub,
byte[] k)
cryptoAeadChaCha20Poly1305Encrypt in interface AEAD.Nativepublic boolean cryptoAeadChaCha20Poly1305Decrypt(byte[] m,
long[] mLen,
byte[] nSec,
byte[] c,
long cLen,
byte[] ad,
long adLen,
byte[] nPub,
byte[] k)
cryptoAeadChaCha20Poly1305Decrypt in interface AEAD.Nativepublic boolean cryptoAeadChaCha20Poly1305EncryptDetached(byte[] c,
byte[] mac,
long[] macLenAddress,
byte[] m,
long mLen,
byte[] ad,
long adLen,
byte[] nSec,
byte[] nPub,
byte[] k)
cryptoAeadChaCha20Poly1305EncryptDetached in interface AEAD.Nativepublic boolean cryptoAeadChaCha20Poly1305DecryptDetached(byte[] m,
byte[] nSec,
byte[] c,
long cLen,
byte[] mac,
byte[] ad,
long adLen,
byte[] nPub,
byte[] k)
cryptoAeadChaCha20Poly1305DecryptDetached in interface AEAD.Nativepublic void cryptoAeadChaCha20Poly1305IetfKeygen(byte[] key)
cryptoAeadChaCha20Poly1305IetfKeygen in interface AEAD.Nativepublic boolean cryptoAeadChaCha20Poly1305IetfEncrypt(byte[] c,
long[] cLen,
byte[] m,
long mLen,
byte[] ad,
long adLen,
byte[] nSec,
byte[] nPub,
byte[] k)
cryptoAeadChaCha20Poly1305IetfEncrypt in interface AEAD.Nativepublic boolean cryptoAeadChaCha20Poly1305IetfDecrypt(byte[] m,
long[] mLen,
byte[] nSec,
byte[] c,
long cLen,
byte[] ad,
long adLen,
byte[] nPub,
byte[] k)
cryptoAeadChaCha20Poly1305IetfDecrypt in interface AEAD.Nativepublic boolean cryptoAeadChaCha20Poly1305IetfEncryptDetached(byte[] c,
byte[] mac,
long[] macLenAddress,
byte[] m,
long mLen,
byte[] ad,
long adLen,
byte[] nSec,
byte[] nPub,
byte[] k)
cryptoAeadChaCha20Poly1305IetfEncryptDetached in interface AEAD.Nativepublic boolean cryptoAeadChaCha20Poly1305IetfDecryptDetached(byte[] m,
byte[] nSec,
byte[] c,
long cLen,
byte[] mac,
byte[] ad,
long adLen,
byte[] nPub,
byte[] k)
cryptoAeadChaCha20Poly1305IetfDecryptDetached in interface AEAD.Nativepublic void cryptoAeadXChaCha20Poly1305IetfKeygen(byte[] k)
cryptoAeadXChaCha20Poly1305IetfKeygen in interface AEAD.Nativepublic boolean cryptoAeadXChaCha20Poly1305IetfEncrypt(byte[] c,
long[] cLen,
byte[] m,
long mLen,
byte[] ad,
long adLen,
byte[] nSec,
byte[] nPub,
byte[] k)
cryptoAeadXChaCha20Poly1305IetfEncrypt in interface AEAD.Nativepublic boolean cryptoAeadXChaCha20Poly1305IetfDecrypt(byte[] m,
long[] mLen,
byte[] nSec,
byte[] c,
long cLen,
byte[] ad,
long adLen,
byte[] nPub,
byte[] k)
cryptoAeadXChaCha20Poly1305IetfDecrypt in interface AEAD.Nativepublic boolean cryptoAeadXChaCha20Poly1305IetfEncryptDetached(byte[] c,
byte[] mac,
long[] macLenAddress,
byte[] m,
long mLen,
byte[] ad,
long adLen,
byte[] nSec,
byte[] nPub,
byte[] k)
cryptoAeadXChaCha20Poly1305IetfEncryptDetached in interface AEAD.Nativepublic boolean cryptoAeadXChaCha20Poly1305IetfDecryptDetached(byte[] m,
byte[] nSec,
byte[] c,
long cLen,
byte[] mac,
byte[] ad,
long adLen,
byte[] nPub,
byte[] k)
cryptoAeadXChaCha20Poly1305IetfDecryptDetached in interface AEAD.Nativepublic void cryptoAeadAES256GCMKeygen(byte[] key)
cryptoAeadAES256GCMKeygen in interface AEAD.Nativepublic boolean cryptoAeadAES256GCMEncrypt(byte[] cipher,
long[] cipherLen,
byte[] message,
long messageLen,
byte[] additionalData,
long additionalDataLen,
byte[] nSec,
byte[] nPub,
byte[] key)
cryptoAeadAES256GCMEncrypt in interface AEAD.Nativepublic boolean cryptoAeadAES256GCMDecrypt(byte[] message,
long[] messageLen,
byte[] nSec,
byte[] cipher,
long cipherLen,
byte[] additionalData,
long additionalDataLen,
byte[] nPub,
byte[] key)
cryptoAeadAES256GCMDecrypt in interface AEAD.Nativepublic boolean cryptoAeadAES256GCMEncryptDetached(byte[] cipher,
byte[] mac,
long[] macLenAddress,
byte[] message,
long messageLen,
byte[] additionalData,
long additionalDataLen,
byte[] nSec,
byte[] nPub,
byte[] key)
cryptoAeadAES256GCMEncryptDetached in interface AEAD.Nativepublic boolean cryptoAeadAES256GCMDecryptDetached(byte[] message,
byte[] nSec,
byte[] cipher,
long cipherLen,
byte[] mac,
byte[] additionalData,
long additionalDataLen,
byte[] nPub,
byte[] key)
cryptoAeadAES256GCMDecryptDetached in interface AEAD.Nativepublic boolean cryptoAeadAES256GCMIsAvailable()
cryptoAeadAES256GCMIsAvailable in interface AEAD.Nativepublic Key keygen(AEAD.Method method)
public java.lang.String encrypt(java.lang.String m,
java.lang.String additionalData,
byte[] nPub,
Key k,
AEAD.Method method)
public java.lang.String encrypt(java.lang.String m,
java.lang.String additionalData,
byte[] nSec,
byte[] nPub,
Key k,
AEAD.Method method)
public java.lang.String decrypt(java.lang.String cipher,
java.lang.String additionalData,
byte[] nPub,
Key k,
AEAD.Method method)
throws javax.crypto.AEADBadTagException
public java.lang.String decrypt(java.lang.String cipher,
java.lang.String additionalData,
byte[] nSec,
byte[] nPub,
Key k,
AEAD.Method method)
throws javax.crypto.AEADBadTagException
public DetachedEncrypt encryptDetached(java.lang.String m, java.lang.String additionalData, byte[] nSec, byte[] nPub, Key k, AEAD.Method method)
encryptDetached in interface AEAD.Lazypublic DetachedDecrypt decryptDetached(DetachedEncrypt detachedEncrypt, java.lang.String additionalData, byte[] nSec, byte[] nPub, Key k, AEAD.Method method) throws javax.crypto.AEADBadTagException
decryptDetached in interface AEAD.Lazyjavax.crypto.AEADBadTagExceptionpublic boolean successful(int res)
successful in interface Basepublic java.lang.String str(byte[] bs)
BaseHelpers.Lazy.sodiumBin2Hex(byte[])
to convert your byte array to a hexadecimal string that ensures no nulls or carriage breaks.public java.lang.String str(byte[] bs,
java.nio.charset.Charset charset)
BaseHelpers.Lazy.sodiumBin2Hex(byte[])
to convert your byte array to a hexadecimal string that ensures no nulls or carriage breaks.public byte[] bytes(java.lang.String s)
Basepublic boolean wrongLen(int byteLength,
int shouldBe)
public boolean wrongLen(int byteLength,
long shouldBe)
public byte[] removeNulls(byte[] bs)
BaseremoveNulls in interface Basebs - A byte array.public abstract Sodium getSodium()
public static void main(java.lang.String[] args)
throws SodiumException
SodiumException