Crypto.MAC.KMAC

crypton-1.0.1: Cryptography Primitives sink

License | BSD-style
Maintainer | Olivier Chéron <olivier.cheron@gmail.com>
Stability | experimental
Portability | unknown
Safe Haskell | None
Language | Haskell2010

Crypto.MAC.KMAC

Contents

- Incremental

Description

Provide the KMAC (Keccak Message Authentication Code) algorithm, derived from the SHA-3 base algorithm Keccak and defined in NIST SP800-185.

Synopsis

- class HashAlgorithm a => HashSHAKE a
- kmac :: (HashSHAKE a, ByteArrayAccess string, ByteArrayAccess key, ByteArrayAccess ba) => string -> key -> ba -> KMAC a
- newtype KMAC a = KMAC {
  - kmacGetDigest :: Digest a
  }
- data Context a
- initialize :: (HashSHAKE a, ByteArrayAccess string, ByteArrayAccess key) => string -> key -> Context a
- update :: (HashSHAKE a, ByteArrayAccess ba) => Context a -> ba -> Context a
- updates :: (HashSHAKE a, ByteArrayAccess ba) => Context a -> [ba] -> Context a
- finalize :: HashSHAKE a => Context a -> KMAC a

# Documentation

class HashAlgorithm a => HashSHAKE a #

Type class of SHAKE algorithms.

Minimal complete definition

cshakeInternalFinalize, cshakeOutputLength

#### Instances

Instances details

KnownNat bitlen => HashSHAKE (SHAKE128 bitlen) # |
Instance details Defined in Crypto.Hash.SHAKE Methods cshakeInternalFinalize :: Ptr (Context (SHAKE128 bitlen)) -> Ptr (Digest (SHAKE128 bitlen)) -> IO () cshakeOutputLength :: SHAKE128 bitlen -> Int
KnownNat bitlen => HashSHAKE (SHAKE256 bitlen) # |
Instance details Defined in Crypto.Hash.SHAKE Methods cshakeInternalFinalize :: Ptr (Context (SHAKE256 bitlen)) -> Ptr (Digest (SHAKE256 bitlen)) -> IO () cshakeOutputLength :: SHAKE256 bitlen -> Int

kmac :: (HashSHAKE a, ByteArrayAccess string, ByteArrayAccess key, ByteArrayAccess ba) => string -> key -> ba -> KMAC a #

Compute a KMAC using the supplied customization string and key.

newtype KMAC a #

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

The Eq instance is constant time. No Show instance is provided, to avoid printing by mistake.

Constructors

KMAC |
Fields kmacGetDigest :: Digest a

#### Instances

Instances details

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

# Incremental

data Context a #

Represent an ongoing KMAC state, that can be appended with `update` and finalized to a `KMAC` with `finalize`.

initialize :: (HashSHAKE a, ByteArrayAccess string, ByteArrayAccess key) => string -> key -> Context a #

Initialize a new incremental KMAC context with the supplied customization string and key.

update :: (HashSHAKE a, ByteArrayAccess ba) => Context a -> ba -> Context a #

Incrementally update a KMAC context.

updates :: (HashSHAKE a, ByteArrayAccess ba) => Context a -> [ba] -> Context a #

Incrementally update a KMAC context with multiple inputs.

finalize :: HashSHAKE a => Context a -> KMAC a #

Finalize a KMAC context and return the KMAC.