Copyright | (c) Piyush P Kurur 2019 |
---|---|
License | Apache-2.0 OR BSD-3-Clause |
Maintainer | Piyush P Kurur <ppk@iitpkd.ac.in> |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Keyed Hashing.
The keyed version of a cryptographic hash. Certain hashes like blake2 can be used for message authentication where the message is essentially appended to the key and hashed. This module is meant to handle such keyed primitives. Note that this naive message authentication is vulnerable to length extension attack when combined with a Merkel-Damgrad like hash like the sha2 family of hashes; they require a more complicated HMAC construction.
The message authentication code associated with the hashes.
Keyed prim |
Instances
class KeyedHash prim where Source #
Class of primitives, typically cryptographic hashes, that when used as a keyed hash gives a safe MAC.
data family Key p :: Type Source #
The type family that captures the key of a keyed primitive.
Instances
unsafeToKeyed :: prim -> Keyed prim Source #
Converts the hash value to the corresponding
value. This function violates the principle that semantically
distinct values should be of distinct types and hence should be
considered unsafe.Keyed
unsafeToPrim :: Keyed prim -> prim Source #
Converts a Keyed value to the corresponding hash value. This function violates the principle that semantically distinct values should be of distinct types and hence should be considered unsafe