Interface KeyExchange.Native
- All Known Implementing Classes:
LazySodium,LazySodiumJava
- Enclosing interface:
- KeyExchange
public static interface KeyExchange.Native
-
Method Summary
Modifier and TypeMethodDescriptionbooleancryptoKxClientSessionKeys(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.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.
-
Method Details
-
cryptoKxKeypair
boolean cryptoKxKeypair(byte[] publicKey, byte[] secretKey) Generate a public and a secret key.- 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
boolean cryptoKxSeedKeypair(byte[] publicKey, byte[] secretKey, byte[] seed) Deterministically generate a public and secret key. Store the seed somewhere if you want to generate these keys again.- 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
boolean cryptoKxClientSessionKeys(byte[] rx, byte[] tx, byte[] clientPk, byte[] clientSk, byte[] serverPk) This function computes a pair of shared keys (rx and tx) using the client's public key clientPk, the client's secret key clientSk and the server's public key serverPk.- 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
boolean cryptoKxServerSessionKeys(byte[] rx, byte[] tx, byte[] serverPk, byte[] serverSk, byte[] clientPk) This function computes a pair of shared keys (rx and tx) using the client's public key clientPk, the server's secret key serverSk and the server's public key serverPk.- 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.
-