{-# LANGUAGE ExistentialQuantification, MultiParamTypeClasses #-}
module Crypto.Nettle.Hash.Types
( HashAlgorithm(..)
, hash
, hash'
, hashLazy
, hashLazy'
, KeyedHashAlgorithm(..)
, KeyedHash(..)
, keyedHashDigestSize
, keyedHashDigestSize'
, keyedHashName
, keyedHashName'
, keyedHashInit
, keyedHashInit'
, keyedHashUpdate
, keyedHashUpdateLazy
, keyedHashFinalize
, keyedHash
, keyedHash'
, keyedHashLazy
, keyedHashLazy'
, module Data.Tagged
, HMAC
, hmacInit
, hmacInit'
, hmac
, hmac'
, hmacLazy
, hmacLazy'
) where
import Data.Tagged
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as L
import Control.Applicative ((<$>))
import Data.Bits (xor)
import Data.List (foldl')
class HashAlgorithm a where
hashBlockSize :: Tagged a Int
hashDigestSize :: Tagged a Int
hashName :: Tagged a String
hashInit :: a
hashUpdate :: a -> B.ByteString -> a
hashUpdateLazy :: a -> L.ByteString -> a
hashUpdateLazy a :: a
a = (a -> ByteString -> a) -> a -> [ByteString] -> a
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' a -> ByteString -> a
forall a. HashAlgorithm a => a -> ByteString -> a
hashUpdate a
a ([ByteString] -> a)
-> (ByteString -> [ByteString]) -> ByteString -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [ByteString]
L.toChunks
hashFinalize :: a -> B.ByteString
hashHMAC :: B.ByteString -> Tagged a KeyedHash
hashHMAC = ByteString -> Tagged a KeyedHash
forall a. HashAlgorithm a => ByteString -> Tagged a KeyedHash
hmacInit
hash :: HashAlgorithm a => B.ByteString -> Tagged a B.ByteString
hash :: ByteString -> Tagged a ByteString
hash msg :: ByteString
msg = a -> ByteString
forall a. HashAlgorithm a => a -> ByteString
hashFinalize (a -> ByteString) -> (a -> a) -> a -> ByteString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> ByteString -> a) -> ByteString -> a -> a
forall a b c. (a -> b -> c) -> b -> a -> c
flip a -> ByteString -> a
forall a. HashAlgorithm a => a -> ByteString -> a
hashUpdate ByteString
msg (a -> ByteString) -> Tagged a a -> Tagged a ByteString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> Tagged a a
forall a. a -> Tagged a a
tagSelf a
forall a. HashAlgorithm a => a
hashInit
hash' :: HashAlgorithm a => a -> B.ByteString -> B.ByteString
hash' :: a -> ByteString -> ByteString
hash' a :: a
a = (Tagged a ByteString -> a -> ByteString)
-> a -> Tagged a ByteString -> ByteString
forall a b c. (a -> b -> c) -> b -> a -> c
flip Tagged a ByteString -> a -> ByteString
forall a b. Tagged a b -> a -> b
witness a
a (Tagged a ByteString -> ByteString)
-> (ByteString -> Tagged a ByteString) -> ByteString -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Tagged a ByteString
forall a. HashAlgorithm a => ByteString -> Tagged a ByteString
hash
hashLazy :: HashAlgorithm a => L.ByteString -> Tagged a L.ByteString
hashLazy :: ByteString -> Tagged a ByteString
hashLazy msg :: ByteString
msg = ByteString -> ByteString
L.fromStrict (ByteString -> ByteString) -> (a -> ByteString) -> a -> ByteString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> ByteString
forall a. HashAlgorithm a => a -> ByteString
hashFinalize (a -> ByteString) -> (a -> a) -> a -> ByteString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> ByteString -> a) -> ByteString -> a -> a
forall a b c. (a -> b -> c) -> b -> a -> c
flip a -> ByteString -> a
forall a. HashAlgorithm a => a -> ByteString -> a
hashUpdateLazy ByteString
msg (a -> ByteString) -> Tagged a a -> Tagged a ByteString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> Tagged a a
forall a. a -> Tagged a a
tagSelf a
forall a. HashAlgorithm a => a
hashInit
hashLazy' :: HashAlgorithm a => a -> L.ByteString -> L.ByteString
hashLazy' :: a -> ByteString -> ByteString
hashLazy' a :: a
a = (Tagged a ByteString -> a -> ByteString)
-> a -> Tagged a ByteString -> ByteString
forall a b c. (a -> b -> c) -> b -> a -> c
flip Tagged a ByteString -> a -> ByteString
forall a b. Tagged a b -> a -> b
witness a
a (Tagged a ByteString -> ByteString)
-> (ByteString -> Tagged a ByteString) -> ByteString -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Tagged a ByteString
forall a. HashAlgorithm a => ByteString -> Tagged a ByteString
hashLazy
class KeyedHashAlgorithm k where
implKeyedHashDigestSize :: Tagged k Int
implKeyedHashName :: Tagged k String
implKeyedHashInit :: B.ByteString -> k
implKeyedHashUpdate :: k -> B.ByteString -> k
implKeyedHashUpdateLazy :: k -> L.ByteString -> k
implKeyedHashUpdateLazy k :: k
k = (k -> ByteString -> k) -> k -> [ByteString] -> k
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' k -> ByteString -> k
forall k. KeyedHashAlgorithm k => k -> ByteString -> k
implKeyedHashUpdate k
k ([ByteString] -> k)
-> (ByteString -> [ByteString]) -> ByteString -> k
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [ByteString]
L.toChunks
implKeyedHashFinalize :: k -> B.ByteString
data KeyedHash = forall k. KeyedHashAlgorithm k => KeyedHash !k
keyedHashDigestSize :: KeyedHashAlgorithm k => k -> Int
keyedHashDigestSize :: k -> Int
keyedHashDigestSize k :: k
k = Tagged k Int
forall k. KeyedHashAlgorithm k => Tagged k Int
implKeyedHashDigestSize Tagged k Int -> k -> Int
forall a b. Tagged a b -> a -> b
`witness` k
k
keyedHashDigestSize' :: KeyedHash -> Int
keyedHashDigestSize' :: KeyedHash -> Int
keyedHashDigestSize' (KeyedHash k :: k
k) = Tagged k Int
forall k. KeyedHashAlgorithm k => Tagged k Int
implKeyedHashDigestSize Tagged k Int -> k -> Int
forall a b. Tagged a b -> a -> b
`witness` k
k
keyedHashName :: KeyedHashAlgorithm k => k -> String
keyedHashName :: k -> String
keyedHashName k :: k
k = Tagged k String
forall k. KeyedHashAlgorithm k => Tagged k String
implKeyedHashName Tagged k String -> k -> String
forall a b. Tagged a b -> a -> b
`witness` k
k
keyedHashName' :: KeyedHash -> String
keyedHashName' :: KeyedHash -> String
keyedHashName' (KeyedHash k :: k
k) = Tagged k String
forall k. KeyedHashAlgorithm k => Tagged k String
implKeyedHashName Tagged k String -> k -> String
forall a b. Tagged a b -> a -> b
`witness` k
k
keyedHashInit :: KeyedHashAlgorithm k => B.ByteString -> Tagged k KeyedHash
keyedHashInit :: ByteString -> Tagged k KeyedHash
keyedHashInit key :: ByteString
key = k -> KeyedHash
forall k. KeyedHashAlgorithm k => k -> KeyedHash
KeyedHash (k -> KeyedHash) -> Tagged k k -> Tagged k KeyedHash
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> k -> Tagged k k
forall a. a -> Tagged a a
tagSelf (ByteString -> k
forall k. KeyedHashAlgorithm k => ByteString -> k
implKeyedHashInit ByteString
key)
keyedHashInit' :: KeyedHashAlgorithm k => k -> B.ByteString -> KeyedHash
keyedHashInit' :: k -> ByteString -> KeyedHash
keyedHashInit' k :: k
k key :: ByteString
key = ByteString -> Tagged k KeyedHash
forall k. KeyedHashAlgorithm k => ByteString -> Tagged k KeyedHash
keyedHashInit ByteString
key Tagged k KeyedHash -> k -> KeyedHash
forall a b. Tagged a b -> a -> b
`witness` k
k
keyedHashUpdate :: KeyedHash -> B.ByteString -> KeyedHash
keyedHashUpdate :: KeyedHash -> ByteString -> KeyedHash
keyedHashUpdate (KeyedHash k :: k
k) = k -> KeyedHash
forall k. KeyedHashAlgorithm k => k -> KeyedHash
KeyedHash (k -> KeyedHash) -> (ByteString -> k) -> ByteString -> KeyedHash
forall b c a. (b -> c) -> (a -> b) -> a -> c
. k -> ByteString -> k
forall k. KeyedHashAlgorithm k => k -> ByteString -> k
implKeyedHashUpdate k
k
keyedHashUpdateLazy :: KeyedHash -> L.ByteString -> KeyedHash
keyedHashUpdateLazy :: KeyedHash -> ByteString -> KeyedHash
keyedHashUpdateLazy (KeyedHash k :: k
k) = k -> KeyedHash
forall k. KeyedHashAlgorithm k => k -> KeyedHash
KeyedHash (k -> KeyedHash) -> (ByteString -> k) -> ByteString -> KeyedHash
forall b c a. (b -> c) -> (a -> b) -> a -> c
. k -> ByteString -> k
forall k. KeyedHashAlgorithm k => k -> ByteString -> k
implKeyedHashUpdateLazy k
k
keyedHashFinalize :: KeyedHash -> B.ByteString
keyedHashFinalize :: KeyedHash -> ByteString
keyedHashFinalize (KeyedHash k :: k
k) = k -> ByteString
forall k. KeyedHashAlgorithm k => k -> ByteString
implKeyedHashFinalize k
k
keyedHash :: KeyedHashAlgorithm k => B.ByteString -> B.ByteString -> Tagged k B.ByteString
keyedHash :: ByteString -> ByteString -> Tagged k ByteString
keyedHash key :: ByteString
key msg :: ByteString
msg = KeyedHash -> ByteString
keyedHashFinalize (KeyedHash -> ByteString)
-> (KeyedHash -> KeyedHash) -> KeyedHash -> ByteString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (KeyedHash -> ByteString -> KeyedHash)
-> ByteString -> KeyedHash -> KeyedHash
forall a b c. (a -> b -> c) -> b -> a -> c
flip KeyedHash -> ByteString -> KeyedHash
keyedHashUpdate ByteString
msg (KeyedHash -> ByteString)
-> Tagged k KeyedHash -> Tagged k ByteString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Tagged k KeyedHash
forall k. KeyedHashAlgorithm k => ByteString -> Tagged k KeyedHash
keyedHashInit ByteString
key
keyedHash' :: KeyedHashAlgorithm k => k -> B.ByteString -> B.ByteString -> B.ByteString
keyedHash' :: k -> ByteString -> ByteString -> ByteString
keyedHash' k :: k
k key :: ByteString
key msg :: ByteString
msg = ByteString -> ByteString -> Tagged k ByteString
forall k.
KeyedHashAlgorithm k =>
ByteString -> ByteString -> Tagged k ByteString
keyedHash ByteString
key ByteString
msg Tagged k ByteString -> k -> ByteString
forall a b. Tagged a b -> a -> b
`witness` k
k
keyedHashLazy :: KeyedHashAlgorithm k => B.ByteString -> L.ByteString -> Tagged k B.ByteString
keyedHashLazy :: ByteString -> ByteString -> Tagged k ByteString
keyedHashLazy key :: ByteString
key msg :: ByteString
msg = KeyedHash -> ByteString
keyedHashFinalize (KeyedHash -> ByteString)
-> (KeyedHash -> KeyedHash) -> KeyedHash -> ByteString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (KeyedHash -> ByteString -> KeyedHash)
-> ByteString -> KeyedHash -> KeyedHash
forall a b c. (a -> b -> c) -> b -> a -> c
flip KeyedHash -> ByteString -> KeyedHash
keyedHashUpdateLazy ByteString
msg (KeyedHash -> ByteString)
-> Tagged k KeyedHash -> Tagged k ByteString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Tagged k KeyedHash
forall k. KeyedHashAlgorithm k => ByteString -> Tagged k KeyedHash
keyedHashInit ByteString
key
keyedHashLazy' :: KeyedHashAlgorithm k => k -> B.ByteString -> L.ByteString -> B.ByteString
keyedHashLazy' :: k -> ByteString -> ByteString -> ByteString
keyedHashLazy' k :: k
k key :: ByteString
key msg :: ByteString
msg = ByteString -> ByteString -> Tagged k ByteString
forall k.
KeyedHashAlgorithm k =>
ByteString -> ByteString -> Tagged k ByteString
keyedHashLazy ByteString
key ByteString
msg Tagged k ByteString -> k -> ByteString
forall a b. Tagged a b -> a -> b
`witness` k
k
data HMAC a = HMAC !a !a
padZero :: Int -> B.ByteString -> B.ByteString
padZero :: Int -> ByteString -> ByteString
padZero len :: Int
len s :: ByteString
s = if Int
len Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> ByteString -> Int
B.length ByteString
s then ByteString -> ByteString -> ByteString
B.append ByteString
s (ByteString -> ByteString) -> ByteString -> ByteString
forall a b. (a -> b) -> a -> b
$ Int -> Word8 -> ByteString
B.replicate (Int
len Int -> Int -> Int
forall a. Num a => a -> a -> a
- ByteString -> Int
B.length ByteString
s) 0 else ByteString
s
instance HashAlgorithm a => KeyedHashAlgorithm (HMAC a) where
implKeyedHashDigestSize :: Tagged (HMAC a) Int
implKeyedHashDigestSize = Tagged a Int -> Tagged (HMAC a) Int
forall a x. HashAlgorithm a => Tagged a x -> Tagged (HMAC a) x
rt Tagged a Int
forall a. HashAlgorithm a => Tagged a Int
hashDigestSize where
rt :: HashAlgorithm a => Tagged a x -> Tagged (HMAC a) x
rt :: Tagged a x -> Tagged (HMAC a) x
rt = Tagged a x -> Tagged (HMAC a) x
forall k1 k2 (s :: k1) b (t :: k2). Tagged s b -> Tagged t b
retag
implKeyedHashName :: Tagged (HMAC a) String
implKeyedHashName = Tagged a String -> Tagged (HMAC a) String
forall a x. HashAlgorithm a => Tagged a x -> Tagged (HMAC a) x
rt (Tagged a String -> Tagged (HMAC a) String)
-> Tagged a String -> Tagged (HMAC a) String
forall a b. (a -> b) -> a -> b
$ ("HMAC-" String -> String -> String
forall a. [a] -> [a] -> [a]
++) (String -> String) -> Tagged a String -> Tagged a String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Tagged a String
forall a. HashAlgorithm a => Tagged a String
hashName where
rt :: HashAlgorithm a => Tagged a x -> Tagged (HMAC a) x
rt :: Tagged a x -> Tagged (HMAC a) x
rt = Tagged a x -> Tagged (HMAC a) x
forall k1 k2 (s :: k1) b (t :: k2). Tagged s b -> Tagged t b
retag
implKeyedHashInit :: ByteString -> HMAC a
implKeyedHashInit key :: ByteString
key = Tagged a (HMAC a) -> HMAC a
forall k (s :: k) b. Tagged s b -> b
untag (Tagged a (HMAC a) -> HMAC a) -> Tagged a (HMAC a) -> HMAC a
forall a b. (a -> b) -> a -> b
$ a -> Tagged a a
forall a. a -> Tagged a a
tagSelf a
forall a. HashAlgorithm a => a
hashInit Tagged a a -> (a -> Tagged a (HMAC a)) -> Tagged a (HMAC a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \i :: a
i -> do
Int
blockSize <- Tagged a Int
forall a. HashAlgorithm a => Tagged a Int
hashBlockSize
let key' :: ByteString
key' = Int -> ByteString -> ByteString
padZero Int
blockSize (ByteString -> ByteString) -> ByteString -> ByteString
forall a b. (a -> b) -> a -> b
$ if ByteString -> Int
B.length ByteString
key Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
blockSize then a -> ByteString -> ByteString
forall a. HashAlgorithm a => a -> ByteString -> ByteString
hash' a
i ByteString
key else ByteString
key
let o_key :: ByteString
o_key = (Word8 -> Word8) -> ByteString -> ByteString
B.map (Word8 -> Word8 -> Word8
forall a. Bits a => a -> a -> a
xor 0x5c) ByteString
key'
let i_key :: ByteString
i_key = (Word8 -> Word8) -> ByteString -> ByteString
B.map (Word8 -> Word8 -> Word8
forall a. Bits a => a -> a -> a
xor 0x36) ByteString
key'
HMAC a -> Tagged a (HMAC a)
forall (m :: * -> *) a. Monad m => a -> m a
return (HMAC a -> Tagged a (HMAC a)) -> HMAC a -> Tagged a (HMAC a)
forall a b. (a -> b) -> a -> b
$ a -> a -> HMAC a
forall a. a -> a -> HMAC a
HMAC (a -> ByteString -> a
forall a. HashAlgorithm a => a -> ByteString -> a
hashUpdate a
i ByteString
o_key) (a -> ByteString -> a
forall a. HashAlgorithm a => a -> ByteString -> a
hashUpdate a
i ByteString
i_key)
implKeyedHashUpdate :: HMAC a -> ByteString -> HMAC a
implKeyedHashUpdate (HMAC o :: a
o i :: a
i) = a -> a -> HMAC a
forall a. a -> a -> HMAC a
HMAC a
o (a -> HMAC a) -> (ByteString -> a) -> ByteString -> HMAC a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> ByteString -> a
forall a. HashAlgorithm a => a -> ByteString -> a
hashUpdate a
i
implKeyedHashUpdateLazy :: HMAC a -> ByteString -> HMAC a
implKeyedHashUpdateLazy (HMAC o :: a
o i :: a
i) = a -> a -> HMAC a
forall a. a -> a -> HMAC a
HMAC a
o (a -> HMAC a) -> (ByteString -> a) -> ByteString -> HMAC a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> ByteString -> a
forall a. HashAlgorithm a => a -> ByteString -> a
hashUpdateLazy a
i
implKeyedHashFinalize :: HMAC a -> ByteString
implKeyedHashFinalize (HMAC o :: a
o i :: a
i) = a -> ByteString
forall a. HashAlgorithm a => a -> ByteString
hashFinalize (a -> ByteString) -> a -> ByteString
forall a b. (a -> b) -> a -> b
$ a -> ByteString -> a
forall a. HashAlgorithm a => a -> ByteString -> a
hashUpdate a
o (ByteString -> a) -> ByteString -> a
forall a b. (a -> b) -> a -> b
$ a -> ByteString
forall a. HashAlgorithm a => a -> ByteString
hashFinalize a
i
hmacInit :: HashAlgorithm a => B.ByteString -> Tagged a KeyedHash
hmacInit :: ByteString -> Tagged a KeyedHash
hmacInit = Tagged (HMAC a) KeyedHash -> Tagged a KeyedHash
forall a x. Tagged (HMAC a) x -> Tagged a x
rt (Tagged (HMAC a) KeyedHash -> Tagged a KeyedHash)
-> (ByteString -> Tagged (HMAC a) KeyedHash)
-> ByteString
-> Tagged a KeyedHash
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Tagged (HMAC a) KeyedHash
forall k. KeyedHashAlgorithm k => ByteString -> Tagged k KeyedHash
keyedHashInit where
rt :: Tagged (HMAC a) x -> Tagged a x
rt :: Tagged (HMAC a) x -> Tagged a x
rt = Tagged (HMAC a) x -> Tagged a x
forall k1 k2 (s :: k1) b (t :: k2). Tagged s b -> Tagged t b
retag
hmacInit' :: HashAlgorithm a => a -> B.ByteString -> KeyedHash
hmacInit' :: a -> ByteString -> KeyedHash
hmacInit' a :: a
a key :: ByteString
key = ByteString -> Tagged a KeyedHash
forall a. HashAlgorithm a => ByteString -> Tagged a KeyedHash
hmacInit ByteString
key Tagged a KeyedHash -> a -> KeyedHash
forall a b. Tagged a b -> a -> b
`witness` a
a
hmac :: HashAlgorithm a => B.ByteString -> B.ByteString -> Tagged a B.ByteString
hmac :: ByteString -> ByteString -> Tagged a ByteString
hmac key :: ByteString
key = Tagged (HMAC a) ByteString -> Tagged a ByteString
forall a x. Tagged (HMAC a) x -> Tagged a x
rt (Tagged (HMAC a) ByteString -> Tagged a ByteString)
-> (ByteString -> Tagged (HMAC a) ByteString)
-> ByteString
-> Tagged a ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString -> Tagged (HMAC a) ByteString
forall k.
KeyedHashAlgorithm k =>
ByteString -> ByteString -> Tagged k ByteString
keyedHash ByteString
key where
rt :: Tagged (HMAC a) x -> Tagged a x
rt :: Tagged (HMAC a) x -> Tagged a x
rt = Tagged (HMAC a) x -> Tagged a x
forall k1 k2 (s :: k1) b (t :: k2). Tagged s b -> Tagged t b
retag
hmac' :: HashAlgorithm a => a -> B.ByteString -> B.ByteString -> B.ByteString
hmac' :: a -> ByteString -> ByteString -> ByteString
hmac' a :: a
a key :: ByteString
key msg :: ByteString
msg = ByteString -> ByteString -> Tagged a ByteString
forall a.
HashAlgorithm a =>
ByteString -> ByteString -> Tagged a ByteString
hmac ByteString
key ByteString
msg Tagged a ByteString -> a -> ByteString
forall a b. Tagged a b -> a -> b
`witness` a
a
hmacLazy :: HashAlgorithm a => B.ByteString -> L.ByteString -> Tagged a B.ByteString
hmacLazy :: ByteString -> ByteString -> Tagged a ByteString
hmacLazy key :: ByteString
key = Tagged (HMAC a) ByteString -> Tagged a ByteString
forall a x. Tagged (HMAC a) x -> Tagged a x
rt (Tagged (HMAC a) ByteString -> Tagged a ByteString)
-> (ByteString -> Tagged (HMAC a) ByteString)
-> ByteString
-> Tagged a ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString -> Tagged (HMAC a) ByteString
forall k.
KeyedHashAlgorithm k =>
ByteString -> ByteString -> Tagged k ByteString
keyedHashLazy ByteString
key where
rt :: Tagged (HMAC a) x -> Tagged a x
rt :: Tagged (HMAC a) x -> Tagged a x
rt = Tagged (HMAC a) x -> Tagged a x
forall k1 k2 (s :: k1) b (t :: k2). Tagged s b -> Tagged t b
retag
hmacLazy' :: HashAlgorithm a => a -> B.ByteString -> L.ByteString -> B.ByteString
hmacLazy' :: a -> ByteString -> ByteString -> ByteString
hmacLazy' a :: a
a key :: ByteString
key msg :: ByteString
msg = ByteString -> ByteString -> Tagged a ByteString
forall a.
HashAlgorithm a =>
ByteString -> ByteString -> Tagged a ByteString
hmacLazy ByteString
key ByteString
msg Tagged a ByteString -> a -> ByteString
forall a b. Tagged a b -> a -> b
`witness` a
a