cryptonite-0.25: Cryptography Primitives sink

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Stability | experimental
Portability | unknown
Safe Haskell | None
Language | Haskell2010

Crypto.MAC.HMAC

Contents

- Incremental

Description

Provide the HMAC (Hash based Message Authentification Code) base algorithm. http://en.wikipedia.org/wiki/HMAC

Synopsis

- hmac :: (ByteArrayAccess key, ByteArrayAccess message, HashAlgorithm a) => key -> message -> HMAC a
- newtype HMAC a = HMAC {
  - hmacGetDigest :: Digest a
  }
- data Context hashalg = Context !(Context hashalg) !(Context hashalg)
- initialize :: (ByteArrayAccess key, HashAlgorithm a) => key -> Context a
- update :: (ByteArrayAccess message, HashAlgorithm a) => Context a -> message -> Context a
- updates :: (ByteArrayAccess message, HashAlgorithm a) => Context a -> [message] -> Context a
- finalize :: HashAlgorithm a => Context a -> HMAC a

# Documentation

hmac Source #

Arguments

:: (ByteArrayAccess key, ByteArrayAccess message, HashAlgorithm a) |
=> key | Secret key
-> message | Message to MAC
-> HMAC a |

compute a MAC using the supplied hashing function

newtype HMAC a Source #

Represent an HMAC that is a phantom type with the hash used to produce the mac.

The Eq instance is constant time.

Constructors

HMAC |

Fields

- hmacGetDigest :: Digest a

Instances

Eq (HMAC a) Source # |
Instance details Defined in Crypto.MAC.HMAC Methods (==) :: HMAC a -> HMAC a -> Bool Source # (/=) :: HMAC a -> HMAC a -> Bool Source #
ByteArrayAccess (HMAC a) Source # |
Instance details Defined in Crypto.MAC.HMAC Methods length :: HMAC a -> Int Source # withByteArray :: HMAC a -> (Ptr p -> IO a0) -> IO a0 Source # copyByteArrayToPtr :: HMAC a -> Ptr p -> IO () Source #

# Incremental

data Context hashalg Source #

Represent an ongoing HMAC state, that can be appended with `update` and finalize to an HMAC with `hmacFinalize`

Constructors

Context !(Context hashalg) !(Context hashalg) |

initialize Source #

Arguments

:: (ByteArrayAccess key, HashAlgorithm a) |
=> key | Secret key
-> Context a |

Initialize a new incremental HMAC context

update Source #

Arguments

:: (ByteArrayAccess message, HashAlgorithm a) |
=> Context a | Current HMAC context
-> message | Message to append to the MAC
-> Context a | Updated HMAC context

Incrementally update a HMAC context

updates Source #

Arguments

:: (ByteArrayAccess message, HashAlgorithm a) |
=> Context a | Current HMAC context
-> [message] | Messages to append to the MAC
-> Context a | Updated HMAC context

Increamentally update a HMAC context with multiple inputs

finalize :: HashAlgorithm a => Context a -> HMAC a Source #

Finalize a HMAC context and return the HMAC.