Copyright | (c) 2013 Stefan Bühler |
---|---|
License | MIT-style (see the file COPYING) |
Maintainer | stbuehler@web.de |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell98 |
Generic interface to calculate key based hashes.
- class KeyedHashAlgorithm k where
- data KeyedHash = KeyedHashAlgorithm k => KeyedHash !k
- keyedHashDigestSize :: KeyedHashAlgorithm k => k -> Int
- keyedHashDigestSize' :: KeyedHash -> Int
- keyedHashName :: KeyedHashAlgorithm k => k -> String
- keyedHashName' :: KeyedHash -> String
- keyedHashInit :: KeyedHashAlgorithm k => ByteString -> Tagged k KeyedHash
- keyedHashInit' :: KeyedHashAlgorithm k => k -> ByteString -> KeyedHash
- keyedHashUpdate :: KeyedHash -> ByteString -> KeyedHash
- keyedHashUpdateLazy :: KeyedHash -> ByteString -> KeyedHash
- keyedHashFinalize :: KeyedHash -> ByteString
- keyedHash :: KeyedHashAlgorithm k => ByteString -> ByteString -> Tagged k ByteString
- keyedHash' :: KeyedHashAlgorithm k => k -> ByteString -> ByteString -> ByteString
- keyedHashLazy :: KeyedHashAlgorithm k => ByteString -> ByteString -> Tagged k ByteString
- keyedHashLazy' :: KeyedHashAlgorithm k => k -> ByteString -> ByteString -> ByteString
Documentation
class KeyedHashAlgorithm k where Source #
KeyedHashAlgorithm
is a class for keyed hash algorithms that take a key and a message to produce a digest.
The most popular example is HMAC
.
implKeyedHashDigestSize, implKeyedHashName, implKeyedHashInit, implKeyedHashUpdate, implKeyedHashFinalize
implKeyedHashDigestSize :: Tagged k Int Source #
Digest size in bytes the keyed hash algorithm returns
implKeyedHashName :: Tagged k String Source #
Name
implKeyedHashInit :: ByteString -> k Source #
Initialize state from a key
implKeyedHashUpdate :: k -> ByteString -> k Source #
Add more message data to the state
implKeyedHashUpdateLazy :: k -> ByteString -> k Source #
Add more lazy message data to the state
implKeyedHashFinalize :: k -> ByteString Source #
Produce final digest
KeyedHash
hides the KeyedHashAlgorithm
implementation.
KeyedHashAlgorithm k => KeyedHash !k |
keyedHashDigestSize :: KeyedHashAlgorithm k => k -> Int Source #
Untagged variant of implKeyedHashDigestSize
; takes a (possible undefined
) key typed value from a KeyedHashAlgorithm
instance as parameter.
keyedHashDigestSize' :: KeyedHash -> Int Source #
Get implKeyedHashDigestSize
from a KeyedHash
keyedHashName :: KeyedHashAlgorithm k => k -> String Source #
Untagged variant of implKeyedHashName
; takes a (possible undefined
) key typed value from a KeyedHashAlgorithm
instance as parameter.
keyedHashName' :: KeyedHash -> String Source #
Get implKeyedHashName
from a KeyedHash
:: KeyedHashAlgorithm k | |
=> ByteString |
|
-> Tagged k KeyedHash |
Initialize a KeyedHash
context from a key
keyedHashInit' :: KeyedHashAlgorithm k => k -> ByteString -> KeyedHash Source #
Untagged variant of keyedHashInit
; takes a (possible undefined
) key typed value from a KeyedHashAlgorithm
instance as parameter.
keyedHashUpdate :: KeyedHash -> ByteString -> KeyedHash Source #
Add more message data to the context
keyedHashUpdateLazy :: KeyedHash -> ByteString -> KeyedHash Source #
Add more lazy message data to the context
keyedHashFinalize :: KeyedHash -> ByteString Source #
Produce final digest
keyedHash :: KeyedHashAlgorithm k => ByteString -> ByteString -> Tagged k ByteString Source #
Helper to hash key
and message
in one step
Example:
untag (keyedHash (fromString "secretkey") (fromString "secret message") :: Tagged (HMAC SHA256) B.ByteString)
keyedHash' :: KeyedHashAlgorithm k => k -> ByteString -> ByteString -> ByteString Source #
Untagged variant of keyedHash
; takes a (possible undefined
) key typed value from a KeyedHashAlgorithm
instance as parameter.
Example:
keyedHash' (undefined :: HMAC SHA256) (fromString "secretkey") (fromString "secret message")
keyedHashLazy :: KeyedHashAlgorithm k => ByteString -> ByteString -> Tagged k ByteString Source #
Helper to hash key
and lazy message
in one step
Example:
untag (keyedHashLazy (fromString "secretkey") (fromString "secret message") :: Tagged (HMAC SHA256) B.ByteString)
keyedHashLazy' :: KeyedHashAlgorithm k => k -> ByteString -> ByteString -> ByteString Source #
Untagged variant of keyedHashLazy
; takes a (possible undefined
) key typed value from a KeyedHashAlgorithm
instance as parameter.
Example:
keyedHashLazy' (undefined :: HMAC SHA256) (fromString "secretkey") (fromString "secret message")