| License | BSD-style |
|---|---|
| Maintainer | Matthias Valvekens <dev@mvalvekens.be> |
| Stability | experimental |
| Portability | unknown |
| Safe Haskell | None |
| Language | Haskell2010 |
Crypto.MAC.KeyedBlake2
Contents
Description
Expose a MAC interface to the keyed Blake2 algorithms defined in RFC 7693.
Synopsis
- class HashAlgorithm a => HashBlake2 a
- newtype KeyedBlake2 a = KeyedBlake2 {}
- 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
| (IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 512) => HashBlake2 (Blake2b bitlen) Source # | |
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 # | |
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 # | |
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 # | |
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 | |
Instances
| NFData (KeyedBlake2 a) Source # | |
Defined in Crypto.MAC.KeyedBlake2 Methods rnf :: KeyedBlake2 a -> () | |
| Eq (KeyedBlake2 a) Source # | |
Defined in Crypto.MAC.KeyedBlake2 | |
| ByteArrayAccess (KeyedBlake2 a) Source # | |
Defined in Crypto.MAC.KeyedBlake2 Methods length :: KeyedBlake2 a -> Int withByteArray :: KeyedBlake2 a -> (Ptr p -> IO a0) -> IO a0 copyByteArrayToPtr :: KeyedBlake2 a -> Ptr p -> IO () | |
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
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.
The key may be up to 64 bytes for Blake2b and Blake2bp, and up to 32 bytes for Blake2s and Blake2sp, whatever the digest size (RFC 7693). A longer key is an error.
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.