HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulelibsodium-bindings-0.0.1.1Haskell2010

LibSodium.Bindings.XChaCha20

Direct bindings to XChaCha20 primitives.

  • 6 values

Functions

4 declarations
valuecryptoStreamXChaCha20
  1. :: Ptr CUChar

    Out-parameter where pseudorandom bytes will be stored

  2. -> CULLong

    How many bytes to write

  3. -> Ptr CUChar

    Nonce location (see documentation, won't be modified)

  4. -> Ptr CUChar

    Secret key location (see documentation, won't be modified)

  5. -> IO CInt

    Always 0 (see documentation)

#

Generate and store a given number of pseudorandom bytes, using a nonce and a secret key. The amount of data read from the nonce location and secret key location will be cryptoStreamXChaCha20NonceBytes and cryptoStreamXChaCha20KeyBytes respectively.

This function theoretically returns 0 on success, and -1 on failure. However, this cannot ever fail, although its documentation does not explain this.

See: crypto_stream_xchacha20()

valuecryptoStreamXChaCha20Xor
  1. :: Ptr CUChar

    Out-parameter where the ciphertext will be stored

  2. -> Ptr CUChar

    Message location (won't be modified)

  3. -> CULLong

    Message length

  4. -> Ptr CUChar

    Nonce location (see documentation, won't be modified)

  5. -> Ptr CUChar

    Secret key location (see documentation, won't be modified)

  6. -> IO CInt

    Always 0 (see documentation)

#

Encrypt a message of the given length, using a nonce and a secret key. The amount of data read from the nonce location and secret key location will be cryptoStreamXChaCha20NonceBytes and cryptoStreamXChaCha20KeyBytes respectively.

The resulting ciphertext does not include an authentication tag. It will be combined with the output of the stream cipher using the XOR operation.

This function theoretically returns 0 on success, and -1 on failure. However, this cannot ever fail, although its documentation does not explain this.

Important note

The message location and ciphertext location can be the same: this will produce in-place encryption. However, if they are not the same, they must be non-overlapping.

See: crypto_stream_xchacha20_xor()

valuecryptoStreamXChaCha20XorIC
  1. :: Ptr CUChar

    Out-parameter where the ciphertext will be stored

  2. -> Ptr CUChar

    Message location (won't be modified)

  3. -> CULLong

    Message length

  4. -> Ptr CUChar

    Nonce location (see documentation, won't be modified)

  5. -> Word64

    Value of block counter (see documentation)

  6. -> Ptr CUChar

    Secret key location (see documentation, won't be modified)

  7. -> IO CInt

    Always 0 (see documentation)

#

As cryptoStreamXChaCha20Xor, but allows setting the initial value of the block counter to a non-zero value. This permits direct access to any block without having to compute previous ones.

See the documentation of cryptoStreamXChaCha20Xor for caveats on the use of this function.

See: crypto_stream_xchacha20_xor_ic()

Constants

2 declarations