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 HMAC implementation based on the HashAlgorithm
class,
implementing the KeyedHashAlgorithm
class.
- data HMAC a
- hmacInit :: HashAlgorithm a => ByteString -> Tagged a KeyedHash
- hmacInit' :: HashAlgorithm a => a -> ByteString -> KeyedHash
- hmac :: HashAlgorithm a => ByteString -> ByteString -> Tagged a ByteString
- hmac' :: HashAlgorithm a => a -> ByteString -> ByteString -> ByteString
- hmacLazy :: HashAlgorithm a => ByteString -> ByteString -> Tagged a ByteString
- hmacLazy' :: HashAlgorithm a => a -> ByteString -> ByteString -> ByteString
Documentation
HMAC
is a generic KeyedHashAlgorithm
instance to calculate the HMAC
based
on a HashAlgorithm
HashAlgorithm a => KeyedHashAlgorithm (HMAC a) Source # | |
:: HashAlgorithm a | |
=> ByteString |
|
-> Tagged a KeyedHash |
hmacInit' :: HashAlgorithm a => a -> ByteString -> KeyedHash Source #
Untagged variant of hmacInit
; takes a (possible undefined
) typed HashAlgorithm
context as parameter.
Example:
keyedHashFinalize $ flip keyedHashUpdate (fromString "secret message") $ hmacInit' (undefined :: SHA256) (fromString "secretkey")
:: HashAlgorithm a | |
=> ByteString |
|
-> ByteString |
|
-> Tagged a ByteString |
calculate HMAC with a HashAlgorithm
for a key
and message
Example:
untag (hmac (fromString "secretkey") (fromString "secret message") :: Tagged SHA256 B.ByteString)
hmac' :: HashAlgorithm a => a -> ByteString -> ByteString -> ByteString Source #
Untagged variant of hmac
; takes a (possible undefined
) typed HashAlgorithm
context as parameter.
Example:
hmac' (undefined :: SHA256) (fromString "secretkey") (fromString "secret message")
:: HashAlgorithm a | |
=> ByteString |
|
-> ByteString |
|
-> Tagged a ByteString |
calculate HMAC with a HashAlgorithm
for a key
and lazy message
Example:
untag (hmacLazy (fromString "secretkey") (fromString "secret message") :: Tagged SHA256 B.ByteString)
hmacLazy' :: HashAlgorithm a => a -> ByteString -> ByteString -> ByteString Source #
Untagged variant of hmacLazy
; takes a (possible undefined
) typed HashAlgorithm
context as parameter.
Example:
hmacLazy' (undefined :: SHA256) (fromString "secretkey") (fromString "secret message")