Interface SecretStream.Native

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

public static interface SecretStream.Native
  • Method Details

    • cryptoSecretStreamKeygen

      void cryptoSecretStreamKeygen(byte[] key)
      Generate a secret stream key.
      Parameters:
      key - The key of size SecretStream.KEYBYTES.
    • cryptoSecretStreamInitPush

      boolean cryptoSecretStreamInitPush(SecretStream.State state, byte[] header, byte[] key)
      Initialises encryption with a state and a key.
      Parameters:
      state - State to be used in other cryptoSecretStreamPush() functions.
      header - The header of size SecretStream.HEADERBYTES.
      key - The key as generated by cryptoSecretStreamKeygen(byte[]).
      Returns:
      True if successfully initialised state.
    • cryptoSecretStreamPush

      boolean cryptoSecretStreamPush(SecretStream.State state, byte[] cipher, long[] cipherAddr, byte[] message, long messageLen, byte[] additionalData, long additionalDataLen, byte tag)
      Encrypt a message.
      Parameters:
      state - State as initialised in cryptoSecretStreamInitPush.
      cipher - The resulting cipher of size SecretStream.ABYTES + messageLen.
      cipherAddr - The cipher address will be stored here if not null.
      message - The message to encrypt.
      messageLen - The message length.
      additionalData - Additional data.
      additionalDataLen - Additional data length.
      tag - The tag.
      Returns:
      True if the message was encrypted.
    • cryptoSecretStreamPush

      boolean cryptoSecretStreamPush(SecretStream.State state, byte[] cipher, long[] cipherAddr, byte[] message, long messageLen, byte tag)
      Encrypt a message. This is like cryptoSecretStreamPush but without additional data.
      Parameters:
      state - State.
      cipher - The resulting cipher of size SecretStream.ABYTES + messageLen.
      cipherAddr - The cipher address will be stored here if not null.
      message - The message to encrypt.
      messageLen - The message length.
      tag - The tag.
      Returns:
      True if the message was encrypted.
    • cryptoSecretStreamPush

      boolean cryptoSecretStreamPush(SecretStream.State state, byte[] cipher, byte[] message, long messageLen, byte tag)
      Encrypt a message. This is like cryptoSecretStreamPush but without additional data or an address to store the cipher.
      Parameters:
      state - State as initialised in cryptoSecretStreamInitPush.
      cipher - The resulting cipher of size SecretStream.ABYTES + messageLen.
      message - The message to encrypt.
      messageLen - The message length.
      tag - The tag.
      Returns:
      True if the message was encrypted.
    • cryptoSecretStreamInitPull

      boolean cryptoSecretStreamInitPull(SecretStream.State state, byte[] header, byte[] key)
      Initialises decryption using a state and a key.
      Parameters:
      state - State to be used in other cryptoSecretStreamPush() functions.
      header - The header of size SecretStream.HEADERBYTES.
      key - The key as generated by cryptoSecretStreamKeygen(byte[]).
      Returns:
      True if successfully initialised state.
    • cryptoSecretStreamPull

      boolean cryptoSecretStreamPull(SecretStream.State state, byte[] message, long[] messageAddress, byte[] tag, byte[] cipher, long cipherLen, byte[] additionalData, long additionalDataLen)
      Decrypt a message.
      Parameters:
      state - The state as put into cryptoSecretStreamInitPull.
      message - The message of size cipherLen - SecretStream.ABYTES.
      messageAddress - The place to store the message.
      tag - The tag.
      cipher - The resulting encrypted message.
      cipherLen - The cipher length.
      additionalData - Any authenticated data.
      additionalDataLen - Authenticated data length.
      Returns:
      True if successful decryption.
    • cryptoSecretStreamPull

      boolean cryptoSecretStreamPull(SecretStream.State state, byte[] message, byte[] tag, byte[] cipher, long cipherLen)
      Decrypt a message without additional data.
      Parameters:
      state - The state as put into cryptoSecretStreamInitPull.
      message - The message of size cipherLen - SecretStream.ABYTES.
      tag - The tag.
      cipher - The resulting encrypted message.
      cipherLen - The cipher length.
      Returns:
      True if successful decryption.
    • cryptoSecretStreamRekey

      void cryptoSecretStreamRekey(SecretStream.State state)
      Explicitly rekeys.
      Parameters:
      state - The state to update.