crypton-1.0.4: Cryptography Primitives sink

License | BSD-style
Maintainer | Matthias Valvekens <dev@mvalvekens.be>
Stability | experimental
Portability | unknown
Safe Haskell | None
Language | Haskell2010

Crypto.MAC.KeyedBlake2

Contents

- Incremental

Description

Expose a MAC interface to the keyed Blake2 algorithms defined in RFC 7693.

Synopsis

- class HashAlgorithm a => HashBlake2 a
- newtype KeyedBlake2 a = KeyedBlake2 {
  - keyedBlake2GetDigest :: Digest a
  }
- keyedBlake2 :: (HashBlake2 a, ByteArrayAccess key, ByteArrayAccess ba) => key -> ba -> KeyedBlake2 a
- keyedBlake2Lazy :: (HashBlake2 a, ByteArrayAccess key) => key -> ByteString -> KeyedBlake2 a
- data Context a
- initialize :: (HashBlake2 a, ByteArrayAccess key) => key -> Context a
- update :: (HashBlake2 a, ByteArrayAccess ba) => Context a -> ba -> Context a
- updates :: (HashBlake2 a, ByteArrayAccess ba) => Context a -> [ba] -> Context a
- finalize :: HashBlake2 a => Context a -> KeyedBlake2 a

# Documentation

class HashAlgorithm a => HashBlake2 a Source #

Typeclass for the Blake2 family of digest functions.

Minimal complete definition

blake2InternalKeyedInit

#### Instances

Instances details

(IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 512) => HashBlake2 (Blake2b bitlen) Source # |
Instance details Defined in Crypto.Hash.Blake2 Methods blake2InternalKeyedInit :: Ptr (Context (Blake2b bitlen)) -> Ptr Word8 -> Word32 -> IO ()
(IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 512) => HashBlake2 (Blake2bp bitlen) Source # |
Instance details Defined in Crypto.Hash.Blake2 Methods blake2InternalKeyedInit :: Ptr (Context (Blake2bp bitlen)) -> Ptr Word8 -> Word32 -> IO ()
(IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 256) => HashBlake2 (Blake2s bitlen) Source # |
Instance details Defined in Crypto.Hash.Blake2 Methods blake2InternalKeyedInit :: Ptr (Context (Blake2s bitlen)) -> Ptr Word8 -> Word32 -> IO ()
(IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 256) => HashBlake2 (Blake2sp bitlen) Source # |
Instance details Defined in Crypto.Hash.Blake2 Methods blake2InternalKeyedInit :: Ptr (Context (Blake2sp bitlen)) -> Ptr Word8 -> Word32 -> IO ()

newtype KeyedBlake2 a Source #

Represent a Blake2b MAC 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

KeyedBlake2 |

Fields

- keyedBlake2GetDigest :: Digest a

#### Instances

Instances details

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

keyedBlake2 :: (HashBlake2 a, ByteArrayAccess key, ByteArrayAccess ba) => key -> ba -> KeyedBlake2 a Source #

Compute a Blake2 MAC using the supplied key.

keyedBlake2Lazy :: (HashBlake2 a, ByteArrayAccess key) => key -> ByteString -> KeyedBlake2 a Source #

Compute a Blake2 MAC using the supplied key, for a lazy input.

# Incremental

data Context a Source #

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

initialize :: (HashBlake2 a, ByteArrayAccess key) => key -> Context a Source #

Initialize a new incremental keyed Blake2 context with the supplied key.

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

Incrementally update a keyed Blake2 context.

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

Incrementally update a keyed Blake2 context with multiple inputs.

finalize :: HashBlake2 a => Context a -> KeyedBlake2 a Source #

Finalize a keyed Blake2 context and return the computed MAC.