| Copyright | (c) 2025 Jared Tobin |
|---|---|
| License | MIT |
| Maintainer | Jared Tobin <jared@ppad.tech> |
| Safe Haskell | None |
| Language | Haskell2010 |
Crypto.MAC.Poly1305
Description
A pure Poly1305 MAC implementation, as specified by RFC 8439.
Synopsis
- newtype MAC = MAC ByteString
- mac :: ByteString -> ByteString -> Maybe MAC
Poly1305 message authentication code
A Poly1305 message authentication code.
Note that you should compare MACs for equality using the Eq
instance, which performs the comparison in constant time, instead
of unwrapping and comparing the underlying ByteStrings.
>>>let Just foo@(MAC bs0) = mac key "hi">>>let Just bar@(MAC bs1) = mac key "there">>>foo == bar -- do thisFalse>>>bs0 == bs1 -- don't do thisFalse
Constructors
| MAC ByteString |
Arguments
| :: ByteString | 256-bit one-time key |
| -> ByteString | arbitrary-length message |
| -> Maybe MAC | 128-bit message authentication code |
Produce a Poly1305 MAC for the provided message, given the provided key.
Per RFC8439: the key, which is essentially a one-time key, should be unique, and MUST be unpredictable for each invocation.
The key must be exactly 256 bits in length.
>>>mac "i'll never use this key again!!!" "a message needing authentication"Just "O'\231Z\224\149\148\246\203[}\210\203\b\200\207"