{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# CFILES raaz/hash/sha1/portable.c #-}
module Raaz.Hash.Sha1.Internal (SHA1(..)) where
import Data.String
import Data.Word
import Foreign.Storable ( Storable(..) )
import Raaz.Core
import Raaz.Hash.Internal
newtype SHA1 = SHA1 (Tuple 5 (BE Word32))
deriving (Storable, EndianStore, Equality, Eq)
instance Encodable SHA1
instance IsString SHA1 where
fromString = fromBase16
instance Show SHA1 where
show = showBase16
instance Initialisable (HashMemory SHA1) () where
initialise _ = initialise $ SHA1 $ unsafeFromList [ 0x67452301
, 0xefcdab89
, 0x98badcfe
, 0x10325476
, 0xc3d2e1f0
]
instance Primitive SHA1 where
blockSize _ = BYTES 64
type Implementation SHA1 = SomeHashI SHA1
instance Hash SHA1 where
additionalPadBlocks _ = toEnum 1