libsodium-bindings-0.0.1.1: FFI bindings to libsodium
Copyright(C) Koz Ross 2022
LicenseBSD-3-Clause
Maintainerkoz.ross@retro-freedom.nz
StabilityStable
PortabilityGHC only
Safe HaskellTrustworthy
LanguageHaskell2010

LibSodium.Bindings.XChaCha20

Description

Direct bindings to XChaCha20 primitives.

Synopsis

Functions

cryptoStreamXChaCha20 Source #

Arguments

:: Ptr CUChar

Out-parameter where pseudorandom bytes will be stored

-> CULLong

How many bytes to write

-> Ptr CUChar

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

-> Ptr CUChar

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

-> 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()

Since: 0.0.1.0

cryptoStreamXChaCha20Xor Source #

Arguments

:: Ptr CUChar

Out-parameter where the ciphertext will be stored

-> Ptr CUChar

Message location (won't be modified)

-> CULLong

Message length

-> Ptr CUChar

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

-> Ptr CUChar

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

-> 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()

Since: 0.0.1.0

cryptoStreamXChaCha20XorIC Source #

Arguments

:: Ptr CUChar

Out-parameter where the ciphertext will be stored

-> Ptr CUChar

Message location (won't be modified)

-> CULLong

Message length

-> Ptr CUChar

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

-> Word64

Value of block counter (see documentation)

-> Ptr CUChar

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

-> 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()

Since: 0.0.1.0

cryptoStreamXChaCha20Keygen Source #

Arguments

:: Ptr CUChar

Out-parameter where the key will be stored

-> IO ()

Doesn't return anything meaningful

Generate a random XChaCha20 secret key. This will always write cryptoStreamXChaCha20KeyBytes to the out-parameter.

See: crypto_stream_xchacha20_keygen()

Since: 0.0.1.0

Constants

cryptoStreamXChaCha20KeyBytes :: CSize Source #

The number of bytes in an XChaCha20 secret key.

See: crypto_stream_xchacha20_KEYBYTES

Since: 0.0.1.0

cryptoStreamXChaCha20NonceBytes :: CSize Source #

The number of bytes in an XChaCha20 nonce.

See: crypto_stream_xchacha20_NONCEBYTES

Since: 0.0.1.0