Interface KeyExchange.Native

All Known Implementing Classes:
LazySodium, LazySodiumJava
Enclosing interface:
KeyExchange

public static interface KeyExchange.Native
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    boolean
    cryptoKxKeypair(byte[] publicKey, byte[] secretKey)
    Generate a public and a secret key.
    boolean
    cryptoKxSeedKeypair(byte[] publicKey, byte[] secretKey, byte[] seed)
    Deterministically generate a public and secret key.
    boolean
    cryptoKxServerSessionKeys(byte[] rx, byte[] tx, byte[] serverPk, byte[] serverSk, byte[] clientPk)
    This function computes a pair of shared keys (rx and tx) using the client's public key clientPk, the server's secret key serverSk and the server's public key serverPk.
  • 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 size KeyExchange.PUBLICKEYBYTES.
      secretKey - Secret key will be populated here of size KeyExchange.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 size KeyExchange.PUBLICKEYBYTES.
      secretKey - Secret key will be populated here of size KeyExchange.SECRETKEYBYTES.
      seed - A random seed of size KeyExchange.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 size KeyExchange.SESSIONKEYBYTES. This should be used as an encryption key to SEND data to the server.
      tx - Shared key 2 of size KeyExchange.SESSIONKEYBYTES. This should be used as an encryption key to SEND data to the client FROM the server.
      clientPk - Client public key of size KeyExchange.PUBLICKEYBYTES.
      clientSk - Client secret key of size KeyExchange.SECRETKEYBYTES.
      serverPk - Server public key of size KeyExchange.PUBLICKEYBYTES.
      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 size KeyExchange.SESSIONKEYBYTES. This should be used as an encryption key to SEND data to the client.
      tx - Shared key 2 of size KeyExchange.SESSIONKEYBYTES. This should be used as an encryption key to SEND data to the client FROM the client.
      serverPk - Server public key of size KeyExchange.PUBLICKEYBYTES.
      serverSk - Server secret key of size KeyExchange.SECRETKEYBYTES.
      clientPk - Client public key of size KeyExchange.PUBLICKEYBYTES.
      Returns:
      True if successful or false if the client public key is wrong.