Copyright | (C) Hécate Moonlight |
---|---|
License | BSD-3-Clause |
Maintainer | The Haskell Cryptography Group |
Stability | Stable |
Portability | GHC only |
Safe Haskell | None |
Language | Haskell2010 |
Introduction
Compute an authentication tag for a message and a secret key, and verify that a given tag is valid for a given message and a key.
The function computing the tag is deterministic: the same (message, key) tuple will always produce the same output. However, even if the message is public, knowing the key is required in order to be able to compute a valid tag. Therefore, the key should remain confidential. The tag, however, can be public.
The operations of this module are backed by the HMAC-SHA512-256 algorithm.
Usage
A typical use case is:
A
prepares a message, adds an authentication tag, sends it toB
A
doesn't store the message- Later on,
B
sends the message and the authentication tag toA
A
uses the authentication tag to verify that it created this message.
This operation does not encrypt the message. It only computes and verifies an authentication tag.
Functions
:: Ptr CUChar | Buffer that holds the tag |
-> Ptr CUChar | Buffer that holds the message |
-> CULLong | Length of the message |
-> Ptr CUChar | Buffer that holds the secret key of size |
-> IO CInt | Returns -1 if the verification fails, and 0 if it passes. |
Verify that the tag is valid for the provided message and secret key.
See: crypto_auth_verify()
Since: 0.0.1.0
:: Ptr CUChar | Buffer that holds the secret key of size |
-> IO () |
Create a random secret key of size cryptoAuthKeyBytes
It is equivalent to calling randombytesBuf
but
improves code clarity and can prevent misuse by ensuring that the provided
key length is always be correct.
See: crypto_auth_keygen()
Since: 0.0.1.0