Copyright | (C) Koz Ross 2022 |
---|---|
License | BSD-3-Clause |
Maintainer | koz.ross@retro-freedom.nz |
Stability | Stable |
Portability | GHC only |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
Direct bindings to XChaCha20 primitives.
Synopsis
- cryptoStreamXChaCha20 :: Ptr CUChar -> CULLong -> Ptr CUChar -> Ptr CUChar -> IO CInt
- cryptoStreamXChaCha20Xor :: Ptr CUChar -> Ptr CUChar -> CULLong -> Ptr CUChar -> Ptr CUChar -> IO CInt
- cryptoStreamXChaCha20XorIC :: Ptr CUChar -> Ptr CUChar -> CULLong -> Ptr CUChar -> Word64 -> Ptr CUChar -> IO CInt
- cryptoStreamXChaCha20Keygen :: Ptr CUChar -> IO ()
- cryptoStreamXChaCha20KeyBytes :: CSize
- cryptoStreamXChaCha20NonceBytes :: CSize
Functions
cryptoStreamXChaCha20 Source #
:: 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 #
:: 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 #
:: 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 #
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