Merge pull request #182 from haskell-crypto/hash-type-nat

Add HashBlockSize & HashDigestSize & HashInternalContextSize type family
This commit is contained in:
Vincent Hanquez 2017-07-07 21:45:22 +01:00 committed by GitHub
commit ccc3930072
26 changed files with 272 additions and 8 deletions

View File

@ -63,6 +63,9 @@ data Blake2s (bitlen :: Nat) = Blake2s
instance (IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 256) instance (IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 256)
=> HashAlgorithm (Blake2s bitlen) => HashAlgorithm (Blake2s bitlen)
where where
type HashBlockSize (Blake2s bitlen) = 64
type HashDigestSize (Blake2s bitlen) = bitlen
type HashInternalContextSize (Blake2s bitlen) = 185
hashBlockSize _ = 64 hashBlockSize _ = 64
hashDigestSize _ = byteLen (Proxy :: Proxy bitlen) hashDigestSize _ = byteLen (Proxy :: Proxy bitlen)
hashInternalContextSize _ = 185 hashInternalContextSize _ = 185
@ -95,6 +98,9 @@ data Blake2b (bitlen :: Nat) = Blake2b
instance (IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 512) instance (IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 512)
=> HashAlgorithm (Blake2b bitlen) => HashAlgorithm (Blake2b bitlen)
where where
type HashBlockSize (Blake2b bitlen) = 128
type HashDigestSize (Blake2b bitlen) = bitlen
type HashInternalContextSize (Blake2b bitlen) = 361
hashBlockSize _ = 128 hashBlockSize _ = 128
hashDigestSize _ = byteLen (Proxy :: Proxy bitlen) hashDigestSize _ = byteLen (Proxy :: Proxy bitlen)
hashInternalContextSize _ = 361 hashInternalContextSize _ = 361
@ -115,6 +121,9 @@ data Blake2sp (bitlen :: Nat) = Blake2sp
instance (IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 256) instance (IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 256)
=> HashAlgorithm (Blake2sp bitlen) => HashAlgorithm (Blake2sp bitlen)
where where
type HashBlockSize (Blake2sp bitlen) = 64
type HashDigestSize (Blake2sp bitlen) = bitlen
type HashInternalContextSize (Blake2sp bitlen) = 2185
hashBlockSize _ = 64 hashBlockSize _ = 64
hashDigestSize _ = byteLen (Proxy :: Proxy bitlen) hashDigestSize _ = byteLen (Proxy :: Proxy bitlen)
hashInternalContextSize _ = 2185 hashInternalContextSize _ = 2185
@ -135,6 +144,9 @@ data Blake2bp (bitlen :: Nat) = Blake2bp
instance (IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 512) instance (IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 512)
=> HashAlgorithm (Blake2bp bitlen) => HashAlgorithm (Blake2bp bitlen)
where where
type HashBlockSize (Blake2bp bitlen) = 128
type HashDigestSize (Blake2bp bitlen) = bitlen
type HashInternalContextSize (Blake2bp bitlen) = 2325
hashBlockSize _ = 128 hashBlockSize _ = 128
hashDigestSize _ = byteLen (Proxy :: Proxy bitlen) hashDigestSize _ = byteLen (Proxy :: Proxy bitlen)
hashInternalContextSize _ = 2325 hashInternalContextSize _ = 2325

View File

@ -10,6 +10,8 @@
-- --
{-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Crypto.Hash.Blake2b module Crypto.Hash.Blake2b
( Blake2b_160 (..), Blake2b_224 (..), Blake2b_256 (..), Blake2b_384 (..), Blake2b_512 (..) ( Blake2b_160 (..), Blake2b_224 (..), Blake2b_256 (..), Blake2b_384 (..), Blake2b_512 (..)
) where ) where
@ -26,6 +28,9 @@ data Blake2b_160 = Blake2b_160
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm Blake2b_160 where instance HashAlgorithm Blake2b_160 where
type HashBlockSize Blake2b_160 = 128
type HashDigestSize Blake2b_160 = 20
type HashInternalContextSize Blake2b_160 = 361
hashBlockSize _ = 128 hashBlockSize _ = 128
hashDigestSize _ = 20 hashDigestSize _ = 20
hashInternalContextSize _ = 361 hashInternalContextSize _ = 361
@ -38,6 +43,9 @@ data Blake2b_224 = Blake2b_224
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm Blake2b_224 where instance HashAlgorithm Blake2b_224 where
type HashBlockSize Blake2b_224 = 128
type HashDigestSize Blake2b_224 = 28
type HashInternalContextSize Blake2b_224 = 361
hashBlockSize _ = 128 hashBlockSize _ = 128
hashDigestSize _ = 28 hashDigestSize _ = 28
hashInternalContextSize _ = 361 hashInternalContextSize _ = 361
@ -50,6 +58,9 @@ data Blake2b_256 = Blake2b_256
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm Blake2b_256 where instance HashAlgorithm Blake2b_256 where
type HashBlockSize Blake2b_256 = 128
type HashDigestSize Blake2b_256 = 32
type HashInternalContextSize Blake2b_256 = 361
hashBlockSize _ = 128 hashBlockSize _ = 128
hashDigestSize _ = 32 hashDigestSize _ = 32
hashInternalContextSize _ = 361 hashInternalContextSize _ = 361
@ -62,6 +73,9 @@ data Blake2b_384 = Blake2b_384
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm Blake2b_384 where instance HashAlgorithm Blake2b_384 where
type HashBlockSize Blake2b_384 = 128
type HashDigestSize Blake2b_384 = 48
type HashInternalContextSize Blake2b_384 = 361
hashBlockSize _ = 128 hashBlockSize _ = 128
hashDigestSize _ = 48 hashDigestSize _ = 48
hashInternalContextSize _ = 361 hashInternalContextSize _ = 361
@ -74,6 +88,9 @@ data Blake2b_512 = Blake2b_512
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm Blake2b_512 where instance HashAlgorithm Blake2b_512 where
type HashBlockSize Blake2b_512 = 128
type HashDigestSize Blake2b_512 = 64
type HashInternalContextSize Blake2b_512 = 361
hashBlockSize _ = 128 hashBlockSize _ = 128
hashDigestSize _ = 64 hashDigestSize _ = 64
hashInternalContextSize _ = 361 hashInternalContextSize _ = 361

View File

@ -10,6 +10,8 @@
-- --
{-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Crypto.Hash.Blake2bp module Crypto.Hash.Blake2bp
( Blake2bp_512 (..) ( Blake2bp_512 (..)
) where ) where
@ -26,6 +28,9 @@ data Blake2bp_512 = Blake2bp_512
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm Blake2bp_512 where instance HashAlgorithm Blake2bp_512 where
type HashBlockSize Blake2bp_512 = 128
type HashDigestSize Blake2bp_512 = 64
type HashInternalContextSize Blake2bp_512 = 2325
hashBlockSize _ = 128 hashBlockSize _ = 128
hashDigestSize _ = 64 hashDigestSize _ = 64
hashInternalContextSize _ = 2325 hashInternalContextSize _ = 2325

View File

@ -10,6 +10,8 @@
-- --
{-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Crypto.Hash.Blake2s module Crypto.Hash.Blake2s
( Blake2s_160 (..), Blake2s_224 (..), Blake2s_256 (..) ( Blake2s_160 (..), Blake2s_224 (..), Blake2s_256 (..)
) where ) where
@ -26,6 +28,9 @@ data Blake2s_160 = Blake2s_160
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm Blake2s_160 where instance HashAlgorithm Blake2s_160 where
type HashBlockSize Blake2s_160 = 64
type HashDigestSize Blake2s_160 = 20
type HashInternalContextSize Blake2s_160 = 185
hashBlockSize _ = 64 hashBlockSize _ = 64
hashDigestSize _ = 20 hashDigestSize _ = 20
hashInternalContextSize _ = 185 hashInternalContextSize _ = 185
@ -38,6 +43,9 @@ data Blake2s_224 = Blake2s_224
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm Blake2s_224 where instance HashAlgorithm Blake2s_224 where
type HashBlockSize Blake2s_224 = 64
type HashDigestSize Blake2s_224 = 28
type HashInternalContextSize Blake2s_224 = 185
hashBlockSize _ = 64 hashBlockSize _ = 64
hashDigestSize _ = 28 hashDigestSize _ = 28
hashInternalContextSize _ = 185 hashInternalContextSize _ = 185
@ -50,6 +58,9 @@ data Blake2s_256 = Blake2s_256
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm Blake2s_256 where instance HashAlgorithm Blake2s_256 where
type HashBlockSize Blake2s_256 = 64
type HashDigestSize Blake2s_256 = 32
type HashInternalContextSize Blake2s_256 = 185
hashBlockSize _ = 64 hashBlockSize _ = 64
hashDigestSize _ = 32 hashDigestSize _ = 32
hashInternalContextSize _ = 185 hashInternalContextSize _ = 185

View File

@ -10,6 +10,8 @@
-- --
{-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Crypto.Hash.Blake2sp module Crypto.Hash.Blake2sp
( Blake2sp_224 (..), Blake2sp_256 (..) ( Blake2sp_224 (..), Blake2sp_256 (..)
) where ) where
@ -26,6 +28,9 @@ data Blake2sp_224 = Blake2sp_224
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm Blake2sp_224 where instance HashAlgorithm Blake2sp_224 where
type HashBlockSize Blake2sp_224 = 64
type HashDigestSize Blake2sp_224 = 28
type HashInternalContextSize Blake2sp_224 = 2185
hashBlockSize _ = 64 hashBlockSize _ = 64
hashDigestSize _ = 28 hashDigestSize _ = 28
hashInternalContextSize _ = 2185 hashInternalContextSize _ = 2185
@ -38,6 +43,9 @@ data Blake2sp_256 = Blake2sp_256
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm Blake2sp_256 where instance HashAlgorithm Blake2sp_256 where
type HashBlockSize Blake2sp_256 = 64
type HashDigestSize Blake2sp_256 = 32
type HashInternalContextSize Blake2sp_256 = 2185
hashBlockSize _ = 64 hashBlockSize _ = 64
hashDigestSize _ = 32 hashDigestSize _ = 32
hashInternalContextSize _ = 2185 hashInternalContextSize _ = 2185

View File

@ -10,6 +10,8 @@
-- --
{-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Crypto.Hash.Keccak module Crypto.Hash.Keccak
( Keccak_224 (..), Keccak_256 (..), Keccak_384 (..), Keccak_512 (..) ( Keccak_224 (..), Keccak_256 (..), Keccak_384 (..), Keccak_512 (..)
) where ) where
@ -26,6 +28,9 @@ data Keccak_224 = Keccak_224
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm Keccak_224 where instance HashAlgorithm Keccak_224 where
type HashBlockSize Keccak_224 = 144
type HashDigestSize Keccak_224 = 28
type HashInternalContextSize Keccak_224 = 352
hashBlockSize _ = 144 hashBlockSize _ = 144
hashDigestSize _ = 28 hashDigestSize _ = 28
hashInternalContextSize _ = 352 hashInternalContextSize _ = 352
@ -38,6 +43,9 @@ data Keccak_256 = Keccak_256
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm Keccak_256 where instance HashAlgorithm Keccak_256 where
type HashBlockSize Keccak_256 = 136
type HashDigestSize Keccak_256 = 32
type HashInternalContextSize Keccak_256 = 344
hashBlockSize _ = 136 hashBlockSize _ = 136
hashDigestSize _ = 32 hashDigestSize _ = 32
hashInternalContextSize _ = 344 hashInternalContextSize _ = 344
@ -50,6 +58,9 @@ data Keccak_384 = Keccak_384
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm Keccak_384 where instance HashAlgorithm Keccak_384 where
type HashBlockSize Keccak_384 = 104
type HashDigestSize Keccak_384 = 48
type HashInternalContextSize Keccak_384 = 312
hashBlockSize _ = 104 hashBlockSize _ = 104
hashDigestSize _ = 48 hashDigestSize _ = 48
hashInternalContextSize _ = 312 hashInternalContextSize _ = 312
@ -62,6 +73,9 @@ data Keccak_512 = Keccak_512
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm Keccak_512 where instance HashAlgorithm Keccak_512 where
type HashBlockSize Keccak_512 = 72
type HashDigestSize Keccak_512 = 64
type HashInternalContextSize Keccak_512 = 280
hashBlockSize _ = 72 hashBlockSize _ = 72
hashDigestSize _ = 64 hashDigestSize _ = 64
hashInternalContextSize _ = 280 hashInternalContextSize _ = 280

View File

@ -10,6 +10,8 @@
-- --
{-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Crypto.Hash.MD2 ( MD2 (..) ) where module Crypto.Hash.MD2 ( MD2 (..) ) where
import Crypto.Hash.Types import Crypto.Hash.Types
@ -23,6 +25,9 @@ data MD2 = MD2
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm MD2 where instance HashAlgorithm MD2 where
type HashBlockSize MD2 = 16
type HashDigestSize MD2 = 16
type HashInternalContextSize MD2 = 96
hashBlockSize _ = 16 hashBlockSize _ = 16
hashDigestSize _ = 16 hashDigestSize _ = 16
hashInternalContextSize _ = 96 hashInternalContextSize _ = 96

View File

@ -10,6 +10,8 @@
-- --
{-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Crypto.Hash.MD4 ( MD4 (..) ) where module Crypto.Hash.MD4 ( MD4 (..) ) where
import Crypto.Hash.Types import Crypto.Hash.Types
@ -23,6 +25,9 @@ data MD4 = MD4
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm MD4 where instance HashAlgorithm MD4 where
type HashBlockSize MD4 = 64
type HashDigestSize MD4 = 16
type HashInternalContextSize MD4 = 96
hashBlockSize _ = 64 hashBlockSize _ = 64
hashDigestSize _ = 16 hashDigestSize _ = 16
hashInternalContextSize _ = 96 hashInternalContextSize _ = 96

View File

@ -10,6 +10,8 @@
-- --
{-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Crypto.Hash.MD5 ( MD5 (..) ) where module Crypto.Hash.MD5 ( MD5 (..) ) where
import Crypto.Hash.Types import Crypto.Hash.Types
@ -23,6 +25,9 @@ data MD5 = MD5
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm MD5 where instance HashAlgorithm MD5 where
type HashBlockSize MD5 = 64
type HashDigestSize MD5 = 16
type HashInternalContextSize MD5 = 96
hashBlockSize _ = 64 hashBlockSize _ = 64
hashDigestSize _ = 16 hashDigestSize _ = 16
hashInternalContextSize _ = 96 hashInternalContextSize _ = 96

View File

@ -10,6 +10,8 @@
-- --
{-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Crypto.Hash.RIPEMD160 ( RIPEMD160 (..) ) where module Crypto.Hash.RIPEMD160 ( RIPEMD160 (..) ) where
import Crypto.Hash.Types import Crypto.Hash.Types
@ -23,6 +25,9 @@ data RIPEMD160 = RIPEMD160
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm RIPEMD160 where instance HashAlgorithm RIPEMD160 where
type HashBlockSize RIPEMD160 = 64
type HashDigestSize RIPEMD160 = 20
type HashInternalContextSize RIPEMD160 = 128
hashBlockSize _ = 64 hashBlockSize _ = 64
hashDigestSize _ = 20 hashDigestSize _ = 20
hashInternalContextSize _ = 128 hashInternalContextSize _ = 128

View File

@ -10,6 +10,8 @@
-- --
{-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Crypto.Hash.SHA1 ( SHA1 (..) ) where module Crypto.Hash.SHA1 ( SHA1 (..) ) where
import Crypto.Hash.Types import Crypto.Hash.Types
@ -23,6 +25,9 @@ data SHA1 = SHA1
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm SHA1 where instance HashAlgorithm SHA1 where
type HashBlockSize SHA1 = 64
type HashDigestSize SHA1 = 20
type HashInternalContextSize SHA1 = 96
hashBlockSize _ = 64 hashBlockSize _ = 64
hashDigestSize _ = 20 hashDigestSize _ = 20
hashInternalContextSize _ = 96 hashInternalContextSize _ = 96

View File

@ -10,6 +10,8 @@
-- --
{-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Crypto.Hash.SHA224 ( SHA224 (..) ) where module Crypto.Hash.SHA224 ( SHA224 (..) ) where
import Crypto.Hash.Types import Crypto.Hash.Types
@ -23,6 +25,9 @@ data SHA224 = SHA224
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm SHA224 where instance HashAlgorithm SHA224 where
type HashBlockSize SHA224 = 64
type HashDigestSize SHA224 = 28
type HashInternalContextSize SHA224 = 192
hashBlockSize _ = 64 hashBlockSize _ = 64
hashDigestSize _ = 28 hashDigestSize _ = 28
hashInternalContextSize _ = 192 hashInternalContextSize _ = 192

View File

@ -10,6 +10,8 @@
-- --
{-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Crypto.Hash.SHA256 ( SHA256 (..) ) where module Crypto.Hash.SHA256 ( SHA256 (..) ) where
import Crypto.Hash.Types import Crypto.Hash.Types
@ -23,6 +25,9 @@ data SHA256 = SHA256
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm SHA256 where instance HashAlgorithm SHA256 where
type HashBlockSize SHA256 = 64
type HashDigestSize SHA256 = 32
type HashInternalContextSize SHA256 = 192
hashBlockSize _ = 64 hashBlockSize _ = 64
hashDigestSize _ = 32 hashDigestSize _ = 32
hashInternalContextSize _ = 192 hashInternalContextSize _ = 192

View File

@ -10,6 +10,8 @@
-- --
{-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Crypto.Hash.SHA3 module Crypto.Hash.SHA3
( SHA3_224 (..), SHA3_256 (..), SHA3_384 (..), SHA3_512 (..) ( SHA3_224 (..), SHA3_256 (..), SHA3_384 (..), SHA3_512 (..)
) where ) where
@ -20,11 +22,15 @@ import Data.Data
import Data.Typeable import Data.Typeable
import Data.Word (Word8, Word32) import Data.Word (Word8, Word32)
-- | SHA3 (224 bits) cryptographic hash algorithm -- | SHA3 (224 bits) cryptographic hash algorithm
data SHA3_224 = SHA3_224 data SHA3_224 = SHA3_224
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm SHA3_224 where instance HashAlgorithm SHA3_224 where
type HashBlockSize SHA3_224 = 144
type HashDigestSize SHA3_224 = 28
type HashInternalContextSize SHA3_224 = 352
hashBlockSize _ = 144 hashBlockSize _ = 144
hashDigestSize _ = 28 hashDigestSize _ = 28
hashInternalContextSize _ = 352 hashInternalContextSize _ = 352
@ -37,6 +43,9 @@ data SHA3_256 = SHA3_256
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm SHA3_256 where instance HashAlgorithm SHA3_256 where
type HashBlockSize SHA3_256 = 136
type HashDigestSize SHA3_256 = 32
type HashInternalContextSize SHA3_256 = 344
hashBlockSize _ = 136 hashBlockSize _ = 136
hashDigestSize _ = 32 hashDigestSize _ = 32
hashInternalContextSize _ = 344 hashInternalContextSize _ = 344
@ -49,6 +58,9 @@ data SHA3_384 = SHA3_384
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm SHA3_384 where instance HashAlgorithm SHA3_384 where
type HashBlockSize SHA3_384 = 104
type HashDigestSize SHA3_384 = 48
type HashInternalContextSize SHA3_384 = 312
hashBlockSize _ = 104 hashBlockSize _ = 104
hashDigestSize _ = 48 hashDigestSize _ = 48
hashInternalContextSize _ = 312 hashInternalContextSize _ = 312
@ -61,6 +73,9 @@ data SHA3_512 = SHA3_512
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm SHA3_512 where instance HashAlgorithm SHA3_512 where
type HashBlockSize SHA3_512 = 72
type HashDigestSize SHA3_512 = 64
type HashInternalContextSize SHA3_512 = 280
hashBlockSize _ = 72 hashBlockSize _ = 72
hashDigestSize _ = 64 hashDigestSize _ = 64
hashInternalContextSize _ = 280 hashInternalContextSize _ = 280
@ -68,6 +83,7 @@ instance HashAlgorithm SHA3_512 where
hashInternalUpdate = c_sha3_update hashInternalUpdate = c_sha3_update
hashInternalFinalize p = c_sha3_finalize p 512 hashInternalFinalize p = c_sha3_finalize p 512
foreign import ccall unsafe "cryptonite_sha3_init" foreign import ccall unsafe "cryptonite_sha3_init"
c_sha3_init :: Ptr (Context a) -> Word32 -> IO () c_sha3_init :: Ptr (Context a) -> Word32 -> IO ()

View File

@ -10,6 +10,8 @@
-- --
{-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Crypto.Hash.SHA384 ( SHA384 (..) ) where module Crypto.Hash.SHA384 ( SHA384 (..) ) where
import Crypto.Hash.Types import Crypto.Hash.Types
@ -23,6 +25,9 @@ data SHA384 = SHA384
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm SHA384 where instance HashAlgorithm SHA384 where
type HashBlockSize SHA384 = 128
type HashDigestSize SHA384 = 48
type HashInternalContextSize SHA384 = 256
hashBlockSize _ = 128 hashBlockSize _ = 128
hashDigestSize _ = 48 hashDigestSize _ = 48
hashInternalContextSize _ = 256 hashInternalContextSize _ = 256

View File

@ -10,6 +10,8 @@
-- --
{-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Crypto.Hash.SHA512 ( SHA512 (..) ) where module Crypto.Hash.SHA512 ( SHA512 (..) ) where
import Crypto.Hash.Types import Crypto.Hash.Types
@ -23,6 +25,9 @@ data SHA512 = SHA512
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm SHA512 where instance HashAlgorithm SHA512 where
type HashBlockSize SHA512 = 128
type HashDigestSize SHA512 = 64
type HashInternalContextSize SHA512 = 256
hashBlockSize _ = 128 hashBlockSize _ = 128
hashDigestSize _ = 64 hashDigestSize _ = 64
hashInternalContextSize _ = 256 hashInternalContextSize _ = 256

View File

@ -10,6 +10,8 @@
-- --
{-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Crypto.Hash.SHA512t module Crypto.Hash.SHA512t
( SHA512t_224 (..), SHA512t_256 (..) ( SHA512t_224 (..), SHA512t_256 (..)
) where ) where
@ -26,6 +28,9 @@ data SHA512t_224 = SHA512t_224
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm SHA512t_224 where instance HashAlgorithm SHA512t_224 where
type HashBlockSize SHA512t_224 = 128
type HashDigestSize SHA512t_224 = 28
type HashInternalContextSize SHA512t_224 = 256
hashBlockSize _ = 128 hashBlockSize _ = 128
hashDigestSize _ = 28 hashDigestSize _ = 28
hashInternalContextSize _ = 256 hashInternalContextSize _ = 256
@ -38,6 +43,9 @@ data SHA512t_256 = SHA512t_256
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm SHA512t_256 where instance HashAlgorithm SHA512t_256 where
type HashBlockSize SHA512t_256 = 128
type HashDigestSize SHA512t_256 = 32
type HashInternalContextSize SHA512t_256 = 256
hashBlockSize _ = 128 hashBlockSize _ = 128
hashDigestSize _ = 32 hashDigestSize _ = 32
hashInternalContextSize _ = 256 hashInternalContextSize _ = 256

View File

@ -40,13 +40,16 @@ import Crypto.Internal.Nat
data SHAKE128 (bitlen :: Nat) = SHAKE128 data SHAKE128 (bitlen :: Nat) = SHAKE128
deriving (Show, Typeable) deriving (Show, Typeable)
instance (IsDivisibleBy8 bitLen, KnownNat bitLen) => HashAlgorithm (SHAKE128 bitLen) where instance (IsDivisibleBy8 bitlen, KnownNat bitlen) => HashAlgorithm (SHAKE128 bitlen) where
type HashBlockSize (SHAKE128 bitlen) = 168
type HashDigestSize (SHAKE128 bitlen) = Div8 bitlen
type HashInternalContextSize (SHAKE128 bitlen) = 376
hashBlockSize _ = 168 hashBlockSize _ = 168
hashDigestSize _ = byteLen (Proxy :: Proxy bitLen) hashDigestSize _ = byteLen (Proxy :: Proxy bitlen)
hashInternalContextSize _ = 376 hashInternalContextSize _ = 376
hashInternalInit p = c_sha3_init p 128 hashInternalInit p = c_sha3_init p 128
hashInternalUpdate = c_sha3_update hashInternalUpdate = c_sha3_update
hashInternalFinalize = shakeFinalizeOutput (Proxy :: Proxy bitLen) hashInternalFinalize = shakeFinalizeOutput (Proxy :: Proxy bitlen)
-- | SHAKE256 (256 bits) extendable output function. Supports an arbitrary -- | SHAKE256 (256 bits) extendable output function. Supports an arbitrary
-- digest size (multiple of 8 bits), to be specified as a type parameter -- digest size (multiple of 8 bits), to be specified as a type parameter
@ -58,16 +61,19 @@ instance (IsDivisibleBy8 bitLen, KnownNat bitLen) => HashAlgorithm (SHAKE128 bit
data SHAKE256 (bitlen :: Nat) = SHAKE256 data SHAKE256 (bitlen :: Nat) = SHAKE256
deriving (Show, Typeable) deriving (Show, Typeable)
instance (IsDivisibleBy8 bitLen, KnownNat bitLen) => HashAlgorithm (SHAKE256 bitLen) where instance (IsDivisibleBy8 bitlen, KnownNat bitlen) => HashAlgorithm (SHAKE256 bitlen) where
type HashBlockSize (SHAKE256 bitlen) = 136
type HashDigestSize (SHAKE256 bitlen) = Div8 bitlen
type HashInternalContextSize (SHAKE256 bitlen) = 344
hashBlockSize _ = 136 hashBlockSize _ = 136
hashDigestSize _ = byteLen (Proxy :: Proxy bitLen) hashDigestSize _ = byteLen (Proxy :: Proxy bitlen)
hashInternalContextSize _ = 344 hashInternalContextSize _ = 344
hashInternalInit p = c_sha3_init p 256 hashInternalInit p = c_sha3_init p 256
hashInternalUpdate = c_sha3_update hashInternalUpdate = c_sha3_update
hashInternalFinalize = shakeFinalizeOutput (Proxy :: Proxy bitLen) hashInternalFinalize = shakeFinalizeOutput (Proxy :: Proxy bitlen)
shakeFinalizeOutput :: (IsDivisibleBy8 bitLen, KnownNat bitLen) shakeFinalizeOutput :: (IsDivisibleBy8 bitlen, KnownNat bitlen)
=> proxy bitLen => proxy bitlen
-> Ptr (Context a) -> Ptr (Context a)
-> Ptr (Digest a) -> Ptr (Digest a)
-> IO () -> IO ()

View File

@ -10,6 +10,8 @@
-- --
{-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Crypto.Hash.Skein256 module Crypto.Hash.Skein256
( Skein256_224 (..), Skein256_256 (..) ( Skein256_224 (..), Skein256_256 (..)
) where ) where
@ -26,6 +28,9 @@ data Skein256_224 = Skein256_224
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm Skein256_224 where instance HashAlgorithm Skein256_224 where
type HashBlockSize Skein256_224 = 32
type HashDigestSize Skein256_224 = 28
type HashInternalContextSize Skein256_224 = 96
hashBlockSize _ = 32 hashBlockSize _ = 32
hashDigestSize _ = 28 hashDigestSize _ = 28
hashInternalContextSize _ = 96 hashInternalContextSize _ = 96
@ -38,6 +43,9 @@ data Skein256_256 = Skein256_256
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm Skein256_256 where instance HashAlgorithm Skein256_256 where
type HashBlockSize Skein256_256 = 32
type HashDigestSize Skein256_256 = 32
type HashInternalContextSize Skein256_256 = 96
hashBlockSize _ = 32 hashBlockSize _ = 32
hashDigestSize _ = 32 hashDigestSize _ = 32
hashInternalContextSize _ = 96 hashInternalContextSize _ = 96

View File

@ -10,6 +10,8 @@
-- --
{-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Crypto.Hash.Skein512 module Crypto.Hash.Skein512
( Skein512_224 (..), Skein512_256 (..), Skein512_384 (..), Skein512_512 (..) ( Skein512_224 (..), Skein512_256 (..), Skein512_384 (..), Skein512_512 (..)
) where ) where
@ -26,6 +28,9 @@ data Skein512_224 = Skein512_224
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm Skein512_224 where instance HashAlgorithm Skein512_224 where
type HashBlockSize Skein512_224 = 64
type HashDigestSize Skein512_224 = 28
type HashInternalContextSize Skein512_224 = 160
hashBlockSize _ = 64 hashBlockSize _ = 64
hashDigestSize _ = 28 hashDigestSize _ = 28
hashInternalContextSize _ = 160 hashInternalContextSize _ = 160
@ -38,6 +43,9 @@ data Skein512_256 = Skein512_256
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm Skein512_256 where instance HashAlgorithm Skein512_256 where
type HashBlockSize Skein512_256 = 64
type HashDigestSize Skein512_256 = 32
type HashInternalContextSize Skein512_256 = 160
hashBlockSize _ = 64 hashBlockSize _ = 64
hashDigestSize _ = 32 hashDigestSize _ = 32
hashInternalContextSize _ = 160 hashInternalContextSize _ = 160
@ -50,6 +58,9 @@ data Skein512_384 = Skein512_384
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm Skein512_384 where instance HashAlgorithm Skein512_384 where
type HashBlockSize Skein512_384 = 64
type HashDigestSize Skein512_384 = 48
type HashInternalContextSize Skein512_384 = 160
hashBlockSize _ = 64 hashBlockSize _ = 64
hashDigestSize _ = 48 hashDigestSize _ = 48
hashInternalContextSize _ = 160 hashInternalContextSize _ = 160
@ -62,6 +73,9 @@ data Skein512_512 = Skein512_512
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm Skein512_512 where instance HashAlgorithm Skein512_512 where
type HashBlockSize Skein512_512 = 64
type HashDigestSize Skein512_512 = 64
type HashInternalContextSize Skein512_512 = 160
hashBlockSize _ = 64 hashBlockSize _ = 64
hashDigestSize _ = 64 hashDigestSize _ = 64
hashInternalContextSize _ = 160 hashInternalContextSize _ = 160

View File

@ -10,6 +10,8 @@
-- --
{-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Crypto.Hash.Tiger ( Tiger (..) ) where module Crypto.Hash.Tiger ( Tiger (..) ) where
import Crypto.Hash.Types import Crypto.Hash.Types
@ -23,6 +25,9 @@ data Tiger = Tiger
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm Tiger where instance HashAlgorithm Tiger where
type HashBlockSize Tiger = 64
type HashDigestSize Tiger = 24
type HashInternalContextSize Tiger = 96
hashBlockSize _ = 64 hashBlockSize _ = 64
hashDigestSize _ = 24 hashDigestSize _ = 24
hashInternalContextSize _ = 96 hashInternalContextSize _ = 96

View File

@ -8,6 +8,8 @@
-- Crypto hash types definitions -- Crypto hash types definitions
-- --
{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Crypto.Hash.Types module Crypto.Hash.Types
( HashAlgorithm(..) ( HashAlgorithm(..)
, Context(..) , Context(..)
@ -20,6 +22,7 @@ import qualified Crypto.Internal.ByteArray as B
import Foreign.Ptr (Ptr) import Foreign.Ptr (Ptr)
import qualified Foundation.Array as F import qualified Foundation.Array as F
import qualified Foundation as F import qualified Foundation as F
import GHC.TypeLits (Nat)
-- | Class representing hashing algorithms. -- | Class representing hashing algorithms.
-- --
@ -27,6 +30,13 @@ import qualified Foundation as F
-- and lowlevel. the Hash module takes care of -- and lowlevel. the Hash module takes care of
-- hidding the mutable interface properly. -- hidding the mutable interface properly.
class HashAlgorithm a where class HashAlgorithm a where
-- | Associated type for the block size of the hash algorithm
type HashBlockSize a :: Nat
-- | Associated type for the digest size of the hash algorithm
type HashDigestSize a :: Nat
-- | Associated type for the internal context size of the hash algorithm
type HashInternalContextSize a :: Nat
-- | Get the block size of a hash algorithm -- | Get the block size of a hash algorithm
hashBlockSize :: a -> Int hashBlockSize :: a -> Int
-- | Get the digest size of a hash algorithm -- | Get the digest size of a hash algorithm

View File

@ -10,6 +10,8 @@
-- --
{-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Crypto.Hash.Whirlpool ( Whirlpool (..) ) where module Crypto.Hash.Whirlpool ( Whirlpool (..) ) where
import Crypto.Hash.Types import Crypto.Hash.Types
@ -23,6 +25,9 @@ data Whirlpool = Whirlpool
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm Whirlpool where instance HashAlgorithm Whirlpool where
type HashBlockSize Whirlpool = 64
type HashDigestSize Whirlpool = 64
type HashInternalContextSize Whirlpool = 168
hashBlockSize _ = 64 hashBlockSize _ = 64
hashDigestSize _ = 64 hashDigestSize _ = 64
hashInternalContextSize _ = 168 hashInternalContextSize _ = 168

View File

@ -9,6 +9,8 @@ module Crypto.Internal.Nat
, type IsAtMost, type IsAtLeast , type IsAtMost, type IsAtLeast
, byteLen , byteLen
, integralNatVal , integralNatVal
, type Div8
, type Mod8
) where ) where
import GHC.TypeLits import GHC.TypeLits
@ -49,6 +51,74 @@ type family IsGE (bitlen :: Nat) (n :: Nat) (c :: Bool) where
-- --
type IsAtLeast (bitlen :: Nat) (n :: Nat) = IsGE bitlen n (n <=? bitlen) ~ 'True type IsAtLeast (bitlen :: Nat) (n :: Nat) = IsGE bitlen n (n <=? bitlen) ~ 'True
type family Div8 (bitLen :: Nat) where
Div8 0 = 0
Div8 1 = 0
Div8 2 = 0
Div8 3 = 0
Div8 4 = 0
Div8 5 = 0
Div8 6 = 0
Div8 7 = 0
Div8 8 = 1
Div8 9 = 1
Div8 10 = 1
Div8 11 = 1
Div8 12 = 1
Div8 13 = 1
Div8 14 = 1
Div8 15 = 1
Div8 16 = 2
Div8 17 = 2
Div8 18 = 2
Div8 19 = 2
Div8 20 = 2
Div8 21 = 2
Div8 22 = 2
Div8 23 = 2
Div8 24 = 3
Div8 25 = 3
Div8 26 = 3
Div8 27 = 3
Div8 28 = 3
Div8 29 = 3
Div8 30 = 3
Div8 31 = 3
Div8 32 = 4
Div8 33 = 4
Div8 34 = 4
Div8 35 = 4
Div8 36 = 4
Div8 37 = 4
Div8 38 = 4
Div8 39 = 4
Div8 40 = 5
Div8 41 = 5
Div8 42 = 5
Div8 43 = 5
Div8 44 = 5
Div8 45 = 5
Div8 46 = 5
Div8 47 = 5
Div8 48 = 6
Div8 49 = 6
Div8 50 = 6
Div8 51 = 6
Div8 52 = 6
Div8 53 = 6
Div8 54 = 6
Div8 55 = 6
Div8 56 = 7
Div8 57 = 7
Div8 58 = 7
Div8 59 = 7
Div8 60 = 7
Div8 61 = 7
Div8 62 = 7
Div8 63 = 7
Div8 64 = 8
Div8 n = 8 + Div8 (n - 64)
type family IsDiv8 (bitLen :: Nat) (n :: Nat) where type family IsDiv8 (bitLen :: Nat) (n :: Nat) where
IsDiv8 bitLen 0 = 'True IsDiv8 bitLen 0 = 'True
#if MIN_VERSION_base(4,9,0) #if MIN_VERSION_base(4,9,0)

View File

@ -10,6 +10,8 @@
-- --
{-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Crypto.Hash.%%MODULENAME%% module Crypto.Hash.%%MODULENAME%%
( %{CUSTOMIZABLE%}%%COMMA%% %%MODULENAME%%_%%CUSTOM_BITSIZE%% (..)%{CUSTOMIZABLE%} ( %{CUSTOMIZABLE%}%%COMMA%% %%MODULENAME%%_%%CUSTOM_BITSIZE%% (..)%{CUSTOMIZABLE%}
) where ) where
@ -26,6 +28,9 @@ data %%MODULENAME%%_%%CUSTOM_BITSIZE%% = %%MODULENAME%%_%%CUSTOM_BITSIZE%%
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm %%MODULENAME%%_%%CUSTOM_BITSIZE%% where instance HashAlgorithm %%MODULENAME%%_%%CUSTOM_BITSIZE%% where
type HashBlockSize %%MODULENAME%%_%%CUSTOM_BITSIZE%% = %%CUSTOM_BLOCK_SIZE_BYTES%%
type HashDigestSize %%MODULENAME%%_%%CUSTOM_BITSIZE%% = %%CUSTOM_DIGEST_SIZE_BYTES%%
type HashInternalContextSize %%MODULENAME%%_%%CUSTOM_BITSIZE%% = %%CUSTOM_CTX_SIZE_BYTES%%
hashBlockSize _ = %%CUSTOM_BLOCK_SIZE_BYTES%% hashBlockSize _ = %%CUSTOM_BLOCK_SIZE_BYTES%%
hashDigestSize _ = %%CUSTOM_DIGEST_SIZE_BYTES%% hashDigestSize _ = %%CUSTOM_DIGEST_SIZE_BYTES%%
hashInternalContextSize _ = %%CUSTOM_CTX_SIZE_BYTES%% hashInternalContextSize _ = %%CUSTOM_CTX_SIZE_BYTES%%

View File

@ -10,6 +10,8 @@
-- --
{-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Crypto.Hash.%%MODULENAME%% ( %%MODULENAME%% (..) ) where module Crypto.Hash.%%MODULENAME%% ( %%MODULENAME%% (..) ) where
import Crypto.Hash.Types import Crypto.Hash.Types
@ -23,6 +25,9 @@ data %%MODULENAME%% = %%MODULENAME%%
deriving (Show,Data,Typeable) deriving (Show,Data,Typeable)
instance HashAlgorithm %%MODULENAME%% where instance HashAlgorithm %%MODULENAME%% where
type HashBlockSize %%MODULENAME%% = %%BLOCK_SIZE_BYTES%%
type HashDigestSize %%MODULENAME%% = %%DIGEST_SIZE_BYTES%%
type HashInternalContextSize %%MODULENAME%% = %%CTX_SIZE_BYTES%%
hashBlockSize _ = %%BLOCK_SIZE_BYTES%% hashBlockSize _ = %%BLOCK_SIZE_BYTES%%
hashDigestSize _ = %%DIGEST_SIZE_BYTES%% hashDigestSize _ = %%DIGEST_SIZE_BYTES%%
hashInternalContextSize _ = %%CTX_SIZE_BYTES%% hashInternalContextSize _ = %%CTX_SIZE_BYTES%%