Package com.codevasp.lazysodium
Class LazySodium
java.lang.Object
com.codevasp.lazysodium.LazySodium
- All Implemented Interfaces:
AEAD.Lazy,AEAD.Native,Auth.Lazy,Auth.Native,Base,Box.Lazy,Box.Native,DiffieHellman.Lazy,DiffieHellman.Native,GenericHash.Lazy,GenericHash.Native,Hash.Lazy,Hash.Native,Helpers.Lazy,Helpers.Native,KeyDerivation.Lazy,KeyDerivation.Native,KeyExchange.Lazy,KeyExchange.Native,Padding.Lazy,Padding.Native,PwHash.Lazy,PwHash.Native,Random,Ristretto255.Lazy,Ristretto255.Native,SecretBox.Lazy,SecretBox.Native,SecretStream.Lazy,SecretStream.Native,SecureMemory.Lazy,SecureMemory.Native,ShortHash.Lazy,ShortHash.Native,Sign.Lazy,Sign.Native,Stream.Lazy,Stream.Native
- Direct Known Subclasses:
LazySodiumJava
public abstract class LazySodium
extends 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, Ristretto255.Native, Ristretto255.Lazy
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic Base64Facadeprotected final Charsetprotected final MessageEncoder -
Constructor Summary
ConstructorsConstructorDescriptionLazySodium(MessageEncoder messageEncoder) LazySodium(Charset charset) LazySodium(Charset charset, MessageEncoder messageEncoder) -
Method Summary
Modifier and TypeMethodDescriptionbyte[]Convert a string to directly bytes.convertKeyPairEd25519ToCurve25519(KeyPair ed25519KeyPair) Converts a ed25519 keypair to a curve25519 keypair.booleanconvertPublicKeyEd25519ToCurve25519(byte[] curve, byte[] ed) Converts a public ed25519 key to a public curve25519 key.booleanconvertSecretKeyEd25519ToCurve25519(byte[] curve, byte[] ed) Converts a secret ed25519 key to a secret curve25519 key.booleancryptoAeadAES256GCMDecrypt(byte[] message, long[] messageLen, byte[] nSec, byte[] cipher, long cipherLen, byte[] additionalData, long additionalDataLen, byte[] nPub, byte[] key) booleancryptoAeadAES256GCMDecryptDetached(byte[] message, byte[] nSec, byte[] cipher, long cipherLen, byte[] mac, byte[] additionalData, long additionalDataLen, byte[] nPub, byte[] key) booleancryptoAeadAES256GCMEncrypt(byte[] cipher, long[] cipherLen, byte[] message, long messageLen, byte[] additionalData, long additionalDataLen, byte[] nSec, byte[] nPub, byte[] key) booleancryptoAeadAES256GCMEncryptDetached(byte[] cipher, byte[] mac, long[] macLenAddress, byte[] message, long messageLen, byte[] additionalData, long additionalDataLen, byte[] nSec, byte[] nPub, byte[] key) booleanvoidcryptoAeadAES256GCMKeygen(byte[] key) booleancryptoAeadChaCha20Poly1305Decrypt(byte[] m, long[] mLen, byte[] nSec, byte[] c, long cLen, byte[] ad, long adLen, byte[] nPub, byte[] k) booleancryptoAeadChaCha20Poly1305DecryptDetached(byte[] m, byte[] nSec, byte[] c, long cLen, byte[] mac, byte[] ad, long adLen, byte[] nPub, byte[] k) booleancryptoAeadChaCha20Poly1305Encrypt(byte[] c, long[] cLen, byte[] m, long mLen, byte[] ad, long adLen, byte[] nSec, byte[] nPub, byte[] k) booleancryptoAeadChaCha20Poly1305EncryptDetached(byte[] c, byte[] mac, long[] macLenAddress, byte[] m, long mLen, byte[] ad, long adLen, byte[] nSec, byte[] nPub, byte[] k) booleancryptoAeadChaCha20Poly1305IetfDecrypt(byte[] m, long[] mLen, byte[] nSec, byte[] c, long cLen, byte[] ad, long adLen, byte[] nPub, byte[] k) booleancryptoAeadChaCha20Poly1305IetfDecryptDetached(byte[] m, byte[] nSec, byte[] c, long cLen, byte[] mac, byte[] ad, long adLen, byte[] nPub, byte[] k) booleancryptoAeadChaCha20Poly1305IetfEncrypt(byte[] c, long[] cLen, byte[] m, long mLen, byte[] ad, long adLen, byte[] nSec, byte[] nPub, byte[] k) booleancryptoAeadChaCha20Poly1305IetfEncryptDetached(byte[] c, byte[] mac, long[] macLenAddress, byte[] m, long mLen, byte[] ad, long adLen, byte[] nSec, byte[] nPub, byte[] k) voidcryptoAeadChaCha20Poly1305IetfKeygen(byte[] key) voidcryptoAeadChaCha20Poly1305Keygen(byte[] key) booleancryptoAeadXChaCha20Poly1305IetfDecrypt(byte[] m, long[] mLen, byte[] nSec, byte[] c, long cLen, byte[] ad, long adLen, byte[] nPub, byte[] k) booleancryptoAeadXChaCha20Poly1305IetfDecryptDetached(byte[] m, byte[] nSec, byte[] c, long cLen, byte[] mac, byte[] ad, long adLen, byte[] nPub, byte[] k) booleancryptoAeadXChaCha20Poly1305IetfEncrypt(byte[] c, long[] cLen, byte[] m, long mLen, byte[] ad, long adLen, byte[] nSec, byte[] nPub, byte[] k) booleancryptoAeadXChaCha20Poly1305IetfEncryptDetached(byte[] c, byte[] mac, long[] macLenAddress, byte[] m, long mLen, byte[] ad, long adLen, byte[] nSec, byte[] nPub, byte[] k) voidcryptoAeadXChaCha20Poly1305IetfKeygen(byte[] k) booleancryptoAuth(byte[] tag, byte[] in, long inLen, byte[] key) Computes a tag for the message in, whose length is inLen bytes, and the key k.cryptoAuth(String message, Key key) Computes a tag for the message in.cryptoAuthHMACSha(Auth.Type type, String in, Key key) booleancryptoAuthHMACSha256(byte[] out, byte[] in, long inLen, byte[] k) booleancryptoAuthHMACSha256Final(Auth.StateHMAC256 state, byte[] out) booleancryptoAuthHMACSha256Init(Auth.StateHMAC256 state, byte[] key, int keyLen) voidcryptoAuthHMACSha256Keygen(byte[] key) booleancryptoAuthHMACSha256Update(Auth.StateHMAC256 state, byte[] in, long inLen) booleancryptoAuthHMACSha256Verify(byte[] h, byte[] in, long inLen, byte[] k) booleancryptoAuthHMACSha512(byte[] out, byte[] in, long inLen, byte[] k) booleancryptoAuthHMACSha512256(byte[] out, byte[] in, long inLen, byte[] k) booleancryptoAuthHMACSha512256Final(Auth.StateHMAC512256 state, byte[] out) booleancryptoAuthHMACSha512256Init(Auth.StateHMAC512256 state, byte[] key, int keyLen) voidcryptoAuthHMACSha512256Keygen(byte[] key) booleancryptoAuthHMACSha512256Update(Auth.StateHMAC512256 state, byte[] in, long inLen) booleancryptoAuthHMACSha512256Verify(byte[] h, byte[] in, long inLen, byte[] k) booleancryptoAuthHMACSha512Final(Auth.StateHMAC512 state, byte[] out) booleancryptoAuthHMACSha512Init(Auth.StateHMAC512 state, byte[] key, int keyLen) voidcryptoAuthHMACSha512Keygen(byte[] key) booleancryptoAuthHMACSha512Update(Auth.StateHMAC512 state, byte[] in, long inLen) booleancryptoAuthHMACSha512Verify(byte[] h, byte[] in, long inLen, byte[] k) booleancryptoAuthHMACShaInit(Auth.StateHMAC256 state, Key key) booleancryptoAuthHMACShaInit(Auth.StateHMAC512256 state, Key key) booleancryptoAuthHMACShaInit(Auth.StateHMAC512 state, Key key) booleancryptoAuthHMACShaUpdate(Auth.StateHMAC256 state, String in) booleancryptoAuthHMACShaUpdate(Auth.StateHMAC512256 state, String in) booleancryptoAuthHMACShaUpdate(Auth.StateHMAC512 state, String in) booleancryptoAuthHMACShaVerify(Auth.Type type, String h, String in, Key key) Generate an authentication key.voidcryptoAuthKeygen(byte[] k) Generate an authentication key.booleancryptoAuthVerify(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.booleancryptoAuthVerify(String tag, String message, Key key) Verifies that the tag valid tag for the message.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.booleancryptoBoxBeforeNm(byte[] k, byte[] publicKey, byte[] secretKey) 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.booleancryptoBoxDetached(byte[] cipherText, byte[] mac, byte[] message, long messageLen, byte[] nonce, byte[] publicKey, byte[] secretKey) booleancryptoBoxDetachedAfterNm(byte[] cipherText, byte[] mac, byte[] message, long messageLen, byte[] nonce, byte[] key) cryptoBoxDetachedAfterNm(String message, byte[] nonce, String sharedSecretKey) Encrypt a message but allow for storage of the mac separately.booleancryptoBoxEasy(byte[] cipherText, byte[] message, long messageLen, byte[] nonce, byte[] publicKey, byte[] secretKey) cryptoBoxEasy(String message, byte[] nonce, KeyPair keyPair) Encrypts a message.booleancryptoBoxEasyAfterNm(byte[] cipherText, byte[] message, long messageLen, byte[] nonce, byte[] key) cryptoBoxEasyAfterNm(String message, byte[] nonce, String sharedSecretKey) Encrypt a message.Generate a secret and public key.booleancryptoBoxKeypair(byte[] publicKey, byte[] secretKey) booleancryptoBoxOpenDetached(byte[] message, byte[] cipherText, byte[] mac, long cipherTextLen, byte[] nonce, byte[] publicKey, byte[] secretKey) booleancryptoBoxOpenDetachedAfterNm(byte[] message, byte[] cipherText, byte[] mac, long cipherTextLen, byte[] nonce, byte[] key) cryptoBoxOpenDetachedAfterNm(DetachedEncrypt detachedEncrypt, byte[] nonce, String sharedSecretKey) Decrypt a message.booleancryptoBoxOpenEasy(byte[] message, byte[] cipherText, long cipherTextLen, byte[] nonce, byte[] publicKey, byte[] secretKey) cryptoBoxOpenEasy(String cipherText, byte[] nonce, KeyPair keyPair) Decrypts a previously encrypted message.booleancryptoBoxOpenEasyAfterNm(byte[] message, byte[] cipher, long cLen, byte[] nonce, byte[] key) cryptoBoxOpenEasyAfterNm(String cipher, byte[] nonce, String sharedSecretKey) Decrypt a message.booleancryptoBoxSeal(byte[] cipher, byte[] message, long messageLen, byte[] publicKey) cryptoBoxSealEasy(String message, Key publicKey) Encrypts a message.booleancryptoBoxSealOpen(byte[] m, byte[] cipher, long cipherLen, byte[] publicKey, byte[] secretKey) cryptoBoxSealOpenEasy(String cipherText, KeyPair keyPair) Decrypts a previously encrypted message.cryptoBoxSeedKeypair(byte[] seed) Generate a public and secret key deterministically.booleancryptoBoxSeedKeypair(byte[] publicKey, byte[] secretKey, byte[] seed) booleancryptoCoreRistretto255Add(byte[] result, byte[] p, byte[] q) Adds two given Ristretto255 pointspandqand puts the representation of the result intoresult.Adds two given Ristretto255 pointspandqand returns the result.cryptoCoreRistretto255FromHash(byte[] hash) Maps aRistretto255.RISTRETTO255_HASH_BYTESbytes hash to a Ristretto255 point.booleancryptoCoreRistretto255FromHash(byte[] point, byte[] hash) Maps aRistretto255.RISTRETTO255_HASH_BYTESbytes hash to a Ristretto255 point and puts its representation topoint.Maps aRistretto255.RISTRETTO255_HASH_BYTESbytes hash to aRistretto255.RistrettoPoint.booleancryptoCoreRistretto255IsValidPoint(byte[] point) Returns whether the passed bytes represent a valid Ristretto255 point.booleanReturns whether the passed encoded string represents a valid Ristretto255 point.Chooses a random Ristretto255 point and returns it.voidcryptoCoreRistretto255Random(byte[] point) Chooses a random Ristretto255 point and puts its representation topointcryptoCoreRistretto255ScalarAdd(byte[] x, byte[] y) Adds two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.voidcryptoCoreRistretto255ScalarAdd(byte[] result, byte[] x, byte[] y) Adds two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.cryptoCoreRistretto255ScalarAdd(byte[] x, String y) Adds two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.cryptoCoreRistretto255ScalarAdd(byte[] x, BigInteger y) Adds two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.cryptoCoreRistretto255ScalarAdd(String x, byte[] y) Adds two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.Adds two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.Adds two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.cryptoCoreRistretto255ScalarAdd(BigInteger x, byte[] y) Adds two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.Adds two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.Adds two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.cryptoCoreRistretto255ScalarComplement(byte[] scalar) Calculates the result R for the given scalar value such thatR + scalar = 1 (mod L)withLbeing the order of the Ristretto255 group.voidcryptoCoreRistretto255ScalarComplement(byte[] result, byte[] scalar) Calculates the result R for the given scalar value such thatR + scalar = 1 (mod L)withLbeing the order of the Ristretto255 group.cryptoCoreRistretto255ScalarComplement(String scalarEnc) Calculates the result R for the given scalar value such thatR + scalar = 1 (mod L)withLbeing the order of the Ristretto255 group.Calculates the result R for the given scalar value such thatR + scalar = 1 (mod L)withLbeing the order of the Ristretto255 group.cryptoCoreRistretto255ScalarInvert(byte[] scalar) Calculates the multiplicative inverse of the given scalar value.booleancryptoCoreRistretto255ScalarInvert(byte[] result, byte[] scalar) Calculates the multiplicative inverse of the given scalar value.cryptoCoreRistretto255ScalarInvert(String scalarEnc) Calculates the multiplicative inverse of the given scalar value.Calculates the multiplicative inverse of the given scalar value.cryptoCoreRistretto255ScalarMul(byte[] x, byte[] y) Multiplies two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.voidcryptoCoreRistretto255ScalarMul(byte[] result, byte[] x, byte[] y) Multiplies two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.cryptoCoreRistretto255ScalarMul(byte[] x, String y) Multiplies two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.cryptoCoreRistretto255ScalarMul(byte[] x, BigInteger y) Multiplies two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.cryptoCoreRistretto255ScalarMul(String x, byte[] y) Multiplies two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.Multiplies two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.Multiplies two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.cryptoCoreRistretto255ScalarMul(BigInteger x, byte[] y) Multiplies two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.Multiplies two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.Multiplies two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.cryptoCoreRistretto255ScalarNegate(byte[] scalar) Calculates the additive inverse of the given scalar value.voidcryptoCoreRistretto255ScalarNegate(byte[] result, byte[] scalar) Calculates the additive inverse of the given scalar value.cryptoCoreRistretto255ScalarNegate(String scalarEnc) Calculates the additive inverse of the given scalar value.Calculates the additive inverse of the given scalar value.Creates a random scalar value in[0, l[withLbeing the order of the Ristretto255 group.voidcryptoCoreRistretto255ScalarRandom(byte[] scalar) Creates a random scalar value in[0, l[withLbeing the order of the Ristretto255 group.cryptoCoreRistretto255ScalarReduce(byte[] scalar) Reduces a possibly larger scalar value to[0, L[withLbeing the order of the Ristretto255 group.voidcryptoCoreRistretto255ScalarReduce(byte[] result, byte[] scalar) Reduces a possibly larger scalar value to[0, l[withLbeing the order of the Ristretto255 group.cryptoCoreRistretto255ScalarReduce(String scalarEnc) Reduces a possibly larger scalar value to[0, l[withLbeing the order of the Ristretto255 group.Reduces a possibly larger scalar value to[0, l[withLbeing the order of the Ristretto255 group.cryptoCoreRistretto255ScalarSub(byte[] x, byte[] y) Subtracts two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.voidcryptoCoreRistretto255ScalarSub(byte[] result, byte[] x, byte[] y) Subtracts two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.cryptoCoreRistretto255ScalarSub(byte[] x, String y) Subtracts two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.cryptoCoreRistretto255ScalarSub(byte[] x, BigInteger y) Subtracts two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.cryptoCoreRistretto255ScalarSub(String x, byte[] y) Subtracts two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.Subtracts two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.Subtracts two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.cryptoCoreRistretto255ScalarSub(BigInteger x, byte[] y) Subtracts two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.Subtracts two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.Subtracts two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.booleancryptoCoreRistretto255Sub(byte[] result, byte[] p, byte[] q) Subtracts two given Ristretto255 pointspandqand puts the representation of the result intoresult.Subtracts two given Ristretto255 pointspandqand returns the result.booleancryptoGenericHash(byte[] out, int outLen, byte[] in, long inLen) Hash a byte array without a key.booleancryptoGenericHash(byte[] out, int outLen, byte[] in, long inLen, byte[] key, int keyLen) Hash a byte array.Hash a string without a key.cryptoGenericHash(String in, Key key) Hash a string with a key, so later on you can verify the hashed string with the key.booleancryptoGenericHashFinal(byte[] state, byte[] out, int outLen) Now that the hash has finalised, the hash can be put intoout.cryptoGenericHashFinal(byte[] state, int outLen) Finalise the hashing operation.booleancryptoGenericHashInit(byte[] state, byte[] key, int keyLength, int outLen) Hash multiple parts of a message.booleancryptoGenericHashInit(byte[] state, int outLen) Hash multiple parts of a message without a keybooleancryptoGenericHashInit(byte[] state, Key key, int outLen) Initialise a multi-part hashing operation.Generate a hashing key.voidcryptoGenericHashKeygen(byte[] k) Generate a key.cryptoGenericHashKeygen(int size) Generate a hashing key with a size.intbooleancryptoGenericHashUpdate(byte[] state, byte[] in, long inLen) Update a multi-part hashing with another part.booleancryptoGenericHashUpdate(byte[] state, String in) Hash a part of a multi-part hash.booleancryptoHashSha256(byte[] out, byte[] in, long inLen) cryptoHashSha256(String message) booleancryptoHashSha256Final(Hash.State256 state, byte[] out) booleanbooleancryptoHashSha256Update(Hash.State256 state, byte[] in, long inLen) booleancryptoHashSha256Update(Hash.State256 state, String messagePart) booleancryptoHashSha512(byte[] out, byte[] in, long inLen) cryptoHashSha512(String message) booleancryptoHashSha512Final(Hash.State512 state, byte[] out) booleanbooleancryptoHashSha512Update(Hash.State512 state, byte[] in, long inLen) booleancryptoHashSha512Update(Hash.State512 state, String messagePart) intcryptoKdfDeriveFromKey(byte[] subKey, int subKeyLen, long subKeyId, byte[] context, byte[] masterKey) Derive a subkey from a master key.cryptoKdfDeriveFromKey(int lengthOfSubKey, long subKeyId, String context, Key masterKey) Derive a subkey from a master key.Auto generates a master key and returns it in string format.voidcryptoKdfKeygen(byte[] masterKey) Creates a master key.booleancryptoKxClientSessionKeys(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.cryptoKxClientSessionKeys(KeyPair clientKeyPair, KeyPair serverKeyPair) Generate a client's session keys.cryptoKxClientSessionKeys(Key clientPk, Key clientSk, Key serverPk) Generate a client's session keys.Generate a public and secret key.cryptoKxKeypair(byte[] seed) Deterministically generate a public and secret key.booleancryptoKxKeypair(byte[] publicKey, byte[] secretKey) Generate a public and a secret key.booleancryptoKxSeedKeypair(byte[] publicKey, byte[] secretKey, byte[] seed) Deterministically generate a public and secret key.booleancryptoKxServerSessionKeys(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.cryptoKxServerSessionKeys(KeyPair serverKeyPair, KeyPair clientKeyPair) Generate a server's session keys.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.booleancryptoPwHash(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 intooutputHash.cryptoPwHash(String password, int lengthOfHash, byte[] salt, long opsLimit, com.sun.jna.NativeLong memLimit, PwHash.Alg alg) Hashes a given password.booleancryptoPwHashStr(byte[] outputStr, byte[] password, int passwordLen, long opsLimit, com.sun.jna.NativeLong memLimit) Hashes a password and stores it into an array.cryptoPwHashStr(String password, long opsLimit, com.sun.jna.NativeLong memLimit) The most minimal way of hashing a given password.booleancryptoPwHashStrNeedsRehash(byte[] hash, long opsLimit, com.sun.jna.NativeLong memLimit) Checks whether the hash needs a rehash.cryptoPwHashStrRemoveNulls(String password, long opsLimit, com.sun.jna.NativeLong memLimit) Hashes a string and removes all the null bytes.booleancryptoPwHashStrVerify(byte[] hash, byte[] password, int passwordLen) Verifies a hashed password.booleancryptoPwHashStrVerify(String hash, String password) Verifies a password.booleancryptoScalarMult(byte[] shared, byte[] secretKey, byte[] publicKey) cryptoScalarMult(Key secretKey, Key publicKey) Generate a shared key from another user's public key and a secret key.booleancryptoScalarMultBase(byte[] publicKey, byte[] secretKey) cryptoScalarMultBase(Key secretKey) Generate a public key from a private key.booleancryptoScalarmultRistretto255(byte[] result, byte[] n, byte[] point) Multiplies the given Ristretto255pointby the scalarnand puts the representation of the result intoresult.cryptoScalarmultRistretto255(byte[] n, Ristretto255.RistrettoPoint point) Multiplies the given Ristretto255pointby the scalarnand returns the resulting point.Multiplies the given Ristretto255pointby the scalarnand returns the resulting point.Multiplies the given Ristretto255pointby the scalarnand returns the resulting point.cryptoScalarmultRistretto255Base(byte[] n) Multiplies the Ristretto255 base point by the scalarnand returns the result.booleancryptoScalarmultRistretto255Base(byte[] result, byte[] n) Multiplies the Ristretto255 base point by the scalarnand puts the representation of the result intoresult.Multiplies the Ristretto255 base point by the scalarnand returns the result.Multiplies the Ristretto255 base point by the scalarnand returns the result.booleancryptoSecretBoxDetached(byte[] cipherText, byte[] mac, byte[] message, long messageLen, byte[] nonce, byte[] key) Encrypts a message.cryptoSecretBoxDetached(String message, byte[] nonce, Key key) Encrypts a message with the mac separatelybooleancryptoSecretBoxEasy(byte[] cipherText, byte[] message, long messageLen, byte[] nonce, byte[] key) Encrypts a message using a key generated bySecretBox.Native.cryptoSecretBoxKeygen(byte[]).cryptoSecretBoxEasy(String message, byte[] nonce, Key key) Encrypts a message.Generates a secret symmetric key.voidcryptoSecretBoxKeygen(byte[] key) Creates a random key.booleancryptoSecretBoxOpenDetached(byte[] message, byte[] cipherText, byte[] mac, long cipherTextLen, byte[] nonce, byte[] key) Decrypts a message with the mac and the cipher provided separately.cryptoSecretBoxOpenDetached(DetachedEncrypt cipherAndMac, byte[] nonce, Key key) Decrypts a message.booleancryptoSecretBoxOpenEasy(byte[] message, byte[] cipherText, long cipherTextLen, byte[] nonce, byte[] key) Decrypts and verifies a message using a key generated bySecretBox.Native.cryptoSecretBoxKeygen(byte[]).cryptoSecretBoxOpenEasy(String cipher, byte[] nonce, Key key) Decrypts a message.cryptoSecretStreamInitPull(byte[] header, Key key) Initialises decryption using a state and a key.booleancryptoSecretStreamInitPull(SecretStream.State state, byte[] header, byte[] key) Initialises decryption using a state and a key.cryptoSecretStreamInitPush(byte[] header, Key key) Initialise encryption.booleancryptoSecretStreamInitPush(SecretStream.State state, byte[] header, byte[] key) Initialises encryption with a state and a key.Generates a key.voidcryptoSecretStreamKeygen(byte[] key) Generate a secret stream key.booleancryptoSecretStreamPull(SecretStream.State state, byte[] message, byte[] tag, byte[] cipher, long cipherLen) Decrypt a message without additional data.booleancryptoSecretStreamPull(SecretStream.State state, byte[] message, long[] messageAddress, byte[] tag, byte[] cipher, long cipherLen, byte[] additionalData, long additionalDataLen) Decrypt a message.cryptoSecretStreamPull(SecretStream.State state, String cipher, byte[] tag) Decrypt a message without additional data.booleancryptoSecretStreamPush(SecretStream.State state, byte[] cipher, byte[] message, long messageLen, byte tag) Encrypt amessage.booleancryptoSecretStreamPush(SecretStream.State state, byte[] cipher, long[] cipherAddr, byte[] message, long messageLen, byte tag) Encrypt amessage.booleancryptoSecretStreamPush(SecretStream.State state, byte[] cipher, long[] cipherAddr, byte[] message, long messageLen, byte[] additionalData, long additionalDataLen, byte tag) Encrypt amessage.cryptoSecretStreamPush(SecretStream.State state, String message, byte tag) Encrypt amessage.voidExplicitly rekeys.booleancryptoShortHash(byte[] out, byte[] in, long inLen, byte[] key) Short-input hash some text.cryptoShortHash(String in, Key key) Hash a short message using a key.Generate a 64-bit key for short-input hashing.voidcryptoShortHashKeygen(byte[] k) Output a 64-bit key.booleancryptoSign(byte[] signedMessage, byte[] message, long messageLen, byte[] secretKey) Sign a message.cryptoSign(String message, Key secretKey) Sign a message.cryptoSign(String message, String secretKey) Sign a message.booleancryptoSignDetached(byte[] signature, byte[] message, long messageLen, byte[] secretKey) Returns a signature for a message.cryptoSignDetached(String message, Key secretKey) Returns a signature for a message.booleancryptoSignEd25519SkToPk(byte[] publicKey, byte[] ed) Extracts the ed25519 public key from a secret ed25519 key.booleancryptoSignEd25519SkToSeed(byte[] seed, byte[] ed) Extracts the seed value from a secret ed25519 key.booleancryptoSignFinalCreate(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.booleancryptoSignFinalVerify(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.booleanUseful for signing a multi-part message (Ed25519ph).Generate a signing keypair (ed25519).booleancryptoSignKeypair(byte[] publicKey, byte[] secretKey) Generate a signing keypair (ed25519).booleancryptoSignOpen(byte[] message, byte[] signedMessage, long signedMessageLen, byte[] publicKey) Verify a signed message.cryptoSignOpen(String signedMessage, Key publicKey) Checks that a message is validly signed by a public key.cryptoSignSecretKeyPair(Key secretKey) Generate a signing keypair (ed25519), given a secret ed25519 key.cryptoSignSeedKeypair(byte[] seed) Generate a signing keypair deterministically.booleancryptoSignSeedKeypair(byte[] publicKey, byte[] secretKey, byte[] seed) Deterministically generate a public and secret key.booleancryptoSignUpdate(Sign.StateCryptoSign state, byte[] chunk, long chunkLength) Add a new chunk of length chunkLen bytes to the message that will eventually be signed.booleancryptoSignVerifyDetached(byte[] signature, byte[] message, int messageLen, byte[] publicKey) Verifies thatsignatureis valid for themessage.booleancryptoSignVerifyDetached(String signature, String message, Key publicKey) Verifies thatsignatureis valid for themessage.byte[]cryptoStream(byte[] nonce, Key key, Stream.Method method) booleancryptoStreamChaCha20(byte[] c, long cLen, byte[] nonce, byte[] key) booleancryptoStreamChaCha20Ietf(byte[] c, long cLen, byte[] nonce, byte[] key) voidcryptoStreamChaCha20IetfKeygen(byte[] key) booleancryptoStreamChaCha20IetfXor(byte[] cipher, byte[] message, long messageLen, byte[] nonce, byte[] key) booleancryptoStreamChacha20IetfXorIc(byte[] cipher, byte[] message, long messageLen, byte[] nonce, long ic, byte[] key) voidcryptoStreamChaCha20Keygen(byte[] key) booleancryptoStreamChaCha20Xor(byte[] cipher, byte[] message, long messageLen, byte[] nonce, byte[] key) booleancryptoStreamChacha20XorIc(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) cryptoStreamKeygen(Stream.Method method) booleancryptoStreamSalsa20(byte[] c, long cLen, byte[] nonce, byte[] key) voidcryptoStreamSalsa20Keygen(byte[] key) booleancryptoStreamSalsa20Xor(byte[] cipher, byte[] message, long messageLen, byte[] nonce, byte[] key) booleancryptoStreamSalsa20XorIc(byte[] cipher, byte[] message, long messageLen, byte[] nonce, long ic, byte[] key) cryptoStreamXor(String message, byte[] nonce, Key key, Stream.Method method) cryptoStreamXorDecrypt(String cipher, byte[] nonce, Key key, Stream.Method method) cryptoStreamXorIc(String message, byte[] nonce, long ic, Key key, Stream.Method method) cryptoStreamXorIcDecrypt(String cipher, byte[] nonce, long ic, Key key, Stream.Method method) booleancryptoStreamXSalsa20(byte[] c, long cLen, byte[] nonce, byte[] key) voidcryptoStreamXSalsa20Keygen(byte[] key) booleancryptoStreamXSalsa20Xor(byte[] cipher, byte[] message, long messageLen, byte[] nonce, byte[] key) byte[]decodeFromString(String encoded) Decodes the given string to bytes, using thisLazySodium's associatedMessageEncoder.decrypt(String cipher, String additionalData, byte[] nSec, byte[] nPub, Key k, AEAD.Method method) decrypt(String cipher, String additionalData, byte[] nPub, Key k, AEAD.Method method) decryptDetached(DetachedEncrypt detachedEncrypt, String additionalData, byte[] nSec, byte[] nPub, Key k, AEAD.Method method) encodeToString(byte[] bytes) Encodes the given bytes, using thisLazySodium's associatedMessageEncoder.encrypt(String m, String additionalData, byte[] nSec, byte[] nPub, Key k, AEAD.Method method) encrypt(String m, String additionalData, byte[] nPub, Key k, AEAD.Method method) encryptDetached(String m, String additionalData, byte[] nSec, byte[] nPub, Key k, AEAD.Method method) abstract Sodiumkeygen(AEAD.Method method) static IntegerlongToInt(long lng) static voidbyte[]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.longReturn a unsigned int byte 0 and 0xffffffff included.longrandomBytesUniform(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> Tres(int res, T object) com.sun.jna.PointersodiumAllocArray(int count, int size) Returns a pointer from which count objects that are size bytes of memory each can be accessed.sodiumBin2Hex(byte[] bin) Binary to hexadecimal.voidsodiumFree(com.sun.jna.Pointer p) Unlocks and deallocates memory allocated usingSecureMemory.Native.sodiumMalloc(int)orSecureMemory.Native.sodiumAllocArray(int, int)}.byte[]sodiumHex2Bin(String hex) Hexadecimal to binary.intcom.sun.jna.PointersodiumMalloc(int size) Returns a pointer from which exactly size contiguous bytes of memory can be accessed.booleansodiumMemZero(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.booleansodiumMLock(byte[] array, int len) Locks at least len bytes of memory from the array.booleansodiumMProtectNoAccess(com.sun.jna.Pointer ptr) Makes a region allocated usingSecureMemory.Native.sodiumMalloc(int)orSecureMemory.Native.sodiumAllocArray(int, int)} inaccessible.booleansodiumMProtectReadOnly(com.sun.jna.Pointer ptr) Marks a region allocated usingSecureMemory.Native.sodiumMalloc(int)orSecureMemory.Native.sodiumAllocArray(int, int)} as read-only.booleansodiumMProtectReadWrite(com.sun.jna.Pointer ptr) Marks a region allocated usingSecureMemory.Native.sodiumMalloc(int)orSecureMemory.Native.sodiumAllocArray(int, int)} as readable and writable, after having been protected usingSecureMemory.Native.sodiumMProtectReadOnly(Pointer)orSecureMemory.Native.sodiumMProtectNoAccess(Pointer)}/booleansodiumMUnlock(byte[] array, int len) Unlocks at least len bytes of memory from the array.booleansodiumPad(com.sun.jna.ptr.IntByReference paddedBuffLen, com.sun.jna.Pointer buf, int unpaddedBufLen, int blockSize, int maxBufLen) Adds extra padding to a bufferbufwhose original size isunpaddedBufLenin order to extend its total length to a multiple ofblocksize.booleansodiumUnpad(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 usingPadding.Native.sodiumPad(IntByReference, Pointer, int, int, int).str(byte[] bs) Converts a byte array to a string using a charset.Convert a byte array to a string with a charset.booleansuccessful(int res) static byte[]Hexadecimal string to bytes.byte[]static StringtoHex(byte[] bin) Bytes to hexadecimal.toHexStr(byte[] bs) booleanwrongLen(byte[] bs, int shouldBe) booleanwrongLen(int byteLength, int shouldBe) booleanwrongLen(int byteLength, long shouldBe)
-
Field Details
-
charset
-
messageEncoder
-
base64Facade
-
-
Constructor Details
-
LazySodium
public LazySodium() -
LazySodium
-
LazySodium
-
LazySodium
-
-
Method Details
-
longToInt
-
sodiumInit
public int sodiumInit()- Specified by:
sodiumInitin interfaceHelpers.Native
-
sodiumBin2Hex
Description copied from interface:Helpers.LazyBinary to hexadecimal. This method does not null terminate strings.- Specified by:
sodiumBin2Hexin interfaceHelpers.Lazy- Parameters:
bin- The binary bytes you want to convert to a string.- Returns:
- A hexadecimal string solely made up of the characters 0123456789ABCDEF.
-
sodiumHex2Bin
Description copied from interface:Helpers.LazyHexadecimal to binary. Does not null terminate the binary array.- Specified by:
sodiumHex2Binin interfaceHelpers.Lazy- Parameters:
hex- Hexadecimal string (a string that's made up of the characters 0123456789ABCDEF) to convert to a binary array.- Returns:
- Binary byte array.
-
toHexStr
-
toBinary
-
toHex
Bytes to hexadecimal. Equivalent tosodiumBin2Hex(byte[])but static.- Parameters:
bin- Byte array.- Returns:
- Hexadecimal string.
-
toBin
Hexadecimal string to bytes. Equivalent tosodiumHex2Bin(String)} but static.- Parameters:
hex- Hexadecimal string to convert to bytes.- Returns:
- Byte array.
-
randomBytesRandom
public long randomBytesRandom()Description copied from interface:RandomReturn a unsigned int byte 0 and 0xffffffff included.- Specified by:
randomBytesRandomin interfaceRandom- Returns:
- A random byte.
-
randomBytesBuf
public byte[] randomBytesBuf(int size) Description copied from interface:RandomGet a random number of bytes.- Specified by:
randomBytesBufin interfaceRandom- Parameters:
size- The length of the byte array to return.- Returns:
- Random byte array.
-
nonce
public byte[] nonce(int size) Description copied from interface:RandomGet a random number of bytes to use in a nonce. -
randomBytesUniform
public long randomBytesUniform(int upperBound) Description copied from interface:RandomReturns an unpredictable value between 0 and upperBound (excluded). Unlike randombytes_random() % upper_bound, it guarantees a uniform distribution of the possible output values even when upper_bound is not a power of 2. Note that an upper_bound less than 2 leaves only a single element to be chosen, namely 0.- Specified by:
randomBytesUniformin interfaceRandom- Returns:
- A uniformly random unsigned int.
-
randomBytesDeterministic
public byte[] randomBytesDeterministic(int size, byte[] seed) Description copied from interface:RandomGet deterministically random bytes given a seed.- Specified by:
randomBytesDeterministicin interfaceRandom- Parameters:
size- Size of byte array to return.seed- Seed to provide.- Returns:
- Deterministically random byte array.
-
sodiumPad
public boolean sodiumPad(com.sun.jna.ptr.IntByReference paddedBuffLen, com.sun.jna.Pointer buf, int unpaddedBufLen, int blockSize, int maxBufLen) Description copied from interface:Padding.NativeAdds extra padding to a bufferbufwhose original size isunpaddedBufLenin order to extend its total length to a multiple ofblocksize.- Specified by:
sodiumPadin interfacePadding.Native- Parameters:
paddedBuffLen- New length of buffer.buf- The buffer byte array.unpaddedBufLen- The length ofbufwith no padding.blockSize- Block size.maxBufLen- The absolute maximum you want this buffer length to be.- Returns:
- False if the padded buffer length would exceed
maxBufLen.
-
sodiumUnpad
public boolean sodiumUnpad(com.sun.jna.ptr.IntByReference unPaddedBuffLen, com.sun.jna.Pointer buf, int paddedBufLen, int blockSize) Description copied from interface:Padding.NativeComputes the original, unpadded length of a message previously padded usingPadding.Native.sodiumPad(IntByReference, Pointer, int, int, int). The original length is put intounpaddedBufLen.- Specified by:
sodiumUnpadin interfacePadding.Native- Parameters:
unPaddedBuffLen- This will be populated with the unpadded buffer length.buf- The buffer.paddedBufLen- The padded buffer size.blockSize- The block size.- Returns:
- True if the buffer was unpadded.
-
sodiumMemZero
public boolean sodiumMemZero(byte[] pnt, int len) Description copied from interface:SecureMemory.NativeThe sodium_memzero() function tries to effectively zero len bytes starting at pnt, even if optimizations are being applied to the code.- Specified by:
sodiumMemZeroin interfaceSecureMemory.Native- Parameters:
pnt- The byte array to zero out.len- How many bytes to zero out.- Returns:
- True if zeroed
-
sodiumMLock
public boolean sodiumMLock(byte[] array, int len) Description copied from interface:SecureMemory.NativeLocks at least len bytes of memory from the array. This can help avoid swapping sensitive data to disk.- Specified by:
sodiumMLockin interfaceSecureMemory.Native- Parameters:
array- Array to lock.len- Number of bytes to lock.- Returns:
- True if locked, false otherwise.
-
sodiumMUnlock
public boolean sodiumMUnlock(byte[] array, int len) Description copied from interface:SecureMemory.NativeUnlocks at least len bytes of memory from the array.- Specified by:
sodiumMUnlockin interfaceSecureMemory.Native- Parameters:
array- Array to unlock.len- Number of bytes to unlock.- Returns:
- True if unlocked, false otherwise.
-
sodiumMalloc
public com.sun.jna.Pointer sodiumMalloc(int size) Description copied from interface:SecureMemory.NativeReturns a pointer from which exactly size contiguous bytes of memory can be accessed.- Specified by:
sodiumMallocin interfaceSecureMemory.Native- Parameters:
size- The size of the byte array to allocate.- Returns:
- A Pointer to the byte array.
-
sodiumAllocArray
public com.sun.jna.Pointer sodiumAllocArray(int count, int size) Description copied from interface:SecureMemory.NativeReturns a pointer from which count objects that are size bytes of memory each can be accessed. It provides the same guarantees asSecureMemory.Native.sodiumMalloc(int)but also protects against arithmetic overflows when count * size exceeds SIZE_MAX.- Specified by:
sodiumAllocArrayin interfaceSecureMemory.Native- Parameters:
count- Number of objectssize- Size of those objects- Returns:
- A Pointer to the resulting array.
-
sodiumFree
public void sodiumFree(com.sun.jna.Pointer p) Description copied from interface:SecureMemory.NativeUnlocks and deallocates memory allocated usingSecureMemory.Native.sodiumMalloc(int)orSecureMemory.Native.sodiumAllocArray(int, int)}.- Specified by:
sodiumFreein interfaceSecureMemory.Native- Parameters:
p- The pointer to which an array shall be freed.
-
sodiumMProtectNoAccess
public boolean sodiumMProtectNoAccess(com.sun.jna.Pointer ptr) Description copied from interface:SecureMemory.NativeMakes a region allocated usingSecureMemory.Native.sodiumMalloc(int)orSecureMemory.Native.sodiumAllocArray(int, int)} inaccessible. It cannot be read or written, but the data is preserved.- Specified by:
sodiumMProtectNoAccessin interfaceSecureMemory.Native- Parameters:
ptr- The pointer to a region to decline access to.- Returns:
- True if operation completed successfully.
-
sodiumMProtectReadOnly
public boolean sodiumMProtectReadOnly(com.sun.jna.Pointer ptr) Description copied from interface:SecureMemory.NativeMarks a region allocated usingSecureMemory.Native.sodiumMalloc(int)orSecureMemory.Native.sodiumAllocArray(int, int)} as read-only. Attempting to modify the data will cause the process to terminate.- Specified by:
sodiumMProtectReadOnlyin interfaceSecureMemory.Native- Parameters:
ptr- Pointer to the region.- Returns:
- True if operation completed successfully.
-
sodiumMProtectReadWrite
public boolean sodiumMProtectReadWrite(com.sun.jna.Pointer ptr) Description copied from interface:SecureMemory.NativeMarks a region allocated usingSecureMemory.Native.sodiumMalloc(int)orSecureMemory.Native.sodiumAllocArray(int, int)} as readable and writable, after having been protected usingSecureMemory.Native.sodiumMProtectReadOnly(Pointer)orSecureMemory.Native.sodiumMProtectNoAccess(Pointer)}/- Specified by:
sodiumMProtectReadWritein interfaceSecureMemory.Native- Parameters:
ptr- Pointer to the region.- Returns:
- True if operation completed successfully.
-
cryptoKdfKeygen
public void cryptoKdfKeygen(byte[] masterKey) Description copied from interface:KeyDerivation.NativeCreates a master key.- Specified by:
cryptoKdfKeygenin interfaceKeyDerivation.Native- Parameters:
masterKey- The byte array to populate. Should beKeyDerivation.MASTER_KEY_BYTES.
-
cryptoKdfDeriveFromKey
public int cryptoKdfDeriveFromKey(byte[] subKey, int subKeyLen, long subKeyId, byte[] context, byte[] masterKey) Description copied from interface:KeyDerivation.NativeDerive a subkey from a master key.- Specified by:
cryptoKdfDeriveFromKeyin interfaceKeyDerivation.Native- Parameters:
subKey- The subkey.subKeyLen- The length of the subkey. Should be fromKeyDerivation.BYTES_MINtoKeyDerivation.BYTES_MAX.subKeyId- ID of subkey.context- The context of the subkey. Must beKeyDerivation.CONTEXT_BYTES.masterKey- The generated master key fromKeyDerivation.Native.cryptoKdfKeygen(byte[]). Must beKeyDerivation.MASTER_KEY_BYTES.- Returns:
- 0 on success, -1 otherwise.
-
cryptoKdfKeygen
Description copied from interface:KeyDerivation.LazyAuto generates a master key and returns it in string format. The reason why this does not return a string via the normal 'masterKey.getBytes()' is because the resulting string is mangled.- Specified by:
cryptoKdfKeygenin interfaceKeyDerivation.Lazy- Returns:
- A master Key.
-
cryptoKdfDeriveFromKey
public Key cryptoKdfDeriveFromKey(int lengthOfSubKey, long subKeyId, String context, Key masterKey) throws SodiumException Description copied from interface:KeyDerivation.LazyDerive a subkey from a master key.- Specified by:
cryptoKdfDeriveFromKeyin interfaceKeyDerivation.Lazy- Parameters:
lengthOfSubKey- The length of the subkey. Should be fromKeyDerivation.BYTES_MINtoKeyDerivation.BYTES_MAX.subKeyId- The ID of the subkey.context- The context of the subkey. Must beKeyDerivation.CONTEXT_BYTES.masterKey- The generated master key fromKeyDerivation.Lazy.cryptoKdfKeygen().- Returns:
- A subkey that's gone through
Helpers.Lazy.sodiumBin2Hex(byte[]). - Throws:
SodiumException- If any of the lengths were not correct.
-
cryptoKxKeypair
public boolean cryptoKxKeypair(byte[] publicKey, byte[] secretKey) Description copied from interface:KeyExchange.NativeGenerate a public and a secret key.- Specified by:
cryptoKxKeypairin interfaceKeyExchange.Native- Parameters:
publicKey- Public key will be populated here of sizeKeyExchange.PUBLICKEYBYTES.secretKey- Secret key will be populated here of sizeKeyExchange.SECRETKEYBYTES.- Returns:
- True if generated successfully.
-
cryptoKxSeedKeypair
public boolean cryptoKxSeedKeypair(byte[] publicKey, byte[] secretKey, byte[] seed) Description copied from interface:KeyExchange.NativeDeterministically generate a public and secret key. Store the seed somewhere if you want to generate these keys again.- Specified by:
cryptoKxSeedKeypairin interfaceKeyExchange.Native- Parameters:
publicKey- Public key will be populated here of sizeKeyExchange.PUBLICKEYBYTES.secretKey- Secret key will be populated here of sizeKeyExchange.SECRETKEYBYTES.seed- A random seed of sizeKeyExchange.SEEDBYTES.- Returns:
- True if generated successfully.
-
cryptoKxClientSessionKeys
public boolean cryptoKxClientSessionKeys(byte[] rx, byte[] tx, byte[] clientPk, byte[] clientSk, byte[] serverPk) Description copied from interface:KeyExchange.NativeThis 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.- Specified by:
cryptoKxClientSessionKeysin interfaceKeyExchange.Native- Parameters:
rx- Shared key 1 of sizeKeyExchange.SESSIONKEYBYTES. This should be used as an encryption key to SEND data to the server.tx- Shared key 2 of sizeKeyExchange.SESSIONKEYBYTES. This should be used as an encryption key to SEND data to the client FROM the server.clientPk- Client public key of sizeKeyExchange.PUBLICKEYBYTES.clientSk- Client secret key of sizeKeyExchange.SECRETKEYBYTES.serverPk- Server public key of sizeKeyExchange.PUBLICKEYBYTES.- Returns:
- True if successful or false if the server public key is wrong.
-
cryptoKxServerSessionKeys
public boolean cryptoKxServerSessionKeys(byte[] rx, byte[] tx, byte[] serverPk, byte[] serverSk, byte[] clientPk) Description copied from interface:KeyExchange.NativeThis 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.- Specified by:
cryptoKxServerSessionKeysin interfaceKeyExchange.Native- Parameters:
rx- Shared key 1 of sizeKeyExchange.SESSIONKEYBYTES. This should be used as an encryption key to SEND data to the client.tx- Shared key 2 of sizeKeyExchange.SESSIONKEYBYTES. This should be used as an encryption key to SEND data to the client FROM the client.serverPk- Server public key of sizeKeyExchange.PUBLICKEYBYTES.serverSk- Server secret key of sizeKeyExchange.SECRETKEYBYTES.clientPk- Client public key of sizeKeyExchange.PUBLICKEYBYTES.- Returns:
- True if successful or false if the client public key is wrong.
-
cryptoKxKeypair
Description copied from interface:KeyExchange.LazyGenerate a public and secret key.- Specified by:
cryptoKxKeypairin interfaceKeyExchange.Lazy- Returns:
- A KeyPair containing a public and secret key.
-
cryptoKxKeypair
Description copied from interface:KeyExchange.LazyDeterministically generate a public and secret key. Store the seed somewhere if you want to generate these keys again.- Specified by:
cryptoKxKeypairin interfaceKeyExchange.Lazy- Parameters:
seed- A random seed of sizeKeyExchange.SEEDBYTES.- Returns:
- The generated key pair.
-
cryptoKxClientSessionKeys
public SessionPair cryptoKxClientSessionKeys(KeyPair clientKeyPair, KeyPair serverKeyPair) throws SodiumException Description copied from interface:KeyExchange.LazyGenerate a client's session keys. This should be performed on the client.- Specified by:
cryptoKxClientSessionKeysin interfaceKeyExchange.Lazy- Parameters:
clientKeyPair- Provide the client's public and private key.serverKeyPair- Provide the server's public key only.- Returns:
- Session keys.
- Throws:
SodiumException- Not provided the correct keys, or generation of session keys failed.
-
cryptoKxServerSessionKeys
public SessionPair cryptoKxServerSessionKeys(Key serverPk, Key serverSk, Key clientPk) throws SodiumException Description copied from interface:KeyExchange.LazyComputes 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.- Specified by:
cryptoKxServerSessionKeysin interfaceKeyExchange.Lazy- Parameters:
serverPk- Server public key of sizeKeyExchange.PUBLICKEYBYTES.serverSk- Server secret key of sizeKeyExchange.SECRETKEYBYTES.clientPk- Client public key of sizeKeyExchange.PUBLICKEYBYTES.- Returns:
- True if successful or false if the client public key is wrong.
- Throws:
SodiumException
-
cryptoKxClientSessionKeys
public SessionPair cryptoKxClientSessionKeys(Key clientPk, Key clientSk, Key serverPk) throws SodiumException Description copied from interface:KeyExchange.LazyGenerate a client's session keys. This should be performed on the client.- Specified by:
cryptoKxClientSessionKeysin interfaceKeyExchange.Lazy- Parameters:
clientPk- Client public key of sizeKeyExchange.PUBLICKEYBYTES.clientSk- Client secret key of sizeKeyExchange.SECRETKEYBYTES.serverPk- Server public key of sizeKeyExchange.PUBLICKEYBYTES.- Returns:
- A session pair of keys.
- Throws:
SodiumException- If the size of any of the keys are wrong.- See Also:
-
cryptoKxServerSessionKeys
public SessionPair cryptoKxServerSessionKeys(KeyPair serverKeyPair, KeyPair clientKeyPair) throws SodiumException Description copied from interface:KeyExchange.LazyGenerate a server's session keys. This should be performed on the server.- Specified by:
cryptoKxServerSessionKeysin interfaceKeyExchange.Lazy- Parameters:
serverKeyPair- Provide the server's public and private key.clientKeyPair- Provide the client's public key only.- Returns:
- Session keys.
- Throws:
SodiumException- Not provided the correct keys, or generation of session keys failed.
-
cryptoPwHash
public boolean cryptoPwHash(byte[] outputHash, int outputHashLen, byte[] password, int passwordLen, byte[] salt, long opsLimit, com.sun.jna.NativeLong memLimit, PwHash.Alg alg) Description copied from interface:PwHash.NativeBased on a password you provide, hash that password and put the output intooutputHash. 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 toPwHash.Native.cryptoPwHashStr(byte[], byte[], int, long, NativeLong)instead.- Specified by:
cryptoPwHashin interfacePwHash.Native- Parameters:
outputHash- Where to store the resulting password hash.outputHashLen- The password hash's length. Must be at leastPwHash.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. BetweenPwHash.OPSLIMIT_MINandPwHash.OPSLIMIT_MAX.memLimit- The amount of memory to use. BetweenPwHash.MEMLIMIT_MINandPwHash.MEMLIMIT_MAX.alg- The algorithm to use. Please usePwHash.Alg.PWHASH_ALG_ARGON2ID13for now.- Returns:
- True if the hash succeeded.
-
cryptoPwHashStr
public boolean cryptoPwHashStr(byte[] outputStr, byte[] password, int passwordLen, long opsLimit, com.sun.jna.NativeLong memLimit) Description copied from interface:PwHash.NativeHashes a password and stores it into an array. The output is an ASCII encoded string in a byte array.- Specified by:
cryptoPwHashStrin interfacePwHash.Native- Parameters:
outputStr- An array to hold the hash. Must be at leastPwHash.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. BetweenPwHash.OPSLIMIT_MINandPwHash.OPSLIMIT_MAX.memLimit- The amount of memory to use. BetweenPwHash.MEMLIMIT_MINandPwHash.MEMLIMIT_MAX.- Returns:
- True if the hash succeeded.
- See Also:
-
cryptoPwHashStrVerify
public boolean cryptoPwHashStrVerify(byte[] hash, byte[] password, int passwordLen) Description copied from interface:PwHash.NativeVerifies a hashed password. Remember: you must add a null byte to the end of the hash so that this works properly!- Specified by:
cryptoPwHashStrVerifyin interfacePwHash.Native- Parameters:
hash- The hash of the password.password- The password to check if it equals the hash's password.passwordLen- The checking password's length.- Returns:
- True if the password matches the unhashed hash.
-
cryptoPwHashStrNeedsRehash
public boolean cryptoPwHashStrNeedsRehash(byte[] hash, long opsLimit, com.sun.jna.NativeLong memLimit) Description copied from interface:PwHash.NativeChecks whether the hash needs a rehash.- Specified by:
cryptoPwHashStrNeedsRehashin interfacePwHash.Native- Parameters:
hash- The hash.opsLimit- The operations limit used.memLimit- The memory limit used.- Returns:
- True if the hash needs to be rehashed.
-
cryptoPwHash
public String cryptoPwHash(String password, int lengthOfHash, byte[] salt, long opsLimit, com.sun.jna.NativeLong memLimit, PwHash.Alg alg) throws SodiumException Description copied from interface:PwHash.LazyHashes a given password.- Specified by:
cryptoPwHashin interfacePwHash.Lazy- Parameters:
password- The password to hash.lengthOfHash- The hash size that you want. Anything betweenPwHash.BYTES_MINandPwHash.BYTES_MAXsalt- A salt to use with the hash, generated randomly.opsLimit- The number of cycles to perform whilst hashing. BetweenPwHash.OPSLIMIT_MINandPwHash.OPSLIMIT_MAX.memLimit- The amount of memory to use. BetweenPwHash.MEMLIMIT_MINandPwHash.MEMLIMIT_MAX.alg- The algorithm to use. Defaults toPwHash.Alg.PWHASH_ALG_ARGON2ID13.- Returns:
- A hash of the password in bytes.
- Throws:
SodiumException- If the password is too short or the opsLimit is not correct.
-
cryptoPwHashStr
public String cryptoPwHashStr(String password, long opsLimit, com.sun.jna.NativeLong memLimit) throws SodiumException Description copied from interface:PwHash.LazyThe most minimal way of hashing a given password. We auto-generate the salt and use the default hashing algorithmPwHash.Alg.- Specified by:
cryptoPwHashStrin interfacePwHash.Lazy- Parameters:
password- The password string to hash.opsLimit- The number of cycles to perform whilst hashing. BetweenPwHash.OPSLIMIT_MINandPwHash.OPSLIMIT_MAX.memLimit- The amount of memory to use. BetweenPwHash.MEMLIMIT_MINandPwHash.MEMLIMIT_MAX.- Returns:
- The hashed password
- Throws:
SodiumException- If the password could not be hashed.
-
cryptoPwHashStrRemoveNulls
public String cryptoPwHashStrRemoveNulls(String password, long opsLimit, com.sun.jna.NativeLong memLimit) throws SodiumException Description copied from interface:PwHash.LazyHashes a string and removes all the null bytes. Uses the hashing algorithmPwHash.Alg.- Specified by:
cryptoPwHashStrRemoveNullsin interfacePwHash.Lazy- Parameters:
password- The password string to hash.opsLimit- The number of cycles to perform whilst hashing. BetweenPwHash.OPSLIMIT_MINandPwHash.OPSLIMIT_MAX.memLimit- The amount of memory to use. BetweenPwHash.MEMLIMIT_MINandPwHash.MEMLIMIT_MAX.- Returns:
- The hash without null bytes at the end. WARNING: when verifying please remember to ADD a null byte to the end!
- Throws:
SodiumException- If the password could not be hashed.
-
cryptoPwHashStrVerify
Description copied from interface:PwHash.LazyVerifies a password. Good news: this function automatically adds a null byte to the end which is required for the native underlying function to work.- Specified by:
cryptoPwHashStrVerifyin interfacePwHash.Lazy- Parameters:
hash- The hash. Must be hexadecimalHelpers.Lazy.sodiumBin2Hex(byte[]).password- The password.- Returns:
- True if the password 'unlocks' the hash.
-
cryptoHashSha256
public boolean cryptoHashSha256(byte[] out, byte[] in, long inLen) - Specified by:
cryptoHashSha256in interfaceHash.Native
-
cryptoHashSha256Init
- Specified by:
cryptoHashSha256Initin interfaceHash.Lazy- Specified by:
cryptoHashSha256Initin interfaceHash.Native
-
cryptoHashSha256Update
- Specified by:
cryptoHashSha256Updatein interfaceHash.Native
-
cryptoHashSha256Final
- Specified by:
cryptoHashSha256Finalin interfaceHash.Native
-
cryptoHashSha512
public boolean cryptoHashSha512(byte[] out, byte[] in, long inLen) - Specified by:
cryptoHashSha512in interfaceHash.Native
-
cryptoHashSha512Init
- Specified by:
cryptoHashSha512Initin interfaceHash.Lazy- Specified by:
cryptoHashSha512Initin interfaceHash.Native
-
cryptoHashSha512Update
- Specified by:
cryptoHashSha512Updatein interfaceHash.Native
-
cryptoHashSha512Final
- Specified by:
cryptoHashSha512Finalin interfaceHash.Native
-
cryptoHashSha256
- Specified by:
cryptoHashSha256in interfaceHash.Lazy- Throws:
SodiumException
-
cryptoHashSha512
- Specified by:
cryptoHashSha512in interfaceHash.Lazy- Throws:
SodiumException
-
cryptoHashSha256Update
- Specified by:
cryptoHashSha256Updatein interfaceHash.Lazy
-
cryptoHashSha256Final
- Specified by:
cryptoHashSha256Finalin interfaceHash.Lazy- Throws:
SodiumException
-
cryptoHashSha512Update
- Specified by:
cryptoHashSha512Updatein interfaceHash.Lazy
-
cryptoHashSha512Final
- Specified by:
cryptoHashSha512Finalin interfaceHash.Lazy- Throws:
SodiumException
-
cryptoSecretBoxKeygen
public void cryptoSecretBoxKeygen(byte[] key) Description copied from interface:SecretBox.NativeCreates a random key. It is equivalent to callingRandom.randomBytesBuf(int)but improves code clarity and can prevent misuse by ensuring that the provided key length is always correct.- Specified by:
cryptoSecretBoxKeygenin interfaceSecretBox.Native- Parameters:
key- The key which is of sizeSecretBox.KEYBYTES.
-
cryptoSecretBoxEasy
public boolean cryptoSecretBoxEasy(byte[] cipherText, byte[] message, long messageLen, byte[] nonce, byte[] key) Description copied from interface:SecretBox.NativeEncrypts a message using a key generated bySecretBox.Native.cryptoSecretBoxKeygen(byte[]).- Specified by:
cryptoSecretBoxEasyin interfaceSecretBox.Native- Parameters:
cipherText- The cipher text. Should be at leastSecretBox.MACBYTES+messageLen.message- The message to encrypt.messageLen- The message byte array length.nonce- A nonce of sizeSecretBox.NONCEBYTESgenerated byRandom.randomBytesBuf(int).key- The symmetric key generated bySecretBox.Native.cryptoSecretBoxKeygen(byte[]).- Returns:
- True if successful.
-
cryptoSecretBoxOpenEasy
public boolean cryptoSecretBoxOpenEasy(byte[] message, byte[] cipherText, long cipherTextLen, byte[] nonce, byte[] key) Description copied from interface:SecretBox.NativeDecrypts and verifies a message using a key generated bySecretBox.Native.cryptoSecretBoxKeygen(byte[]).- Specified by:
cryptoSecretBoxOpenEasyin interfaceSecretBox.Native- Parameters:
message- The message will be put into here once decrypted.cipherText- The cipher produced bySecretBox.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 usingcryptoSecretBoxEasy.key- The key generated bySecretBox.Native.cryptoSecretBoxKeygen(byte[]).- Returns:
- True if successful.
-
cryptoSecretBoxDetached
public boolean cryptoSecretBoxDetached(byte[] cipherText, byte[] mac, byte[] message, long messageLen, byte[] nonce, byte[] key) Description copied from interface:SecretBox.NativeEncrypts a message. Alongside the cipher a mac is returned which can be stored in separate locations.- Specified by:
cryptoSecretBoxDetachedin interfaceSecretBox.Native- Parameters:
cipherText- The encrypted message of lengthmessageLen.mac- The mac.message- The message to encrypt.messageLen- The message's length.nonce- A randomly generated nonce of sizeSecretBox.NONCEBYTES. UseRandom.randomBytesBuf(int).key- The key generated bySecretBox.Native.cryptoSecretBoxKeygen(byte[]).- Returns:
- True if successful.
-
cryptoSecretBoxOpenDetached
public boolean cryptoSecretBoxOpenDetached(byte[] message, byte[] cipherText, byte[] mac, long cipherTextLen, byte[] nonce, byte[] key) Description copied from interface:SecretBox.NativeDecrypts a message with the mac and the cipher provided separately.- Specified by:
cryptoSecretBoxOpenDetachedin interfaceSecretBox.Native- Parameters:
message- The message length which is the same size ascipherTextLen.cipherText- The cipher.mac- The mac.cipherTextLen- The cipher text length.nonce- The nonce that was used inSecretBox.Native.cryptoSecretBoxDetached(byte[], byte[], byte[], long, byte[], byte[]).key- The key generated bySecretBox.Native.cryptoSecretBoxKeygen(byte[]).- Returns:
- True if successful.
-
cryptoSecretBoxKeygen
Description copied from interface:SecretBox.LazyGenerates a secret symmetric key.- Specified by:
cryptoSecretBoxKeygenin interfaceSecretBox.Lazy- Returns:
- A secret symmetric key which has been through
Helpers.Lazy.sodiumBin2Hex(byte[]).
-
cryptoSecretBoxEasy
Description copied from interface:SecretBox.LazyEncrypts a message.- Specified by:
cryptoSecretBoxEasyin interfaceSecretBox.Lazy- Parameters:
message- The message to encrypt.nonce- A randomly generated nonce of sizeSecretBox.NONCEBYTES. UseRandom.randomBytesBuf(int).key- The key. A hexadecimal string that's been throughHelpers.Lazy.sodiumBin2Hex(byte[]).- Returns:
- The cipher byte array that's been
Helpers.Lazy.sodiumBin2Hex(byte[])'ified. - Throws:
SodiumException
-
cryptoSecretBoxOpenEasy
Description copied from interface:SecretBox.LazyDecrypts a message.- Specified by:
cryptoSecretBoxOpenEasyin interfaceSecretBox.Lazy- Parameters:
cipher- The hexadecimal cipher text. SeeHelpers.Lazy.sodiumBin2Hex(byte[]).nonce- The nonce that was used when you encrypted withSecretBox.Lazy.cryptoSecretBoxEasy(String, byte[], Key).key- The key. A hexadecimal string that's been throughHelpers.Lazy.sodiumBin2Hex(byte[]).- Returns:
- The decrypted message.
- Throws:
SodiumException
-
cryptoSecretBoxDetached
public DetachedEncrypt cryptoSecretBoxDetached(String message, byte[] nonce, Key key) throws SodiumException Description copied from interface:SecretBox.LazyEncrypts a message with the mac separately- Specified by:
cryptoSecretBoxDetachedin interfaceSecretBox.Lazy- Parameters:
message- The message to encrypt.nonce- A randomly generated nonce of sizeSecretBox.NONCEBYTES. UseRandom.randomBytesBuf(int).key- The key. A hexadecimal string that's been throughHelpers.Lazy.sodiumBin2Hex(byte[]).- Returns:
- The cipher byte array that's been
Helpers.Lazy.sodiumBin2Hex(byte[])'ified. - Throws:
SodiumException
-
cryptoSecretBoxOpenDetached
public String cryptoSecretBoxOpenDetached(DetachedEncrypt cipherAndMac, byte[] nonce, Key key) throws SodiumException Description copied from interface:SecretBox.LazyDecrypts a message.- Specified by:
cryptoSecretBoxOpenDetachedin interfaceSecretBox.Lazy- Parameters:
cipherAndMac- The hexadecimal cipher text. SeeHelpers.Lazy.sodiumBin2Hex(byte[]).nonce- The nonce that was used when you encrypted withSecretBox.Lazy.cryptoSecretBoxEasy(String, byte[], Key).key- The key. A hexadecimal string that's been throughHelpers.Lazy.sodiumBin2Hex(byte[]).- Returns:
- The decrypted message.
- Throws:
SodiumException
-
cryptoScalarMultBase
public boolean cryptoScalarMultBase(byte[] publicKey, byte[] secretKey) - Specified by:
cryptoScalarMultBasein interfaceDiffieHellman.Native
-
cryptoScalarMultBase
Description copied from interface:DiffieHellman.LazyGenerate a public key from a private key.- Specified by:
cryptoScalarMultBasein interfaceDiffieHellman.Lazy- Parameters:
secretKey- Provide the secret key.- Returns:
- The public key and the provided secret key.
-
cryptoScalarMult
public boolean cryptoScalarMult(byte[] shared, byte[] secretKey, byte[] publicKey) - Specified by:
cryptoScalarMultin interfaceDiffieHellman.Native
-
cryptoScalarMult
Description copied from interface:DiffieHellman.LazyGenerate a shared key from another user's public key and a secret key.- Specified by:
cryptoScalarMultin interfaceDiffieHellman.Lazy- Parameters:
secretKey- Another user's public key.publicKey- A secret key.- Returns:
- Shared secret key.
-
cryptoBoxKeypair
public boolean cryptoBoxKeypair(byte[] publicKey, byte[] secretKey) - Specified by:
cryptoBoxKeypairin interfaceBox.Native
-
cryptoBoxSeedKeypair
public boolean cryptoBoxSeedKeypair(byte[] publicKey, byte[] secretKey, byte[] seed) - Specified by:
cryptoBoxSeedKeypairin interfaceBox.Native
-
cryptoBoxEasy
public boolean cryptoBoxEasy(byte[] cipherText, byte[] message, long messageLen, byte[] nonce, byte[] publicKey, byte[] secretKey) - Specified by:
cryptoBoxEasyin interfaceBox.Native
-
cryptoBoxOpenEasy
public boolean cryptoBoxOpenEasy(byte[] message, byte[] cipherText, long cipherTextLen, byte[] nonce, byte[] publicKey, byte[] secretKey) - Specified by:
cryptoBoxOpenEasyin interfaceBox.Native
-
cryptoBoxDetached
public boolean cryptoBoxDetached(byte[] cipherText, byte[] mac, byte[] message, long messageLen, byte[] nonce, byte[] publicKey, byte[] secretKey) - Specified by:
cryptoBoxDetachedin interfaceBox.Native
-
cryptoBoxOpenDetached
public boolean cryptoBoxOpenDetached(byte[] message, byte[] cipherText, byte[] mac, long cipherTextLen, byte[] nonce, byte[] publicKey, byte[] secretKey) - Specified by:
cryptoBoxOpenDetachedin interfaceBox.Native
-
cryptoBoxBeforeNm
public boolean cryptoBoxBeforeNm(byte[] k, byte[] publicKey, byte[] secretKey) - Specified by:
cryptoBoxBeforeNmin interfaceBox.Native
-
cryptoBoxEasyAfterNm
public boolean cryptoBoxEasyAfterNm(byte[] cipherText, byte[] message, long messageLen, byte[] nonce, byte[] key) - Specified by:
cryptoBoxEasyAfterNmin interfaceBox.Native
-
cryptoBoxOpenEasyAfterNm
public boolean cryptoBoxOpenEasyAfterNm(byte[] message, byte[] cipher, long cLen, byte[] nonce, byte[] key) - Specified by:
cryptoBoxOpenEasyAfterNmin interfaceBox.Native
-
cryptoBoxDetachedAfterNm
public boolean cryptoBoxDetachedAfterNm(byte[] cipherText, byte[] mac, byte[] message, long messageLen, byte[] nonce, byte[] key) - Specified by:
cryptoBoxDetachedAfterNmin interfaceBox.Native
-
cryptoBoxOpenDetachedAfterNm
public boolean cryptoBoxOpenDetachedAfterNm(byte[] message, byte[] cipherText, byte[] mac, long cipherTextLen, byte[] nonce, byte[] key) - Specified by:
cryptoBoxOpenDetachedAfterNmin interfaceBox.Native
-
cryptoBoxSeal
public boolean cryptoBoxSeal(byte[] cipher, byte[] message, long messageLen, byte[] publicKey) - Specified by:
cryptoBoxSealin interfaceBox.Native
-
cryptoBoxSealOpen
public boolean cryptoBoxSealOpen(byte[] m, byte[] cipher, long cipherLen, byte[] publicKey, byte[] secretKey) - Specified by:
cryptoBoxSealOpenin interfaceBox.Native
-
cryptoBoxKeypair
Description copied from interface:Box.LazyGenerate a secret and public key.- Specified by:
cryptoBoxKeypairin interfaceBox.Lazy- Returns:
- Secret and public key.
- Throws:
SodiumException
-
cryptoBoxSeedKeypair
Description copied from interface:Box.LazyGenerate a public and secret key deterministically.- Specified by:
cryptoBoxSeedKeypairin interfaceBox.Lazy- Parameters:
seed- The seed to generate the key.- Returns:
- Public and secret key.
- Throws:
SodiumException
-
cryptoBoxEasy
Description copied from interface:Box.LazyEncrypts a message.- Specified by:
cryptoBoxEasyin interfaceBox.Lazy- Parameters:
message- The message.nonce- The nonce of sizeBox.NONCEBYTES.keyPair- A keypair.- Returns:
- The encrypted
Helpers.Lazy.sodiumBin2Hex(byte[])'ified cipher text. - Throws:
SodiumException
-
cryptoBoxOpenEasy
public String cryptoBoxOpenEasy(String cipherText, byte[] nonce, KeyPair keyPair) throws SodiumException Description copied from interface:Box.LazyDecrypts a previously encrypted message.- Specified by:
cryptoBoxOpenEasyin interfaceBox.Lazy- Parameters:
cipherText- Encrypted viaBox.Lazy.cryptoBoxEasy(String, byte[], KeyPair)and thenHelpers.Lazy.sodiumBin2Hex(byte[])'ified.nonce- The nonce of sizeBox.NONCEBYTES.keyPair- A keypair.- Returns:
- The message.
- Throws:
SodiumException
-
cryptoBoxBeforeNm
Description copied from interface:Box.LazyIf 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.- Specified by:
cryptoBoxBeforeNmin interfaceBox.Lazy- Parameters:
publicKey- A public key as generated byBox.Lazy.cryptoBoxKeypair().secretKey- A secret key as generated byBox.Lazy.cryptoBoxKeypair().- Returns:
- The shared secret key.
- Throws:
SodiumException- Incorrect key lengths.
-
cryptoBoxBeforeNm
Description copied from interface:Box.LazyIf 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.- Specified by:
cryptoBoxBeforeNmin interfaceBox.Lazy- Parameters:
keyPair- A public and secret key as generated byBox.Lazy.cryptoBoxKeypair().- Returns:
- The shared secret key.
- Throws:
SodiumException- Incorrect key lengths.
-
cryptoBoxEasyAfterNm
public String cryptoBoxEasyAfterNm(String message, byte[] nonce, String sharedSecretKey) throws SodiumException Description copied from interface:Box.LazyEncrypt a message.- Specified by:
cryptoBoxEasyAfterNmin interfaceBox.Lazy- Parameters:
message- The message for encryption.nonce- A randomly generated nonce viaRandom.nonce(int)}.sharedSecretKey- The shared secret key as generated viaBox.Lazy.cryptoBoxBeforeNm(KeyPair).- Returns:
- The encrypted message.
- Throws:
SodiumException- Incorrect key lengths or enc error.
-
cryptoBoxOpenEasyAfterNm
public String cryptoBoxOpenEasyAfterNm(String cipher, byte[] nonce, String sharedSecretKey) throws SodiumException Description copied from interface:Box.LazyDecrypt a message.- Specified by:
cryptoBoxOpenEasyAfterNmin interfaceBox.Lazy- Parameters:
cipher- The cipher text to be decrypted.nonce- The same nonce used to encrypt thecipher-Box.Lazy.cryptoBoxEasyAfterNm(String, byte[], String).sharedSecretKey- The shared secret key as generated viaBox.Lazy.cryptoBoxBeforeNm(KeyPair).- Returns:
- The decrypted message.
- Throws:
SodiumException- Incorrect key lengths or decryption error.
-
cryptoBoxDetachedAfterNm
public DetachedEncrypt cryptoBoxDetachedAfterNm(String message, byte[] nonce, String sharedSecretKey) throws SodiumException Description copied from interface:Box.LazyEncrypt a message but allow for storage of the mac separately.- Specified by:
cryptoBoxDetachedAfterNmin interfaceBox.Lazy- Parameters:
message- The message to encrypt.nonce- A randomly generated nonce viaRandom.nonce(int)}.sharedSecretKey- The shared secret key as generated viaBox.Lazy.cryptoBoxBeforeNm(KeyPair).- Returns:
- The encrypted message.
- Throws:
SodiumException- Incorrect key lengths or enc error.
-
cryptoBoxOpenDetachedAfterNm
public DetachedDecrypt cryptoBoxOpenDetachedAfterNm(DetachedEncrypt detachedEncrypt, byte[] nonce, String sharedSecretKey) throws SodiumException Description copied from interface:Box.LazyDecrypt a message.- Specified by:
cryptoBoxOpenDetachedAfterNmin interfaceBox.Lazy- Parameters:
detachedEncrypt- 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 viaBox.Lazy.cryptoBoxBeforeNm(KeyPair).- Returns:
- The decrypted message with the
mac. - Throws:
SodiumException- Incorrect key lengths or decryption error.
-
cryptoBoxSealEasy
Description copied from interface:Box.LazyEncrypts a message.- Specified by:
cryptoBoxSealEasyin interfaceBox.Lazy- Parameters:
message- The message.publicKey- A public key.- Returns:
- The encrypted
Helpers.Lazy.sodiumBin2Hex(byte[])'ified cipher text. - Throws:
SodiumException
-
cryptoBoxSealOpenEasy
Description copied from interface:Box.LazyDecrypts a previously encrypted message.- Specified by:
cryptoBoxSealOpenEasyin interfaceBox.Lazy- Parameters:
cipherText- Encrypted viaBox.Lazy.cryptoBoxSealEasy(String, Key)and thenHelpers.Lazy.sodiumBin2Hex(byte[])'ified.keyPair- A keypair.- Returns:
- The message.
- Throws:
SodiumException
-
cryptoSignInit
Description copied from interface:Sign.NativeUseful for signing a multi-part message (Ed25519ph). If the message can fit in memory and can be supplied as a single chunk, the single-part API should be preferred. This function must be called before the first crypto_sign_update() call.- Specified by:
cryptoSignInitin interfaceSign.Native- Parameters:
state- The state.- Returns:
- True if successful.
-
cryptoSignUpdate
Description copied from interface:Sign.NativeAdd a new chunk of length chunkLen bytes to the message that will eventually be signed.- Specified by:
cryptoSignUpdatein interfaceSign.Native- Parameters:
state- The state.chunk- A part of the long message.chunkLength- Message length.- Returns:
- True if this chunk was successfully signed.
-
cryptoSignFinalCreate
public boolean cryptoSignFinalCreate(Sign.StateCryptoSign state, byte[] sig, com.sun.jna.Pointer sigLen, byte[] sk) Description copied from interface:Sign.NativeThis function computes a signature for the previously supplied message, using the secret key sk and puts it into sig. If sigLen is not NULL, the length of the signature is stored at this address. However this is kind of redundant as you can just do sig.length.- Specified by:
cryptoSignFinalCreatein interfaceSign.Native- Parameters:
state- The state.sig- Resultant signature.sigLen- Signature length.sk- Secret key.- Returns:
- True if successfully signed completely.
-
cryptoSignFinalVerify
Description copied from interface:Sign.NativeVerifies that sig is a valid signature for the message whose content has been previously supplied using crypto_update(), using the public key pk.- Specified by:
cryptoSignFinalVerifyin interfaceSign.Native- Parameters:
state- The state.sig- Resultant signature.pk- Secret key.- Returns:
- True if successfully signed completely.
-
cryptoSignKeypair
public boolean cryptoSignKeypair(byte[] publicKey, byte[] secretKey) Description copied from interface:Sign.NativeGenerate a signing keypair (ed25519).- Specified by:
cryptoSignKeypairin interfaceSign.Native- Parameters:
publicKey- Public key.secretKey- Secret key.- Returns:
- True if successful.
-
cryptoSignSeedKeypair
public boolean cryptoSignSeedKeypair(byte[] publicKey, byte[] secretKey, byte[] seed) Description copied from interface:Sign.NativeDeterministically generate a public and secret key.- Specified by:
cryptoSignSeedKeypairin interfaceSign.Native- Parameters:
publicKey- Public key.secretKey- Secret key.seed- The seed used to generate the keys.- Returns:
- True if successfully generated keys.
-
cryptoSign
public boolean cryptoSign(byte[] signedMessage, byte[] message, long messageLen, byte[] secretKey) Description copied from interface:Sign.NativeSign a message.- Specified by:
cryptoSignin interfaceSign.Native- Parameters:
signedMessage- Signed message will be placed here. It isSign.BYTES+messageLenlong.message- The message.messageLen- The message length.secretKey- The secret key.- Returns:
- True if successfully signed.
-
cryptoSignOpen
public boolean cryptoSignOpen(byte[] message, byte[] signedMessage, long signedMessageLen, byte[] publicKey) Description copied from interface:Sign.NativeVerify a signed message.- Specified by:
cryptoSignOpenin interfaceSign.Native- Parameters:
message- The message will be placed in here.signedMessage- The signed message.signedMessageLen- The signed message length.publicKey- Public key.- Returns:
- True if the signature is from the public key.
-
cryptoSignDetached
public boolean cryptoSignDetached(byte[] signature, byte[] message, long messageLen, byte[] secretKey) Description copied from interface:Sign.NativeReturns a signature for a message. This does not prepend the signature to the message. SeeSign.Native.cryptoSign(byte[], byte[], long, byte[])for that.- Specified by:
cryptoSignDetachedin interfaceSign.Native- Parameters:
signature- The signature will be added to this byte array.message- The message to sign.messageLen- The message length.secretKey- The secret key.- Returns:
- True if the secret key could provide a signature.
-
cryptoSignVerifyDetached
public boolean cryptoSignVerifyDetached(byte[] signature, byte[] message, int messageLen, byte[] publicKey) Description copied from interface:Sign.NativeVerifies thatsignatureis valid for themessage.- Specified by:
cryptoSignVerifyDetachedin interfaceSign.Native- Parameters:
signature- The signature.message- The message.messageLen- The message length.publicKey- The public key that signed the message.- Returns:
- Returns true if the signature is valid for the message.
- See Also:
-
convertPublicKeyEd25519ToCurve25519
public boolean convertPublicKeyEd25519ToCurve25519(byte[] curve, byte[] ed) Description copied from interface:Sign.NativeConverts a public ed25519 key to a public curve25519 key.- Specified by:
convertPublicKeyEd25519ToCurve25519in interfaceSign.Native- Parameters:
curve- The array in which the generated key will be placed.ed- The public key in ed25519.- Returns:
- Return true if the conversion was successful.
-
convertSecretKeyEd25519ToCurve25519
public boolean convertSecretKeyEd25519ToCurve25519(byte[] curve, byte[] ed) Description copied from interface:Sign.NativeConverts a secret ed25519 key to a secret curve25519 key.- Specified by:
convertSecretKeyEd25519ToCurve25519in interfaceSign.Native- Parameters:
curve- The array in which the generated key will be placed.ed- The secret key in ed25519.- Returns:
- Return true if the conversion was successful.
-
cryptoSignEd25519SkToSeed
public boolean cryptoSignEd25519SkToSeed(byte[] seed, byte[] ed) Description copied from interface:Sign.NativeExtracts the seed value from a secret ed25519 key.- Specified by:
cryptoSignEd25519SkToSeedin interfaceSign.Native- Parameters:
seed- The array in which the seed value will be placed. Must be Sign.ED25519_SEEDBYTES bytes long.ed- The secret key in ed25519.- Returns:
- Return true if the seed is extracted.
-
cryptoSignEd25519SkToPk
public boolean cryptoSignEd25519SkToPk(byte[] publicKey, byte[] ed) Description copied from interface:Sign.NativeExtracts the ed25519 public key from a secret ed25519 key.- Specified by:
cryptoSignEd25519SkToPkin interfaceSign.Native- Parameters:
publicKey- The array in which the public key will be placed. Must be Sign.PUBLICKEYBYTES bytes long.ed- The secret key in ed25519.- Returns:
- Return true if the public key is extracted.
-
cryptoSignKeypair
Description copied from interface:Sign.LazyGenerate a signing keypair (ed25519).- Specified by:
cryptoSignKeypairin interfaceSign.Lazy- Returns:
- Public and private keypair.
- Throws:
SodiumException
-
cryptoSignSeedKeypair
Description copied from interface:Sign.LazyGenerate a signing keypair deterministically.- Specified by:
cryptoSignSeedKeypairin interfaceSign.Lazy- Parameters:
seed- The seed to generate keys.- Returns:
- Public and private keypair.
- Throws:
SodiumException
-
cryptoSignSecretKeyPair
Description copied from interface:Sign.LazyGenerate a signing keypair (ed25519), given a secret ed25519 key.- Specified by:
cryptoSignSecretKeyPairin interfaceSign.Lazy- Parameters:
secretKey- The ed25519 secret key.- Returns:
- The private and public ed25519 keys.
- Throws:
SodiumException
-
cryptoSign
Description copied from interface:Sign.LazySign a message.- Specified by:
cryptoSignin interfaceSign.Lazy- Parameters:
message- The message to sign.secretKey- The secret key.- Returns:
- A
Helpers.Lazy.sodiumBin2Hex(byte[])-ified signed message. - Throws:
SodiumException
-
cryptoSign
Description copied from interface:Sign.LazySign a message.- Specified by:
cryptoSignin interfaceSign.Lazy- Parameters:
message- The message to sign.secretKey- The secret key.- Returns:
- A
Helpers.Lazy.sodiumBin2Hex(byte[])-ified signed message. - Throws:
SodiumException
-
cryptoSignOpen
Description copied from interface:Sign.LazyChecks that a message is validly signed by a public key.- Specified by:
cryptoSignOpenin interfaceSign.Lazy- Parameters:
signedMessage- The signed message.publicKey- The public key that signed the message.- Returns:
- Returns the message without a signature. If null, then the message is not validly signed by the publicKey.
-
cryptoSignDetached
Description copied from interface:Sign.LazyReturns a signature for a message. This does not prepend the signature to the message. SeeSign.Lazy.cryptoSign(String, String)for that.- Specified by:
cryptoSignDetachedin interfaceSign.Lazy- Parameters:
message- The message to sign.secretKey- The secret key.- Returns:
- The signature for a message.
- Throws:
SodiumException- If could not sign.
-
cryptoSignVerifyDetached
Description copied from interface:Sign.LazyVerifies thatsignatureis valid for themessage.- Specified by:
cryptoSignVerifyDetachedin interfaceSign.Lazy- Parameters:
signature- The signature.message- The message.publicKey- The public key that signed the message.- Returns:
- Returns true if the signature is valid for the message.
- See Also:
-
convertKeyPairEd25519ToCurve25519
Description copied from interface:Sign.LazyConverts a ed25519 keypair to a curve25519 keypair.- Specified by:
convertKeyPairEd25519ToCurve25519in interfaceSign.Lazy- Parameters:
ed25519KeyPair- The key pair.- Returns:
- curve25519KeyPair
- Throws:
SodiumException- If conversion was unsuccessful.
-
cryptoSecretStreamKeygen
public void cryptoSecretStreamKeygen(byte[] key) Description copied from interface:SecretStream.NativeGenerate a secret stream key.- Specified by:
cryptoSecretStreamKeygenin interfaceSecretStream.Native- Parameters:
key- The key of sizeSecretStream.KEYBYTES.
-
cryptoSecretStreamInitPush
Description copied from interface:SecretStream.NativeInitialises encryption with a state and a key.- Specified by:
cryptoSecretStreamInitPushin interfaceSecretStream.Native- Parameters:
state- State to be used in othercryptoSecretStreamPush()functions.header- The header of sizeSecretStream.HEADERBYTES.key- The key as generated bySecretStream.Native.cryptoSecretStreamKeygen(byte[]).- Returns:
- True if successfully initialised state.
-
cryptoSecretStreamPush
public boolean cryptoSecretStreamPush(SecretStream.State state, byte[] cipher, long[] cipherAddr, byte[] message, long messageLen, byte tag) Description copied from interface:SecretStream.NativeEncrypt amessage. This is like cryptoSecretStreamPush but without additional data.- Specified by:
cryptoSecretStreamPushin interfaceSecretStream.Native- Parameters:
state- State.cipher- The resulting cipher of sizeSecretStream.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.- Returns:
- True if the message was encrypted.
-
cryptoSecretStreamPush
public boolean cryptoSecretStreamPush(SecretStream.State state, byte[] cipher, byte[] message, long messageLen, byte tag) Description copied from interface:SecretStream.NativeEncrypt amessage. This is like cryptoSecretStreamPush but without additional data or an address to store the cipher.- Specified by:
cryptoSecretStreamPushin interfaceSecretStream.Native- Parameters:
state- State as initialised in cryptoSecretStreamInitPush.cipher- The resulting cipher of sizeSecretStream.ABYTES+messageLen.message- The message to encrypt.messageLen- The message length.tag- The tag.- Returns:
- True if the message was encrypted.
-
cryptoSecretStreamPush
public boolean cryptoSecretStreamPush(SecretStream.State state, byte[] cipher, long[] cipherAddr, byte[] message, long messageLen, byte[] additionalData, long additionalDataLen, byte tag) Description copied from interface:SecretStream.NativeEncrypt amessage.- Specified by:
cryptoSecretStreamPushin interfaceSecretStream.Native- Parameters:
state- State as initialised in cryptoSecretStreamInitPush.cipher- The resulting cipher of sizeSecretStream.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.- Returns:
- True if the message was encrypted.
-
cryptoSecretStreamInitPull
Description copied from interface:SecretStream.NativeInitialises decryption using a state and a key.- Specified by:
cryptoSecretStreamInitPullin interfaceSecretStream.Native- Parameters:
state- State to be used in othercryptoSecretStreamPush()functions.header- The header of sizeSecretStream.HEADERBYTES.key- The key as generated bySecretStream.Native.cryptoSecretStreamKeygen(byte[]).- Returns:
- True if successfully initialised state.
-
cryptoSecretStreamPull
public boolean cryptoSecretStreamPull(SecretStream.State state, byte[] message, long[] messageAddress, byte[] tag, byte[] cipher, long cipherLen, byte[] additionalData, long additionalDataLen) Description copied from interface:SecretStream.NativeDecrypt a message.- Specified by:
cryptoSecretStreamPullin interfaceSecretStream.Native- Parameters:
state- The state as put into cryptoSecretStreamInitPull.message- The message of sizecipherLen-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.- Returns:
- True if successful decryption.
-
cryptoSecretStreamPull
public boolean cryptoSecretStreamPull(SecretStream.State state, byte[] message, byte[] tag, byte[] cipher, long cipherLen) Description copied from interface:SecretStream.NativeDecrypt a message without additional data.- Specified by:
cryptoSecretStreamPullin interfaceSecretStream.Native- Parameters:
state- The state as put into cryptoSecretStreamInitPull.message- The message of sizecipherLen-SecretStream.ABYTES.tag- The tag.cipher- The resulting encrypted message.cipherLen- The cipher length.- Returns:
- True if successful decryption.
-
cryptoSecretStreamKeygen
Description copied from interface:SecretStream.LazyGenerates a key.- Specified by:
cryptoSecretStreamKeygenin interfaceSecretStream.Lazy- Returns:
- Returns a key that's been through
Helpers.Lazy.sodiumBin2Hex(byte[]).
-
cryptoSecretStreamInitPush
Description copied from interface:SecretStream.LazyInitialise encryption.- Specified by:
cryptoSecretStreamInitPushin interfaceSecretStream.Lazy- Parameters:
header- Header to supply.key- The key as generated bySecretStream.Lazy.cryptoSecretStreamKeygen().- Returns:
- A state which can be further processed by other functions in secret stream.
- Throws:
SodiumException
-
cryptoSecretStreamPush
public String cryptoSecretStreamPush(SecretStream.State state, String message, byte tag) throws SodiumException Description copied from interface:SecretStream.LazyEncrypt amessage.- Specified by:
cryptoSecretStreamPushin interfaceSecretStream.Lazy- Parameters:
state- State as initialised inSecretStream.Lazy.cryptoSecretStreamInitPush(byte[], Key).message- The message to encrypt.tag- The tag.- Returns:
- The cipher string.
- Throws:
SodiumException
-
cryptoSecretStreamInitPull
Description copied from interface:SecretStream.LazyInitialises decryption using a state and a key.- Specified by:
cryptoSecretStreamInitPullin interfaceSecretStream.Lazy- Parameters:
header- The header of sizeSecretStream.HEADERBYTES.key- The key as generated bySecretStream.Lazy.cryptoSecretStreamKeygen()}.- Returns:
- A state for further processing of decryption functions.
- Throws:
SodiumException
-
cryptoSecretStreamPull
public String cryptoSecretStreamPull(SecretStream.State state, String cipher, byte[] tag) throws SodiumException Description copied from interface:SecretStream.LazyDecrypt a message without additional data.- Specified by:
cryptoSecretStreamPullin interfaceSecretStream.Lazy- Parameters:
state- The state as generated bySecretStream.Lazy.cryptoSecretStreamInitPull(byte[], Key).cipher- The resulting encrypted message.tag- The tag.- Returns:
- The decreypted cipher, i.e the message.
- Throws:
SodiumException
-
cryptoSecretStreamRekey
Description copied from interface:SecretStream.NativeExplicitly rekeys.- Specified by:
cryptoSecretStreamRekeyin interfaceSecretStream.Lazy- Specified by:
cryptoSecretStreamRekeyin interfaceSecretStream.Native- Parameters:
state- The state to update.
-
cryptoStreamChaCha20Keygen
public void cryptoStreamChaCha20Keygen(byte[] key) - Specified by:
cryptoStreamChaCha20Keygenin interfaceStream.Native
-
cryptoStreamChaCha20
public boolean cryptoStreamChaCha20(byte[] c, long cLen, byte[] nonce, byte[] key) - Specified by:
cryptoStreamChaCha20in interfaceStream.Native
-
cryptoStreamChaCha20Xor
public boolean cryptoStreamChaCha20Xor(byte[] cipher, byte[] message, long messageLen, byte[] nonce, byte[] key) - Specified by:
cryptoStreamChaCha20Xorin interfaceStream.Native
-
cryptoStreamChacha20XorIc
public boolean cryptoStreamChacha20XorIc(byte[] cipher, byte[] message, long messageLen, byte[] nonce, long ic, byte[] key) - Specified by:
cryptoStreamChacha20XorIcin interfaceStream.Native
-
cryptoStreamChaCha20IetfKeygen
public void cryptoStreamChaCha20IetfKeygen(byte[] key) - Specified by:
cryptoStreamChaCha20IetfKeygenin interfaceStream.Native
-
cryptoStreamChaCha20Ietf
public boolean cryptoStreamChaCha20Ietf(byte[] c, long cLen, byte[] nonce, byte[] key) - Specified by:
cryptoStreamChaCha20Ietfin interfaceStream.Native
-
cryptoStreamChaCha20IetfXor
public boolean cryptoStreamChaCha20IetfXor(byte[] cipher, byte[] message, long messageLen, byte[] nonce, byte[] key) - Specified by:
cryptoStreamChaCha20IetfXorin interfaceStream.Native
-
cryptoStreamChacha20IetfXorIc
public boolean cryptoStreamChacha20IetfXorIc(byte[] cipher, byte[] message, long messageLen, byte[] nonce, long ic, byte[] key) - Specified by:
cryptoStreamChacha20IetfXorIcin interfaceStream.Native
-
cryptoStreamSalsa20Keygen
public void cryptoStreamSalsa20Keygen(byte[] key) - Specified by:
cryptoStreamSalsa20Keygenin interfaceStream.Native
-
cryptoStreamSalsa20
public boolean cryptoStreamSalsa20(byte[] c, long cLen, byte[] nonce, byte[] key) - Specified by:
cryptoStreamSalsa20in interfaceStream.Native
-
cryptoStreamSalsa20Xor
public boolean cryptoStreamSalsa20Xor(byte[] cipher, byte[] message, long messageLen, byte[] nonce, byte[] key) - Specified by:
cryptoStreamSalsa20Xorin interfaceStream.Native
-
cryptoStreamSalsa20XorIc
public boolean cryptoStreamSalsa20XorIc(byte[] cipher, byte[] message, long messageLen, byte[] nonce, long ic, byte[] key) - Specified by:
cryptoStreamSalsa20XorIcin interfaceStream.Native
-
cryptoStreamXSalsa20Keygen
public void cryptoStreamXSalsa20Keygen(byte[] key) - Specified by:
cryptoStreamXSalsa20Keygenin interfaceStream.Native
-
cryptoStreamXSalsa20
public boolean cryptoStreamXSalsa20(byte[] c, long cLen, byte[] nonce, byte[] key) - Specified by:
cryptoStreamXSalsa20in interfaceStream.Native
-
cryptoStreamXSalsa20Xor
public boolean cryptoStreamXSalsa20Xor(byte[] cipher, byte[] message, long messageLen, byte[] nonce, byte[] key) - Specified by:
cryptoStreamXSalsa20Xorin interfaceStream.Native
-
cryptoStreamKeygen
- Specified by:
cryptoStreamKeygenin interfaceStream.Lazy
-
cryptoStream
- Specified by:
cryptoStreamin interfaceStream.Lazy
-
cryptoStreamXor
- Specified by:
cryptoStreamXorin interfaceStream.Lazy
-
cryptoStreamXorDecrypt
- Specified by:
cryptoStreamXorDecryptin interfaceStream.Lazy
-
cryptoStreamXorIc
public String cryptoStreamXorIc(String message, byte[] nonce, long ic, Key key, Stream.Method method) - Specified by:
cryptoStreamXorIcin interfaceStream.Lazy
-
cryptoStreamXorIcDecrypt
public String cryptoStreamXorIcDecrypt(String cipher, byte[] nonce, long ic, Key key, Stream.Method method) - Specified by:
cryptoStreamXorIcDecryptin interfaceStream.Lazy
-
cryptoStreamDefaultXorIc
protected byte[] cryptoStreamDefaultXorIc(byte[] messageBytes, byte[] nonce, long ic, Key key, Stream.Method method) -
cryptoAuth
public boolean cryptoAuth(byte[] tag, byte[] in, long inLen, byte[] key) Description copied from interface:Auth.NativeComputes a tag for the message in, whose length is inLen bytes, and the key k.- Specified by:
cryptoAuthin interfaceAuth.Native- Parameters:
tag- Tag of sizeAuth.BYTES.in- A message.inLen- Message size.key- The key as generated byAuth.Native.cryptoAuthKeygen(byte[]).- Returns:
- True if successful.
-
cryptoAuthVerify
public boolean cryptoAuthVerify(byte[] tag, byte[] in, long inLen, byte[] key) Description copied from interface:Auth.NativeVerifies that the tag stored at h is a valid tag for the message in whose length is inLen bytes, and the key k.- Specified by:
cryptoAuthVerifyin interfaceAuth.Native- Parameters:
tag- The tag.in- The message.inLen- Message bytes.key- The key as generated byAuth.Native.cryptoAuthKeygen(byte[]).- Returns:
- True if successful verification.
-
cryptoAuthKeygen
public void cryptoAuthKeygen(byte[] k) Description copied from interface:Auth.NativeGenerate an authentication key.- Specified by:
cryptoAuthKeygenin interfaceAuth.Native- Parameters:
k- Auth key of sizeAuth.KEYBYTES.
-
cryptoAuthKeygen
Description copied from interface:Auth.LazyGenerate an authentication key.- Specified by:
cryptoAuthKeygenin interfaceAuth.Lazy- Returns:
- An authentication key.
-
cryptoAuth
Description copied from interface:Auth.LazyComputes a tag for the message in.- Specified by:
cryptoAuthin interfaceAuth.Lazy- Parameters:
message- A message.key- The key as generated byAuth.Lazy.cryptoAuthKeygen().- Returns:
- True if successful.
- Throws:
SodiumException
-
cryptoAuthVerify
Description copied from interface:Auth.LazyVerifies that the tag valid tag for the message.- Specified by:
cryptoAuthVerifyin interfaceAuth.Lazy- Parameters:
tag- The tag.key- The key as generated byAuth.Lazy.cryptoAuthKeygen().- Returns:
- True if successful verification.
-
cryptoAuthHMACSha256Keygen
public void cryptoAuthHMACSha256Keygen(byte[] key) - Specified by:
cryptoAuthHMACSha256Keygenin interfaceAuth.Native
-
cryptoAuthHMACSha256
public boolean cryptoAuthHMACSha256(byte[] out, byte[] in, long inLen, byte[] k) - Specified by:
cryptoAuthHMACSha256in interfaceAuth.Native
-
cryptoAuthHMACSha256Verify
public boolean cryptoAuthHMACSha256Verify(byte[] h, byte[] in, long inLen, byte[] k) - Specified by:
cryptoAuthHMACSha256Verifyin interfaceAuth.Native
-
cryptoAuthHMACSha256Init
- Specified by:
cryptoAuthHMACSha256Initin interfaceAuth.Native
-
cryptoAuthHMACSha256Update
- Specified by:
cryptoAuthHMACSha256Updatein interfaceAuth.Native
-
cryptoAuthHMACSha256Final
- Specified by:
cryptoAuthHMACSha256Finalin interfaceAuth.Native
-
cryptoAuthHMACSha512Keygen
public void cryptoAuthHMACSha512Keygen(byte[] key) - Specified by:
cryptoAuthHMACSha512Keygenin interfaceAuth.Native
-
cryptoAuthHMACSha512
public boolean cryptoAuthHMACSha512(byte[] out, byte[] in, long inLen, byte[] k) - Specified by:
cryptoAuthHMACSha512in interfaceAuth.Native
-
cryptoAuthHMACSha512Verify
public boolean cryptoAuthHMACSha512Verify(byte[] h, byte[] in, long inLen, byte[] k) - Specified by:
cryptoAuthHMACSha512Verifyin interfaceAuth.Native
-
cryptoAuthHMACSha512Init
- Specified by:
cryptoAuthHMACSha512Initin interfaceAuth.Native
-
cryptoAuthHMACSha512Update
- Specified by:
cryptoAuthHMACSha512Updatein interfaceAuth.Native
-
cryptoAuthHMACSha512Final
- Specified by:
cryptoAuthHMACSha512Finalin interfaceAuth.Native
-
cryptoAuthHMACSha512256Keygen
public void cryptoAuthHMACSha512256Keygen(byte[] key) - Specified by:
cryptoAuthHMACSha512256Keygenin interfaceAuth.Native
-
cryptoAuthHMACSha512256
public boolean cryptoAuthHMACSha512256(byte[] out, byte[] in, long inLen, byte[] k) - Specified by:
cryptoAuthHMACSha512256in interfaceAuth.Native
-
cryptoAuthHMACSha512256Verify
public boolean cryptoAuthHMACSha512256Verify(byte[] h, byte[] in, long inLen, byte[] k) - Specified by:
cryptoAuthHMACSha512256Verifyin interfaceAuth.Native
-
cryptoAuthHMACSha512256Init
- Specified by:
cryptoAuthHMACSha512256Initin interfaceAuth.Native
-
cryptoAuthHMACSha512256Update
- Specified by:
cryptoAuthHMACSha512256Updatein interfaceAuth.Native
-
cryptoAuthHMACSha512256Final
- Specified by:
cryptoAuthHMACSha512256Finalin interfaceAuth.Native
-
cryptoAuthHMACShaKeygen
- Specified by:
cryptoAuthHMACShaKeygenin interfaceAuth.Lazy
-
cryptoAuthHMACSha
- Specified by:
cryptoAuthHMACShain interfaceAuth.Lazy
-
cryptoAuthHMACShaVerify
- Specified by:
cryptoAuthHMACShaVerifyin interfaceAuth.Lazy
-
cryptoAuthHMACShaInit
- Specified by:
cryptoAuthHMACShaInitin interfaceAuth.Lazy
-
cryptoAuthHMACShaUpdate
- Specified by:
cryptoAuthHMACShaUpdatein interfaceAuth.Lazy
-
cryptoAuthHMACShaFinal
- Specified by:
cryptoAuthHMACShaFinalin interfaceAuth.Lazy- Throws:
SodiumException
-
cryptoAuthHMACShaInit
- Specified by:
cryptoAuthHMACShaInitin interfaceAuth.Lazy
-
cryptoAuthHMACShaUpdate
- Specified by:
cryptoAuthHMACShaUpdatein interfaceAuth.Lazy
-
cryptoAuthHMACShaFinal
- Specified by:
cryptoAuthHMACShaFinalin interfaceAuth.Lazy- Throws:
SodiumException
-
cryptoAuthHMACShaInit
- Specified by:
cryptoAuthHMACShaInitin interfaceAuth.Lazy
-
cryptoAuthHMACShaUpdate
- Specified by:
cryptoAuthHMACShaUpdatein interfaceAuth.Lazy
-
cryptoAuthHMACShaFinal
- Specified by:
cryptoAuthHMACShaFinalin interfaceAuth.Lazy- Throws:
SodiumException
-
cryptoShortHash
public boolean cryptoShortHash(byte[] out, byte[] in, long inLen, byte[] key) Description copied from interface:ShortHash.NativeShort-input hash some text.- Specified by:
cryptoShortHashin interfaceShortHash.Native- Parameters:
out- The hashed text of sizeShortHash.SIPHASH24_BYTESorShortHash.SIPHASHX24_BYTESdepending oninsize.in- The short-input text to hash of sizeShortHash.BYTESor of sizeShortHash.SIPHASHX24_BYTES.inLen- The length of the short-input.key- The key generated viaShortHash.Native.cryptoShortHashKeygen(byte[]).- Returns:
- true if success, false if fail.
-
cryptoShortHashKeygen
public void cryptoShortHashKeygen(byte[] k) Description copied from interface:ShortHash.NativeOutput a 64-bit key.- Specified by:
cryptoShortHashKeygenin interfaceShortHash.Native- Parameters:
k- The key of sizeShortHash.SIPHASH24_KEYBYTES.
-
cryptoShortHash
Description copied from interface:ShortHash.LazyHash a short message using a key.- Specified by:
cryptoShortHashin interfaceShortHash.Lazy- Parameters:
in- The short message to hash.key- The key generated viaShortHash.Lazy.cryptoShortHashKeygen().- Returns:
- Your message hashed of size
ShortHash.BYTES. - Throws:
SodiumException
-
cryptoShortHashKeygen
Description copied from interface:ShortHash.LazyGenerate a 64-bit key for short-input hashing.- Specified by:
cryptoShortHashKeygenin interfaceShortHash.Lazy- Returns:
- Key in string format.
-
cryptoGenericHash
public boolean cryptoGenericHash(byte[] out, int outLen, byte[] in, long inLen, byte[] key, int keyLen) Description copied from interface:GenericHash.NativeHash a byte array.- Specified by:
cryptoGenericHashin interfaceGenericHash.Native- Parameters:
out- A place to store the resulting byte array. You may choose the output size, however the minimum recommended output size isGenericHash.BYTES. You may also specify a value betweenGenericHash.BYTES_MINandGenericHash.BYTES_MAX.outLen- Size of out.in- The text to hash.inLen- The size of in.key- The key generated byGenericHash.Native.cryptoGenericHashKeygen(byte[]).keyLen- The length of the key.- Returns:
- True if successfully hashed.
-
cryptoGenericHash
public boolean cryptoGenericHash(byte[] out, int outLen, byte[] in, long inLen) Description copied from interface:GenericHash.NativeHash a byte array without a key.- Specified by:
cryptoGenericHashin interfaceGenericHash.Native- Parameters:
out- A place to store the resulting byte array. You may choose the output size, however the minimum recommended output size isGenericHash.BYTES. You may also specify a value betweenGenericHash.BYTES_MINandGenericHash.BYTES_MAX.outLen- Size of out.in- The text to hash.inLen- The size of in.- Returns:
- True if successfully hashed.
- See Also:
-
cryptoGenericHashInit
public boolean cryptoGenericHashInit(byte[] state, byte[] key, int keyLength, int outLen) Description copied from interface:GenericHash.NativeHash multiple parts of a message.- Specified by:
cryptoGenericHashInitin interfaceGenericHash.Native- Parameters:
state- The state which holds the key in memory for further hashing.key- The key generated byGenericHash.Native.cryptoGenericHashKeygen(byte[]).keyLength- Length of the key.outLen- The size of the hash array. Please see the paramoutinGenericHash.Native.cryptoGenericHash(byte[], int, byte[], long, byte[], int)for more information.- Returns:
- True if initialised.
-
cryptoGenericHashInit
public boolean cryptoGenericHashInit(byte[] state, int outLen) Description copied from interface:GenericHash.NativeHash multiple parts of a message without a key- Specified by:
cryptoGenericHashInitin interfaceGenericHash.Native- Parameters:
state- The state which holds the current state in memory for further hashing.outLen- The size of the hash array. Please see the paramoutinGenericHash.Native.cryptoGenericHash(byte[], int, byte[], long, byte[], int)for more information.- Returns:
- True if initialised.
-
cryptoGenericHashUpdate
public boolean cryptoGenericHashUpdate(byte[] state, byte[] in, long inLen) Description copied from interface:GenericHash.NativeUpdate a multi-part hashing with another part.- Specified by:
cryptoGenericHashUpdatein interfaceGenericHash.Native- Parameters:
state- The state.in- Another hash part.inLen- The length if the hash part.- Returns:
- True if this part of the message was hashed.
-
cryptoGenericHashFinal
public boolean cryptoGenericHashFinal(byte[] state, byte[] out, int outLen) Description copied from interface:GenericHash.NativeNow that the hash has finalised, the hash can be put intoout.- Specified by:
cryptoGenericHashFinalin interfaceGenericHash.Native- Parameters:
state- The state.out- The final hash.outLen- The length of the hash.- Returns:
- True if hashed.
-
cryptoGenericHashStateBytes
public int cryptoGenericHashStateBytes()- Specified by:
cryptoGenericHashStateBytesin interfaceGenericHash.Native
-
cryptoGenericHashKeygen
public void cryptoGenericHashKeygen(byte[] k) Description copied from interface:GenericHash.NativeGenerate a key. Store the key ink.- Specified by:
cryptoGenericHashKeygenin interfaceGenericHash.Native- Parameters:
k- A place to store the generated key of sizeGenericHash.KEYBYTES. Though, it may be betweenGenericHash.KEYBYTESandGenericHash.KEYBYTES_MAX.
-
cryptoGenericHashKeygen
Description copied from interface:GenericHash.LazyGenerate a hashing key.- Specified by:
cryptoGenericHashKeygenin interfaceGenericHash.Lazy- Returns:
- A hashing key.
-
cryptoGenericHashKeygen
Description copied from interface:GenericHash.LazyGenerate a hashing key with a size.- Specified by:
cryptoGenericHashKeygenin interfaceGenericHash.Lazy- Parameters:
size- The size of the hashing key betweenGenericHash.KEYBYTESandGenericHash.KEYBYTES_MAX.- Returns:
- A hashing key.
- Throws:
SodiumException
-
cryptoGenericHash
Description copied from interface:GenericHash.LazyHash a string with a key, so later on you can verify the hashed string with the key. If you're hashing a password please seePwHash.Lazy.cryptoPwHashStr(String, long, NativeLong)} instead.- Specified by:
cryptoGenericHashin interfaceGenericHash.Lazy- Parameters:
in- The string to hash.key- Can be null.- Returns:
- A hashed string.
- Throws:
SodiumException
-
cryptoGenericHash
Description copied from interface:GenericHash.LazyHash a string without a key.- Specified by:
cryptoGenericHashin interfaceGenericHash.Lazy- Parameters:
in- The string to hash.- Returns:
- The hashed string.
- Throws:
SodiumException
-
cryptoGenericHashInit
Description copied from interface:GenericHash.LazyInitialise a multi-part hashing operation.- Specified by:
cryptoGenericHashInitin interfaceGenericHash.Lazy- Parameters:
state- The state which holds the key and operation.key- The key as generated byGenericHash.Lazy.cryptoGenericHashKeygen().outLen- The size of the final hash.- Returns:
- True if initialised.
-
cryptoGenericHashUpdate
Description copied from interface:GenericHash.LazyHash a part of a multi-part hash.- Specified by:
cryptoGenericHashUpdatein interfaceGenericHash.Lazy- Parameters:
state- State as put intoGenericHash.Lazy.cryptoGenericHashInit(byte[], Key, int).in- A part of a string to hash.- Returns:
- True if hashed successfully.
-
cryptoGenericHashFinal
Description copied from interface:GenericHash.LazyFinalise the hashing operation.- Specified by:
cryptoGenericHashFinalin interfaceGenericHash.Lazy- Parameters:
state- State as put intoGenericHash.Lazy.cryptoGenericHashInit(byte[], Key, int).outLen- The size of the final hash.- Returns:
- The final hash.
- Throws:
SodiumException
-
cryptoAeadChaCha20Poly1305Keygen
public void cryptoAeadChaCha20Poly1305Keygen(byte[] key) - Specified by:
cryptoAeadChaCha20Poly1305Keygenin interfaceAEAD.Native
-
cryptoAeadChaCha20Poly1305Encrypt
public boolean cryptoAeadChaCha20Poly1305Encrypt(byte[] c, long[] cLen, byte[] m, long mLen, byte[] ad, long adLen, byte[] nSec, byte[] nPub, byte[] k) - Specified by:
cryptoAeadChaCha20Poly1305Encryptin interfaceAEAD.Native
-
cryptoAeadChaCha20Poly1305Decrypt
public boolean cryptoAeadChaCha20Poly1305Decrypt(byte[] m, long[] mLen, byte[] nSec, byte[] c, long cLen, byte[] ad, long adLen, byte[] nPub, byte[] k) - Specified by:
cryptoAeadChaCha20Poly1305Decryptin interfaceAEAD.Native
-
cryptoAeadChaCha20Poly1305EncryptDetached
public boolean cryptoAeadChaCha20Poly1305EncryptDetached(byte[] c, byte[] mac, long[] macLenAddress, byte[] m, long mLen, byte[] ad, long adLen, byte[] nSec, byte[] nPub, byte[] k) - Specified by:
cryptoAeadChaCha20Poly1305EncryptDetachedin interfaceAEAD.Native
-
cryptoAeadChaCha20Poly1305DecryptDetached
public boolean cryptoAeadChaCha20Poly1305DecryptDetached(byte[] m, byte[] nSec, byte[] c, long cLen, byte[] mac, byte[] ad, long adLen, byte[] nPub, byte[] k) - Specified by:
cryptoAeadChaCha20Poly1305DecryptDetachedin interfaceAEAD.Native
-
cryptoAeadChaCha20Poly1305IetfKeygen
public void cryptoAeadChaCha20Poly1305IetfKeygen(byte[] key) - Specified by:
cryptoAeadChaCha20Poly1305IetfKeygenin interfaceAEAD.Native
-
cryptoAeadChaCha20Poly1305IetfEncrypt
public boolean cryptoAeadChaCha20Poly1305IetfEncrypt(byte[] c, long[] cLen, byte[] m, long mLen, byte[] ad, long adLen, byte[] nSec, byte[] nPub, byte[] k) - Specified by:
cryptoAeadChaCha20Poly1305IetfEncryptin interfaceAEAD.Native
-
cryptoAeadChaCha20Poly1305IetfDecrypt
public boolean cryptoAeadChaCha20Poly1305IetfDecrypt(byte[] m, long[] mLen, byte[] nSec, byte[] c, long cLen, byte[] ad, long adLen, byte[] nPub, byte[] k) - Specified by:
cryptoAeadChaCha20Poly1305IetfDecryptin interfaceAEAD.Native
-
cryptoAeadChaCha20Poly1305IetfEncryptDetached
public boolean cryptoAeadChaCha20Poly1305IetfEncryptDetached(byte[] c, byte[] mac, long[] macLenAddress, byte[] m, long mLen, byte[] ad, long adLen, byte[] nSec, byte[] nPub, byte[] k) - Specified by:
cryptoAeadChaCha20Poly1305IetfEncryptDetachedin interfaceAEAD.Native
-
cryptoAeadChaCha20Poly1305IetfDecryptDetached
public boolean cryptoAeadChaCha20Poly1305IetfDecryptDetached(byte[] m, byte[] nSec, byte[] c, long cLen, byte[] mac, byte[] ad, long adLen, byte[] nPub, byte[] k) - Specified by:
cryptoAeadChaCha20Poly1305IetfDecryptDetachedin interfaceAEAD.Native
-
cryptoAeadXChaCha20Poly1305IetfKeygen
public void cryptoAeadXChaCha20Poly1305IetfKeygen(byte[] k) - Specified by:
cryptoAeadXChaCha20Poly1305IetfKeygenin interfaceAEAD.Native
-
cryptoAeadXChaCha20Poly1305IetfEncrypt
public boolean cryptoAeadXChaCha20Poly1305IetfEncrypt(byte[] c, long[] cLen, byte[] m, long mLen, byte[] ad, long adLen, byte[] nSec, byte[] nPub, byte[] k) - Specified by:
cryptoAeadXChaCha20Poly1305IetfEncryptin interfaceAEAD.Native
-
cryptoAeadXChaCha20Poly1305IetfDecrypt
public boolean cryptoAeadXChaCha20Poly1305IetfDecrypt(byte[] m, long[] mLen, byte[] nSec, byte[] c, long cLen, byte[] ad, long adLen, byte[] nPub, byte[] k) - Specified by:
cryptoAeadXChaCha20Poly1305IetfDecryptin interfaceAEAD.Native
-
cryptoAeadXChaCha20Poly1305IetfEncryptDetached
public boolean cryptoAeadXChaCha20Poly1305IetfEncryptDetached(byte[] c, byte[] mac, long[] macLenAddress, byte[] m, long mLen, byte[] ad, long adLen, byte[] nSec, byte[] nPub, byte[] k) - Specified by:
cryptoAeadXChaCha20Poly1305IetfEncryptDetachedin interfaceAEAD.Native
-
cryptoAeadXChaCha20Poly1305IetfDecryptDetached
public boolean cryptoAeadXChaCha20Poly1305IetfDecryptDetached(byte[] m, byte[] nSec, byte[] c, long cLen, byte[] mac, byte[] ad, long adLen, byte[] nPub, byte[] k) - Specified by:
cryptoAeadXChaCha20Poly1305IetfDecryptDetachedin interfaceAEAD.Native
-
cryptoAeadAES256GCMKeygen
public void cryptoAeadAES256GCMKeygen(byte[] key) - Specified by:
cryptoAeadAES256GCMKeygenin interfaceAEAD.Native
-
cryptoAeadAES256GCMEncrypt
public boolean cryptoAeadAES256GCMEncrypt(byte[] cipher, long[] cipherLen, byte[] message, long messageLen, byte[] additionalData, long additionalDataLen, byte[] nSec, byte[] nPub, byte[] key) - Specified by:
cryptoAeadAES256GCMEncryptin interfaceAEAD.Native
-
cryptoAeadAES256GCMDecrypt
public boolean cryptoAeadAES256GCMDecrypt(byte[] message, long[] messageLen, byte[] nSec, byte[] cipher, long cipherLen, byte[] additionalData, long additionalDataLen, byte[] nPub, byte[] key) - Specified by:
cryptoAeadAES256GCMDecryptin interfaceAEAD.Native
-
cryptoAeadAES256GCMEncryptDetached
public boolean cryptoAeadAES256GCMEncryptDetached(byte[] cipher, byte[] mac, long[] macLenAddress, byte[] message, long messageLen, byte[] additionalData, long additionalDataLen, byte[] nSec, byte[] nPub, byte[] key) - Specified by:
cryptoAeadAES256GCMEncryptDetachedin interfaceAEAD.Native
-
cryptoAeadAES256GCMDecryptDetached
public boolean cryptoAeadAES256GCMDecryptDetached(byte[] message, byte[] nSec, byte[] cipher, long cipherLen, byte[] mac, byte[] additionalData, long additionalDataLen, byte[] nPub, byte[] key) - Specified by:
cryptoAeadAES256GCMDecryptDetachedin interfaceAEAD.Native
-
cryptoAeadAES256GCMIsAvailable
public boolean cryptoAeadAES256GCMIsAvailable()- Specified by:
cryptoAeadAES256GCMIsAvailablein interfaceAEAD.Native
-
keygen
-
encrypt
-
encrypt
public String encrypt(String m, String additionalData, byte[] nSec, byte[] nPub, Key k, AEAD.Method method) -
decrypt
public String decrypt(String cipher, String additionalData, byte[] nPub, Key k, AEAD.Method method) throws AEADBadTagException - Specified by:
decryptin interfaceAEAD.Lazy- Throws:
AEADBadTagException
-
decrypt
public String decrypt(String cipher, String additionalData, byte[] nSec, byte[] nPub, Key k, AEAD.Method method) throws AEADBadTagException - Specified by:
decryptin interfaceAEAD.Lazy- Throws:
AEADBadTagException
-
encryptDetached
public DetachedEncrypt encryptDetached(String m, String additionalData, byte[] nSec, byte[] nPub, Key k, AEAD.Method method) - Specified by:
encryptDetachedin interfaceAEAD.Lazy
-
decryptDetached
public DetachedDecrypt decryptDetached(DetachedEncrypt detachedEncrypt, String additionalData, byte[] nSec, byte[] nPub, Key k, AEAD.Method method) throws AEADBadTagException - Specified by:
decryptDetachedin interfaceAEAD.Lazy- Throws:
AEADBadTagException
-
cryptoCoreRistretto255IsValidPoint
public boolean cryptoCoreRistretto255IsValidPoint(byte[] point) Description copied from interface:Ristretto255.NativeReturns whether the passed bytes represent a valid Ristretto255 point.- Specified by:
cryptoCoreRistretto255IsValidPointin interfaceRistretto255.Native- Parameters:
point- the point to check, should beRistretto255.RISTRETTO255_BYTESbytes- Returns:
- true if valid
-
cryptoCoreRistretto255Random
public void cryptoCoreRistretto255Random(byte[] point) Description copied from interface:Ristretto255.NativeChooses a random Ristretto255 point and puts its representation topoint- Specified by:
cryptoCoreRistretto255Randomin interfaceRistretto255.Native- Parameters:
point- the target array, must beRistretto255.RISTRETTO255_BYTESbytes
-
cryptoCoreRistretto255FromHash
public boolean cryptoCoreRistretto255FromHash(byte[] point, byte[] hash) Description copied from interface:Ristretto255.NativeMaps aRistretto255.RISTRETTO255_HASH_BYTESbytes hash to a Ristretto255 point and puts its representation topoint.- Specified by:
cryptoCoreRistretto255FromHashin interfaceRistretto255.Native- Parameters:
point- the target array, must beRistretto255.RISTRETTO255_BYTESbyteshash- the hash, must beRistretto255.RISTRETTO255_HASH_BYTESbytes- Returns:
- true if successful
-
cryptoScalarmultRistretto255
public boolean cryptoScalarmultRistretto255(byte[] result, byte[] n, byte[] point) Description copied from interface:Ristretto255.NativeMultiplies the given Ristretto255pointby the scalarnand puts the representation of the result intoresult.- Specified by:
cryptoScalarmultRistretto255in interfaceRistretto255.Native- Parameters:
result- the target array, must beRistretto255.RISTRETTO255_BYTESbytesn- the scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytespoint- the Ristretto255 point, must beRistretto255.RISTRETTO255_BYTESbytes- Returns:
- true if successful
-
cryptoScalarmultRistretto255Base
public boolean cryptoScalarmultRistretto255Base(byte[] result, byte[] n) Description copied from interface:Ristretto255.NativeMultiplies the Ristretto255 base point by the scalarnand puts the representation of the result intoresult.- Specified by:
cryptoScalarmultRistretto255Basein interfaceRistretto255.Native- Parameters:
result- the target array, must beRistretto255.RISTRETTO255_BYTESbytesn- the scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytes- Returns:
- true if successful
-
cryptoCoreRistretto255Add
public boolean cryptoCoreRistretto255Add(byte[] result, byte[] p, byte[] q) Description copied from interface:Ristretto255.NativeAdds two given Ristretto255 pointspandqand puts the representation of the result intoresult.- Specified by:
cryptoCoreRistretto255Addin interfaceRistretto255.Native- Parameters:
result- the target array, must beRistretto255.RISTRETTO255_BYTESbytesp- the first Ristretto255 point, must beRistretto255.RISTRETTO255_BYTESbytesq- the second Ristretto255 point, must beRistretto255.RISTRETTO255_BYTESbytes- Returns:
- true if successful
-
cryptoCoreRistretto255Sub
public boolean cryptoCoreRistretto255Sub(byte[] result, byte[] p, byte[] q) Description copied from interface:Ristretto255.NativeSubtracts two given Ristretto255 pointspandqand puts the representation of the result intoresult.- Specified by:
cryptoCoreRistretto255Subin interfaceRistretto255.Native- Parameters:
result- the target array, must beRistretto255.RISTRETTO255_BYTESbytesp- the first Ristretto255 point, must beRistretto255.RISTRETTO255_BYTESbytesq- the second Ristretto255 point, must beRistretto255.RISTRETTO255_BYTESbytes- Returns:
- true if successful
-
cryptoCoreRistretto255ScalarRandom
public void cryptoCoreRistretto255ScalarRandom(byte[] scalar) Description copied from interface:Ristretto255.NativeCreates a random scalar value in[0, l[withLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarRandomin interfaceRistretto255.Native- Parameters:
scalar- the target array, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytes
-
cryptoCoreRistretto255ScalarReduce
public void cryptoCoreRistretto255ScalarReduce(byte[] result, byte[] scalar) Description copied from interface:Ristretto255.NativeReduces a possibly larger scalar value to[0, l[withLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarReducein interfaceRistretto255.Native- Parameters:
result- the target array, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytesscalar- the scalar to reduce, must beRistretto255.RISTRETTO255_NON_REDUCED_SCALAR_BYTESbytes
-
cryptoCoreRistretto255ScalarInvert
public boolean cryptoCoreRistretto255ScalarInvert(byte[] result, byte[] scalar) Description copied from interface:Ristretto255.NativeCalculates the multiplicative inverse of the given scalar value.- Specified by:
cryptoCoreRistretto255ScalarInvertin interfaceRistretto255.Native- Parameters:
result- the target array, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytesscalar- the scalar to invert, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytes- Returns:
- true if successful
-
cryptoCoreRistretto255ScalarNegate
public void cryptoCoreRistretto255ScalarNegate(byte[] result, byte[] scalar) Description copied from interface:Ristretto255.NativeCalculates the additive inverse of the given scalar value.- Specified by:
cryptoCoreRistretto255ScalarNegatein interfaceRistretto255.Native- Parameters:
result- the target array, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytesscalar- the scalar to negate, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytes
-
cryptoCoreRistretto255ScalarComplement
public void cryptoCoreRistretto255ScalarComplement(byte[] result, byte[] scalar) Description copied from interface:Ristretto255.NativeCalculates the result R for the given scalar value such thatR + scalar = 1 (mod L)withLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarComplementin interfaceRistretto255.Native- Parameters:
result- the target array, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytesscalar- the scalar to complement, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytes
-
cryptoCoreRistretto255ScalarAdd
public void cryptoCoreRistretto255ScalarAdd(byte[] result, byte[] x, byte[] y) Description copied from interface:Ristretto255.NativeAdds two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarAddin interfaceRistretto255.Native- Parameters:
result- the target array, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytesx- the first scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytesy- the second scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytes
-
cryptoCoreRistretto255ScalarSub
public void cryptoCoreRistretto255ScalarSub(byte[] result, byte[] x, byte[] y) Description copied from interface:Ristretto255.NativeSubtracts two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarSubin interfaceRistretto255.Native- Parameters:
result- the target array, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytesx- the first scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytesy- the second scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytes
-
cryptoCoreRistretto255ScalarMul
public void cryptoCoreRistretto255ScalarMul(byte[] result, byte[] x, byte[] y) Description copied from interface:Ristretto255.NativeMultiplies two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarMulin interfaceRistretto255.Native- Parameters:
result- the target array, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytesx- the first scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytesy- the second scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytes
-
cryptoCoreRistretto255IsValidPoint
Description copied from interface:Ristretto255.LazyReturns whether the passed encoded string represents a valid Ristretto255 point.- Specified by:
cryptoCoreRistretto255IsValidPointin interfaceRistretto255.Lazy- Parameters:
point- the point to check- Returns:
- true if valid
-
cryptoCoreRistretto255Random
Description copied from interface:Ristretto255.LazyChooses a random Ristretto255 point and returns it.- Specified by:
cryptoCoreRistretto255Randomin interfaceRistretto255.Lazy- Returns:
- a random Ristretto255 point
-
cryptoCoreRistretto255FromHash
public Ristretto255.RistrettoPoint cryptoCoreRistretto255FromHash(String hash) throws SodiumException Description copied from interface:Ristretto255.LazyMaps aRistretto255.RISTRETTO255_HASH_BYTESbytes hash to aRistretto255.RistrettoPoint.- Specified by:
cryptoCoreRistretto255FromHashin interfaceRistretto255.Lazy- Parameters:
hash- the encoded hash- Returns:
- the corresponding Ristretto255 point
- Throws:
SodiumException
-
cryptoCoreRistretto255FromHash
public Ristretto255.RistrettoPoint cryptoCoreRistretto255FromHash(byte[] hash) throws SodiumException Description copied from interface:Ristretto255.LazyMaps aRistretto255.RISTRETTO255_HASH_BYTESbytes hash to a Ristretto255 point.- Specified by:
cryptoCoreRistretto255FromHashin interfaceRistretto255.Lazy- Parameters:
hash- the hash, must beRistretto255.RISTRETTO255_HASH_BYTES- Returns:
- the corresponding Ristretto255 point
- Throws:
SodiumException
-
cryptoScalarmultRistretto255
public Ristretto255.RistrettoPoint cryptoScalarmultRistretto255(BigInteger n, Ristretto255.RistrettoPoint point) throws SodiumException Description copied from interface:Ristretto255.LazyMultiplies the given Ristretto255pointby the scalarnand returns the resulting point.- Specified by:
cryptoScalarmultRistretto255in interfaceRistretto255.Lazy- Parameters:
n- the scalarpoint- the Ristretto255 point- Returns:
- the result
- Throws:
SodiumException
-
cryptoScalarmultRistretto255
public Ristretto255.RistrettoPoint cryptoScalarmultRistretto255(String nEnc, Ristretto255.RistrettoPoint point) throws SodiumException Description copied from interface:Ristretto255.LazyMultiplies the given Ristretto255pointby the scalarnand returns the resulting point.- Specified by:
cryptoScalarmultRistretto255in interfaceRistretto255.Lazy- Parameters:
nEnc- the encoded scalar bytes, in little-endian byte orderpoint- the Ristretto255 point- Returns:
- the result
- Throws:
SodiumException
-
cryptoScalarmultRistretto255
public Ristretto255.RistrettoPoint cryptoScalarmultRistretto255(byte[] n, Ristretto255.RistrettoPoint point) throws SodiumException Description copied from interface:Ristretto255.LazyMultiplies the given Ristretto255pointby the scalarnand returns the resulting point.- Specified by:
cryptoScalarmultRistretto255in interfaceRistretto255.Lazy- Parameters:
n- the scalar, must beRistretto255.RISTRETTO255_BYTESbytes, in little-endian encodingpoint- the Ristretto255 point- Returns:
- the result
- Throws:
SodiumException
-
cryptoScalarmultRistretto255Base
public Ristretto255.RistrettoPoint cryptoScalarmultRistretto255Base(BigInteger n) throws SodiumException Description copied from interface:Ristretto255.LazyMultiplies the Ristretto255 base point by the scalarnand returns the result.- Specified by:
cryptoScalarmultRistretto255Basein interfaceRistretto255.Lazy- Parameters:
n- the scalar- Returns:
- the result
- Throws:
SodiumException
-
cryptoScalarmultRistretto255Base
public Ristretto255.RistrettoPoint cryptoScalarmultRistretto255Base(String nEnc) throws SodiumException Description copied from interface:Ristretto255.LazyMultiplies the Ristretto255 base point by the scalarnand returns the result.- Specified by:
cryptoScalarmultRistretto255Basein interfaceRistretto255.Lazy- Parameters:
nEnc- the encoded scalar, in little-endian byte order- Returns:
- the result
- Throws:
SodiumException
-
cryptoScalarmultRistretto255Base
public Ristretto255.RistrettoPoint cryptoScalarmultRistretto255Base(byte[] n) throws SodiumException Description copied from interface:Ristretto255.LazyMultiplies the Ristretto255 base point by the scalarnand returns the result.- Specified by:
cryptoScalarmultRistretto255Basein interfaceRistretto255.Lazy- Parameters:
n- the scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytes, in little-endian encoding- Returns:
- the result
- Throws:
SodiumException
-
cryptoCoreRistretto255Add
public Ristretto255.RistrettoPoint cryptoCoreRistretto255Add(Ristretto255.RistrettoPoint p, Ristretto255.RistrettoPoint q) throws SodiumException Description copied from interface:Ristretto255.LazyAdds two given Ristretto255 pointspandqand returns the result.- Specified by:
cryptoCoreRistretto255Addin interfaceRistretto255.Lazy- Parameters:
p- the first Ristretto255 pointq- the second Ristretto255 point- Returns:
- the sum
- Throws:
SodiumException
-
cryptoCoreRistretto255Sub
public Ristretto255.RistrettoPoint cryptoCoreRistretto255Sub(Ristretto255.RistrettoPoint p, Ristretto255.RistrettoPoint q) throws SodiumException Description copied from interface:Ristretto255.LazySubtracts two given Ristretto255 pointspandqand returns the result.- Specified by:
cryptoCoreRistretto255Subin interfaceRistretto255.Lazy- Parameters:
p- the first Ristretto255 pointq- the second Ristretto255 point- Returns:
- the difference
- Throws:
SodiumException
-
cryptoCoreRistretto255ScalarRandom
Description copied from interface:Ristretto255.LazyCreates a random scalar value in[0, l[withLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarRandomin interfaceRistretto255.Lazy- Returns:
- the random scalar value
-
cryptoCoreRistretto255ScalarReduce
Description copied from interface:Ristretto255.LazyReduces a possibly larger scalar value to[0, l[withLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarReducein interfaceRistretto255.Lazy- Parameters:
scalar- the scalar to reduce- Returns:
- the reduced scalar
-
cryptoCoreRistretto255ScalarReduce
Description copied from interface:Ristretto255.LazyReduces a possibly larger scalar value to[0, l[withLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarReducein interfaceRistretto255.Lazy- Parameters:
scalarEnc- the encoded scalar to reduce- Returns:
- the reduced scalar
-
cryptoCoreRistretto255ScalarReduce
Description copied from interface:Ristretto255.LazyReduces a possibly larger scalar value to[0, L[withLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarReducein interfaceRistretto255.Lazy- Parameters:
scalar- the scalar to reduce, must beRistretto255.RISTRETTO255_NON_REDUCED_SCALAR_BYTESbytes- Returns:
- the reduced scalar
-
cryptoCoreRistretto255ScalarInvert
Description copied from interface:Ristretto255.LazyCalculates the multiplicative inverse of the given scalar value.- Specified by:
cryptoCoreRistretto255ScalarInvertin interfaceRistretto255.Lazy- Parameters:
scalar- the scalar to invert- Returns:
- the multiplicative inverse
- Throws:
SodiumException
-
cryptoCoreRistretto255ScalarInvert
Description copied from interface:Ristretto255.LazyCalculates the multiplicative inverse of the given scalar value.- Specified by:
cryptoCoreRistretto255ScalarInvertin interfaceRistretto255.Lazy- Parameters:
scalarEnc- the encoded scalar to invert- Returns:
- the multiplicative inverse
- Throws:
SodiumException
-
cryptoCoreRistretto255ScalarInvert
Description copied from interface:Ristretto255.LazyCalculates the multiplicative inverse of the given scalar value.- Specified by:
cryptoCoreRistretto255ScalarInvertin interfaceRistretto255.Lazy- Parameters:
scalar- the scalar to invert, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytes- Returns:
- the multiplicative inverse
- Throws:
SodiumException
-
cryptoCoreRistretto255ScalarNegate
Description copied from interface:Ristretto255.LazyCalculates the additive inverse of the given scalar value.- Specified by:
cryptoCoreRistretto255ScalarNegatein interfaceRistretto255.Lazy- Parameters:
scalar- the scalar to negate- Returns:
- the additive inverse
-
cryptoCoreRistretto255ScalarNegate
Description copied from interface:Ristretto255.LazyCalculates the additive inverse of the given scalar value.- Specified by:
cryptoCoreRistretto255ScalarNegatein interfaceRistretto255.Lazy- Parameters:
scalarEnc- the encoded scalar to negate- Returns:
- the additive inverse
-
cryptoCoreRistretto255ScalarNegate
Description copied from interface:Ristretto255.LazyCalculates the additive inverse of the given scalar value.- Specified by:
cryptoCoreRistretto255ScalarNegatein interfaceRistretto255.Lazy- Parameters:
scalar- the scalar to negate, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytes- Returns:
- the additive inverse
-
cryptoCoreRistretto255ScalarComplement
Description copied from interface:Ristretto255.LazyCalculates the result R for the given scalar value such thatR + scalar = 1 (mod L)withLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarComplementin interfaceRistretto255.Lazy- Parameters:
scalar- the scalar to complement- Returns:
- the complement
-
cryptoCoreRistretto255ScalarComplement
Description copied from interface:Ristretto255.LazyCalculates the result R for the given scalar value such thatR + scalar = 1 (mod L)withLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarComplementin interfaceRistretto255.Lazy- Parameters:
scalarEnc- the encoded scalar to complement- Returns:
- the complement
-
cryptoCoreRistretto255ScalarComplement
Description copied from interface:Ristretto255.LazyCalculates the result R for the given scalar value such thatR + scalar = 1 (mod L)withLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarComplementin interfaceRistretto255.Lazy- Parameters:
scalar- the scalar to complement, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytes- Returns:
- the complement
-
cryptoCoreRistretto255ScalarAdd
Description copied from interface:Ristretto255.LazyAdds two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarAddin interfaceRistretto255.Lazy- Parameters:
x- the first scalary- the second scalar- Returns:
- the sum
-
cryptoCoreRistretto255ScalarAdd
Description copied from interface:Ristretto255.LazyAdds two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarAddin interfaceRistretto255.Lazy- Parameters:
x- the first scalary- the second scalar (encoded)- Returns:
- the sum
-
cryptoCoreRistretto255ScalarAdd
Description copied from interface:Ristretto255.LazyAdds two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarAddin interfaceRistretto255.Lazy- Parameters:
x- the first scalar (encoded)y- the second scalar- Returns:
- the sum
-
cryptoCoreRistretto255ScalarAdd
Description copied from interface:Ristretto255.LazyAdds two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarAddin interfaceRistretto255.Lazy- Parameters:
x- the first scalar (encoded)y- the second scalar (encoded)- Returns:
- the sum
-
cryptoCoreRistretto255ScalarAdd
Description copied from interface:Ristretto255.LazyAdds two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarAddin interfaceRistretto255.Lazy- Parameters:
x- the first scalar (encoded)y- the second scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytes- Returns:
- the sum
-
cryptoCoreRistretto255ScalarAdd
Description copied from interface:Ristretto255.LazyAdds two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarAddin interfaceRistretto255.Lazy- Parameters:
x- the first scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytesy- the second scalar (encoded)- Returns:
- the sum
-
cryptoCoreRistretto255ScalarAdd
Description copied from interface:Ristretto255.LazyAdds two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarAddin interfaceRistretto255.Lazy- Parameters:
x- the first scalary- the second scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytes- Returns:
- the sum
-
cryptoCoreRistretto255ScalarAdd
Description copied from interface:Ristretto255.LazyAdds two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarAddin interfaceRistretto255.Lazy- Parameters:
x- the first scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytesy- the second scalar- Returns:
- the sum
-
cryptoCoreRistretto255ScalarAdd
Description copied from interface:Ristretto255.LazyAdds two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarAddin interfaceRistretto255.Lazy- Parameters:
x- the first scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytesy- the second scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytes- Returns:
- the sum
-
cryptoCoreRistretto255ScalarSub
Description copied from interface:Ristretto255.LazySubtracts two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarSubin interfaceRistretto255.Lazy- Parameters:
x- the first scalary- the second scalar- Returns:
- the difference
-
cryptoCoreRistretto255ScalarSub
Description copied from interface:Ristretto255.LazySubtracts two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarSubin interfaceRistretto255.Lazy- Parameters:
x- the first scalary- the second scalar (encoded)- Returns:
- the difference
-
cryptoCoreRistretto255ScalarSub
Description copied from interface:Ristretto255.LazySubtracts two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarSubin interfaceRistretto255.Lazy- Parameters:
x- the first scalar (encoded)y- the second scalar- Returns:
- the difference
-
cryptoCoreRistretto255ScalarSub
Description copied from interface:Ristretto255.LazySubtracts two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarSubin interfaceRistretto255.Lazy- Parameters:
x- the first scalar (encoded)y- the second scalar (encoded)- Returns:
- the difference
-
cryptoCoreRistretto255ScalarSub
Description copied from interface:Ristretto255.LazySubtracts two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarSubin interfaceRistretto255.Lazy- Parameters:
x- the first scalar (encoded)y- the second scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytes- Returns:
- the difference
-
cryptoCoreRistretto255ScalarSub
Description copied from interface:Ristretto255.LazySubtracts two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarSubin interfaceRistretto255.Lazy- Parameters:
x- the first scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytesy- the second scalar (encoded)- Returns:
- the difference
-
cryptoCoreRistretto255ScalarSub
Description copied from interface:Ristretto255.LazySubtracts two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarSubin interfaceRistretto255.Lazy- Parameters:
x- the first scalary- the second scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytes- Returns:
- the difference
-
cryptoCoreRistretto255ScalarSub
Description copied from interface:Ristretto255.LazySubtracts two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarSubin interfaceRistretto255.Lazy- Parameters:
x- the first scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytesy- the second scalar- Returns:
- the difference
-
cryptoCoreRistretto255ScalarSub
Description copied from interface:Ristretto255.LazySubtracts two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarSubin interfaceRistretto255.Lazy- Parameters:
x- the first scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytesy- the second scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytes- Returns:
- the difference
-
cryptoCoreRistretto255ScalarMul
Description copied from interface:Ristretto255.LazyMultiplies two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarMulin interfaceRistretto255.Lazy- Parameters:
x- the first scalary- the second scalar- Returns:
- the product
-
cryptoCoreRistretto255ScalarMul
Description copied from interface:Ristretto255.LazyMultiplies two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarMulin interfaceRistretto255.Lazy- Parameters:
x- the first scalary- the second scalar (encoded)- Returns:
- the product
-
cryptoCoreRistretto255ScalarMul
Description copied from interface:Ristretto255.LazyMultiplies two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarMulin interfaceRistretto255.Lazy- Parameters:
x- the first scalar (encoded)y- the second scalar- Returns:
- the product
-
cryptoCoreRistretto255ScalarMul
Description copied from interface:Ristretto255.LazyMultiplies two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarMulin interfaceRistretto255.Lazy- Parameters:
x- the first scalar (encoded)y- the second scalar (encoded)- Returns:
- the product
-
cryptoCoreRistretto255ScalarMul
Description copied from interface:Ristretto255.LazyMultiplies two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarMulin interfaceRistretto255.Lazy- Parameters:
x- the first scalar (encoded)y- the second scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytes- Returns:
- the product
-
cryptoCoreRistretto255ScalarMul
Description copied from interface:Ristretto255.LazyMultiplies two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarMulin interfaceRistretto255.Lazy- Parameters:
x- the first scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytesy- the second scalar (encoded)- Returns:
- the product
-
cryptoCoreRistretto255ScalarMul
Description copied from interface:Ristretto255.LazyMultiplies two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarMulin interfaceRistretto255.Lazy- Parameters:
x- the first scalary- the second scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytes- Returns:
- the product
-
cryptoCoreRistretto255ScalarMul
Description copied from interface:Ristretto255.LazyMultiplies two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarMulin interfaceRistretto255.Lazy- Parameters:
x- the first scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytesy- the second scalar- Returns:
- the product
-
cryptoCoreRistretto255ScalarMul
Description copied from interface:Ristretto255.LazyMultiplies two scalarsxandymoduloLwithLbeing the order of the Ristretto255 group.- Specified by:
cryptoCoreRistretto255ScalarMulin interfaceRistretto255.Lazy- Parameters:
x- the first scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytesy- the second scalar, must beRistretto255.RISTRETTO255_SCALAR_BYTESbytes- Returns:
- the product
-
res
public <T> T res(int res, T object) -
successful
public boolean successful(int res) - Specified by:
successfulin interfaceBase
-
str
Description copied from interface:BaseConverts a byte array to a string using a charset. This may not be what you want to use if you're storing this string in a database for example. This function will produce null bytes and unexpected carriage returns. Please useHelpers.Lazy.sodiumBin2Hex(byte[])to convert your byte array to a hexadecimal string that ensures no nulls or carriage breaks. -
str
Description copied from interface:BaseConvert a byte array to a string with a charset. This may not be what you want to use if you're storing this string in a database for example. This function will produce null bytes and unexpected carriage returns. Please useHelpers.Lazy.sodiumBin2Hex(byte[])to convert your byte array to a hexadecimal string that ensures no nulls or carriage breaks. -
bytes
Description copied from interface:BaseConvert a string to directly bytes. -
encodeToString
Encodes the given bytes, using thisLazySodium's associatedMessageEncoder.- Parameters:
bytes- the bytes to encode- Returns:
- the encoded string
-
decodeFromString
Decodes the given string to bytes, using thisLazySodium's associatedMessageEncoder.- Parameters:
encoded- the encoded string- Returns:
- the decoded bytes
-
wrongLen
public boolean wrongLen(byte[] bs, int shouldBe) -
wrongLen
public boolean wrongLen(int byteLength, int shouldBe) -
wrongLen
public boolean wrongLen(int byteLength, long shouldBe) -
removeNulls
public byte[] removeNulls(byte[] bs) Description copied from interface:BaseRemove all the null bytes from the end of a byte array.- Specified by:
removeNullsin interfaceBase- Parameters:
bs- A byte array.- Returns:
- The byte array with no null bytes at the end.
-
getSodium
-
main
- Throws:
SodiumException
-