Copyright | (C) Hécate Moonlight 2023 |
---|---|
License | BSD-3-Clause |
Maintainer | The Haskell Cryptography Group |
Stability | Stable |
Portability | GHC only |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- cryptoAEADXChaCha20Poly1305IETFEncrypt :: Ptr CUChar -> Ptr CULLong -> Ptr CUChar -> CULLong -> Ptr CUChar -> CULLong -> Ptr CUChar -> Ptr CUChar -> Ptr CUChar -> IO CInt
- cryptoAEADXChaCha20Poly1305IETFDecrypt :: Ptr CUChar -> Ptr CULLong -> Ptr CUChar -> Ptr CUChar -> CULLong -> Ptr CUChar -> CULLong -> Ptr CUChar -> Ptr CUChar -> IO CInt
- cryptoAEADXChaCha20Poly1305IETFEncryptDetached :: Ptr CUChar -> Ptr CUChar -> Ptr CULLong -> Ptr CUChar -> CULLong -> Ptr CUChar -> CULLong -> Ptr CUChar -> Ptr CUChar -> Ptr CUChar -> IO CInt
- cryptoAEADXChaCha20Poly1305IETFDecryptDetached :: Ptr CUChar -> Ptr CUChar -> Ptr CUChar -> CULLong -> Ptr CUChar -> Ptr CUChar -> CULLong -> Ptr CUChar -> Ptr CUChar -> IO CInt
- cryptoAEADXChaCha20Poly1305IETFKeyBytes :: CSize
- cryptoAEADXChaCha20Polt1305IETFPubBytes :: CSize
- cryptoAEADXChaCha20Poly1305IETFABytes :: CSize
Introduction
With XChaCha20-Poly1305-IETF
, you can encrypt a message witha key and a nonce to keept it
confidential, as well as compute an authentication tag to make sure that the message
has not been tampered with.
A typical use case for additional data is to authenticate protocol-specific metadata about the message, such as its length and encoding.
For a deeper dive into the limitations of the implementation, please refer to the manual: https://doc.libsodium.org/secret-key_cryptography/aead#limitations
Operations
cryptoAEADXChaCha20Poly1305IETFEncrypt Source #
:: Ptr CUChar | Output buffer. Contains the encrypted message, authentication tag, and non-confidential additional data. |
-> Ptr CULLong | Size of computed output. Should be message length plus |
-> Ptr CUChar | Message to be encrypted. |
-> CULLong | Message length. |
-> Ptr CUChar | Non-confidential additional data. Can be null with additional data length of 0 if no additional data is required. |
-> CULLong | Additional data length. |
-> Ptr CUChar |
|
-> Ptr CUChar | Public nonce of size |
-> Ptr CUChar | Secret key of size |
-> IO CInt | Returns -1 on failure, 0 on success. |
This function encrypts a message, and then appends the authentication tag to the encrypted message.
See: crypto_aead_xchacha20poly1305_ietf_encrypt()
Since: 0.0.1.0
cryptoAEADXChaCha20Poly1305IETFDecrypt Source #
:: Ptr CUChar | Output buffer. At most the cipher text length minus |
-> Ptr CULLong | Size of computed output. Should be message length plus |
-> Ptr CUChar |
|
-> Ptr CUChar | Ciphertext to decrypt. |
-> CULLong | Ciphertext length. |
-> Ptr CUChar | Non-confidential additional data. Can be null with additional data length of 0 if no additional data is required. |
-> CULLong | Additional data length. |
-> Ptr CUChar | Public nonce of size |
-> Ptr CUChar | Secret key of size |
-> IO CInt | Returns -1 on failure, 0 on success. |
This function verifies that an encrypted ciphertext includes a valid tag.
See: crypto_aead_xchacha20poly1305_ietf_decrypt()
Since: 0.0.1.0
cryptoAEADXChaCha20Poly1305IETFEncryptDetached Source #
:: Ptr CUChar | Output buffer. Contains the encrypted message with length equal to the message. |
-> Ptr CUChar | The authentication tag. Has length |
-> Ptr CULLong | Length of the authentication tag buffer. |
-> Ptr CUChar | Message to be encrypted. |
-> CULLong | Length of input message. |
-> Ptr CUChar | Additional, non-confidential data. |
-> CULLong | Length of the additional, non-confidential data. |
-> Ptr CUChar | Not used in this particular construction, should always be |
-> Ptr CUChar | Public nonce of size |
-> Ptr CUChar | Secret key of size |
-> IO CInt | Returns -1 on failure, 0 on success. |
This is the "detached" version of the encryption function. The encrypted message and authentication tag are output to different buffers instead of the tag being appended to the encrypted message.
See: crypto_aead_xchacha20poly1305_ietf_encrypt_detached()
Since: 0.0.1.0
cryptoAEADXChaCha20Poly1305IETFDecryptDetached Source #
:: Ptr CUChar | If the tag is valid, the ciphertext is decrypted and put into this buffer. |
-> Ptr CUChar | Not used in this particular construction, should always be |
-> Ptr CUChar | Ciphertext to be decrypted. |
-> CULLong | Length of the ciphertext. |
-> Ptr CUChar | The authentication tag. Has length |
-> Ptr CUChar | Additional, non-confidential data. |
-> CULLong | Length of the additional, non-confidential data. |
-> Ptr CUChar | Public nonce of size |
-> Ptr CUChar | Secret key of size |
-> IO CInt | Returns 0 on success, -1 if tag is not valid. |
This is the "detached" version of the decryption function. Verifies that the authentication tag is valid for the ciphertext, key, nonce, and additional data.
See: crypto_aead_xchacha20poly1305_ietf_decrypt_detached()
Since: 0.0.1.0
Constants
cryptoAEADXChaCha20Poly1305IETFKeyBytes :: CSize Source #
Recommended length of a key for this construction.
See: crypto_aead_xchacha20poly1305_ietf_KEYBYTES
Since: 0.0.1.0
cryptoAEADXChaCha20Polt1305IETFPubBytes :: CSize Source #
Recommended length of a nonce for this construction.
See: crypto_aead_xchacha20poly1305_ietf_NPUBBYTES
Since: 0.0.1.0
cryptoAEADXChaCha20Poly1305IETFABytes :: CSize Source #
Recommended length for the authentication tag.
See: crypto_aead_xchacha20poly1305_ietf_ABYTES
Since: 0.0.1.0