cryptoHashSHA256 Hash the content of the second buffer and put the result in the first buffer.
See: crypto_hash_sha256()
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05
Modulelibsodium-bindings-0.0.1.1Haskell2010
The SHA-256 and SHA-512 functions are provided for interoperability with other applications. If you are
looking for a generic hash function and not specifically SHA-2, using
LibSodium.Bindings.GenericHashing (BLAKE2b) might be a better choice.
These functions are also not suitable for hashing passwords or deriving keys from passwords.
Use LibSodium.Bindings.PasswordHashing instead.
Only use these functions for interoperability with 3rd party services.
These functions are not keyed and are thus deterministic. In addition, the untruncated versions are vulnerable to length extension attacks. A message can be hashed in a single pass, but a streaming API is also available to process a message as a sequence of multiple chunks.
cryptoHashSHA256 Hash the content of the second buffer and put the result in the first buffer.
See: crypto_hash_sha256()
This is the opaque state held and used by the SHA-256 functions.
Its size is cryptoHashSHA256StateBytes.
Perform an operation with a CryptoHashSHA256State of size cryptoHashSHA256StateBytes allocated and deallocated automatically.
⚠️ The return value of withCryptoHashSHA256State MUST NOT leak the CryptoHashSHA256State.
Please refer to the documentation of allocaBytes for more operational details.
cryptoHashSHA256Init :: Ptr CryptoHashSHA256StateA pointer to an uninitialised hash state. Cannot be Foreign.nullPtr.
-> IO CIntReturns 0 on success, -1 on error.
This function initializes the CryptoHashSHA256State state.
Call this function on a Ptr CryptoHashSHA256State before using it as an argument in any other function in this module.
Add a new chunk to the message that will eventually be hashed.
After all parts have been supplied, cryptoHashSHA256Final can be used to finalise the operation and get the final hash.
Finalise the hashing of a message. The final hash is padded with extra zeros if necessary, then put in a buffer.
After this operation, the buffer containing the CryptoHashSHA256State is emptied and cannot be relied upon.
The size of a SHA256-hashed message.
The size of a CryptoHashSHA256State.
cryptoAuthHMACSHA256 :: Ptr CUCharA pointer to the buffer holding the authenticator.
-> Ptr CUCharA pointer to the message to be authenticated.
-> CULLongThe length of the message to be authenticated.
-> Ptr CUCharA pointer to the secret key used for authentication, of length cryptoAuthHMACSHA256Bytes.
-> IO CIntReturns 0 on success, -1 on error.
Authenticate a message given its size and a secret key, and produce an authenticator to be validated with cryptoAuthHMACSHA256Verify.
See: crypto_auth_hmacsha256().
cryptoAuthHMACSHA256Verify :: Ptr CUCharA pointer to buffer holding the authenticator.
-> Ptr CUCharA pointer to the message that is being authenticated.
-> CULLongThe length of the message that is being authenticated.
-> Ptr CUCharA pointer to the secret key, of size cryptoAuthHMACSHA256KeyBytes.
-> IO CIntReturns 0 on success, -1 on failure.
Verify that an authenticator provided by cryptoAuthHMACSHA256 is correct.
cryptoAuthHMACSHA256Keygen :: Ptr CUCharA pointer to the buffer that will hold the secret key, of size cryptoAuthHMACSHA256KeyBytes.
-> IO ()Nothing is returned
Create a random key of the correct length.
This is the opaque state held and used by the HMAC-SHA-256 functions.
Its size is cryptoAuthHMACSHA256StateBytes bytes.
Please refer to the documentation of allocaBytes for more operational details.
Perform an operation with a CryptoAuthHMACSHA256State of size cryptoAuthHMACSHA256StateBytes allocated and deallocated automatically.
⚠️ The return value of withCryptoAuthHMACSHA256State MUST NOT leak the CryptoAuthHMACSHA256State.
Please refer to the documentation of allocaBytes for more operational details.
This function initializes the CryptoAuthHMACSHA256State state.
Call this function on a Ptr CryptoAuthHMACSHA256State before using it as an argument in any other function in this module.
Add a new chunk to the message that will eventually be hashed.
After all parts have been supplied, cryptoAuthHMACSHA256Final can be used to finalise the operation and get the final hash.
Finalise the hashing of a message. The final hash is padded with extra zeros if necessary, then put in a buffer.
After this operation, the buffer containing the CryptoAuthHMACSHA256State is emptied and cannot be relied upon.
The size of a CryptoAuthHMACSHA256State.
The size of a HMAC-SHA-256 hash
The size of a HMAC-SHA-256 key
cryptoHashSHA512 Hash the content of the second buffer and put the result in the first buffer.
See: crypto_hash_sha512()
This is the opaque state held and used by the SHA-512 functions.
Its size is cryptoHashSHA512StateBytes.
Perform an operation with a 'CryptoHashSHA512State of size cryptoHashSHA512StateBytes allocated and deallocated automatically.
⚠️ The return value of withCryptoHashSHA512State MUST NOT leak the CryptoHashSHA512State.
Please refer to the documentation of allocaBytes for more operational details.
cryptoHashSHA512Init :: Ptr CryptoHashSHA512StateA pointer to an initialised hash state. Cannot be Foreign.nullPtr.
-> IO CIntReturns 0 on success, -1 on error.
This function initializes the CryptoHashSHA512State state.
Call this function on a 'Ptr CryptoHashSHA512State' before using it as an argument in any other function in this module.
Add a new chunk to the message that will eventually be hashed.
After all parts have been supplied, cryptoHashSHA512Final can be used to finalise the operation and get the final hash.
Finalise the hashing of a message. The final hash is padded with extra zeros if necessary, then put in a buffer.
After this operation, the buffer containing the CryptoHashSHA512State is emptied and cannot be relied upon.
The size of a SHA512-hash message.
The size of a CryptoHashSHA512State.
This is the opaque state held and used by the HMAC-SHA-512 functions.
Its size is cryptoAuthHMACSHA512StateBytes bytes.
Please refer to the documentation of allocaBytes for more operational details.
Perform an operation with a CryptoAuthHMACSHA512State of size cryptoAuthHMACSHA512StateBytes allocated and deallocated automatically.
⚠️ The return value of withCryptoAuthHMACSHA512State MUST NOT leak the CryptoAuthHMACSHA512State.
Please refer to the documentation of allocaBytes for more operational details.
cryptoAuthHMACSHA512 :: Ptr CUCharA pointer to the buffer holding the authenticator.
-> Ptr CUCharA pointer to the message to be authenticated.
-> CULLongThe length of the message to be authenticated.
-> Ptr CUCharA pointer to the secret key used for authentication, of length cryptoAuthHMACSHA512Bytes.
-> IO CIntReturns 0 on success, -1 on error.
Authenticate a message given its size and a secret key, and produce an authenticator to be validated with cryptoAuthHMACSHA512Verify.
See: crypto_auth_hmacsha512().
cryptoAuthHMACSHA512Verify :: Ptr CUCharA pointer to buffer holding the authenticator.
-> Ptr CUCharA pointer to the message that is being authenticated.
-> CULLongThe length of the message that is being authenticated.
-> Ptr CUCharA pointer to the secret key, of size cryptoAuthHMACSHA512KeyBytes.
-> IO CIntReturns 0 on success, -1 on failure.
Verify that an authenticator provided by cryptoAuthHMACSHA512 is correct.
cryptoAuthHMACSHA512Keygen :: Ptr CUCharA pointer to the buffer that will hold the secret key, of size cryptoAuthHMACSHA512KeyBytes.
-> IO ()Nothing is returned
Create a random key of the correct length.
This function initializes the CryptoAuthHMACSHA512State state.
Call this function on a 'Ptr CryptoAuthHMACSHA512State' before using it as an argument in any other function in this module.
Add a new chunk to the message that will eventually be hashed.
After all parts have been supplied, cryptoAuthHMACSHA512Final can be used to finalise the operation and get the final hash.
Finalise the hashing of a message. The final hash is padded with extra zeros if necessary, then put in a buffer.
After this operation, the buffer containing the CryptoAuthHMACSHA512State is emptied and cannot be relied upon.
The size of a CryptoAuthHMACSHA512State.
The size of a HMAC-SHA-512 hash
The size of a HMAC-SHA-512 key
HMAC-SHA-512-256 is implemented as HMAC-SHA-512 with the output truncated to 256 bits. This is slightly faster than HMAC-SHA-256. Note that this construction is not the same as HMAC-SHA-512/256, which is HMAC using the SHA-512/256 function.
This is the opaque state held and used by the HMAC-SHA-512256 functions.
Its size is cryptoAuthHMACSHA512256StateBytes bytes.
Please refer to the documentation of allocaBytes for more operational details.
Perform an operation with a CryptoAuthHMACSHA512256State of size cryptoAuthHMACSHA512256StateBytes allocated and deallocated automatically.
⚠️ The return value of withCryptoAuthHMACSHA512256State MUST NOT leak the CryptoAuthHMACSHA512256State.
Please refer to the documentation of allocaBytes for more operational details.
cryptoAuthHMACSHA512256 :: Ptr CUCharA pointer to the buffer holding the authenticator.
-> Ptr CUCharA pointer to the message to be authenticated.
-> CULLongThe length of the message to be authenticated.
-> Ptr CUCharA pointer to the secret key used for authentication, of length cryptoAuthHMACSHA512256Bytes.
-> IO CIntReturns 0 on success, -1 on error.
Authenticate a message given its size and a secret key, and produce an authenticator to be validated with cryptoAuthHMACSHA512256Verify.
cryptoAuthHMACSHA512256Verify :: Ptr CUCharA pointer to buffer holding the authenticator.
-> Ptr CUCharA pointer to the message that is being authenticated.
-> CULLongThe length of the message that is being authenticated.
-> Ptr CUCharA pointer to the secret key, of size cryptoAuthHMACSHA512256KeyBytes.
-> IO CIntReturns 0 on success, -1 on failure.
Verify that an authenticator provided by cryptoAuthHMACSHA512256 is correct.
cryptoAuthHMACSHA512256Keygen :: Ptr CUCharA pointer to the buffer that will hold the secret key, of size cryptoAuthHMACSHA512256KeyBytes.
-> IO ()Nothing is returned
Create a random key of the correct length.
This function initializes the CryptoAuthHMACSHA512256State state.
Call this function on a Ptr CryptoAuthHMACSHA512256State before using it as an argument in any other function in this module.
Add a new chunk to the message that will eventually be hashed.
After all parts have been supplied, cryptoAuthHMACSHA512256Final can be used to finalise the operation and get the final hash.
Finalise the hashing of a message. The final hash is padded with extra zeros if necessary, then put in a buffer.
After this operation, the buffer containing the CryptoAuthHMACSHA512256State is emptied and cannot be relied upon.
The size of a CryptoAuthHMACSHA512256State.
The size of a HMAC-SHA-512256 hash
The size of a HMAC-SHA-512256 key