{-|

This module exposes the `SHA224` hash constructor. You would hardly
need to import the module directly as you would want to treat the
`SHA224` type as an opaque type for type safety. This module is
exported only for special uses like writing a test case or defining a
binary instance etc.

-}

{-# LANGUAGE CPP                        #-}
{-# LANGUAGE TypeFamilies               #-}
{-# LANGUAGE DataKinds                  #-}
{-# LANGUAGE FlexibleInstances          #-}
{-# LANGUAGE MultiParamTypeClasses      #-}
{-# CFILES raaz/hash/sha1/portable.c    #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Raaz.Hash.Sha224.Internal
       ( SHA224(..)
       ) where

import           Data.String
import           Data.Word
import           Foreign.Storable          ( Storable )

import           Raaz.Core
import           Raaz.Hash.Internal

----------------------------- SHA224 -------------------------------------------

-- | Sha224 hash value which consist of 7 32bit words.
newtype SHA224 = SHA224 (Tuple 7 (BE Word32))
            deriving (SHA224 -> SHA224 -> Bool
(SHA224 -> SHA224 -> Bool)
-> (SHA224 -> SHA224 -> Bool) -> Eq SHA224
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SHA224 -> SHA224 -> Bool
$c/= :: SHA224 -> SHA224 -> Bool
== :: SHA224 -> SHA224 -> Bool
$c== :: SHA224 -> SHA224 -> Bool
Eq, SHA224 -> SHA224 -> Result
(SHA224 -> SHA224 -> Result) -> Equality SHA224
forall a. (a -> a -> Result) -> Equality a
eq :: SHA224 -> SHA224 -> Result
$ceq :: SHA224 -> SHA224 -> Result
Equality, Ptr b -> Int -> IO SHA224
Ptr b -> Int -> SHA224 -> IO ()
Ptr SHA224 -> IO SHA224
Ptr SHA224 -> Int -> IO SHA224
Ptr SHA224 -> Int -> SHA224 -> IO ()
Ptr SHA224 -> SHA224 -> IO ()
SHA224 -> Int
(SHA224 -> Int)
-> (SHA224 -> Int)
-> (Ptr SHA224 -> Int -> IO SHA224)
-> (Ptr SHA224 -> Int -> SHA224 -> IO ())
-> (forall b. Ptr b -> Int -> IO SHA224)
-> (forall b. Ptr b -> Int -> SHA224 -> IO ())
-> (Ptr SHA224 -> IO SHA224)
-> (Ptr SHA224 -> SHA224 -> IO ())
-> Storable SHA224
forall b. Ptr b -> Int -> IO SHA224
forall b. Ptr b -> Int -> SHA224 -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
poke :: Ptr SHA224 -> SHA224 -> IO ()
$cpoke :: Ptr SHA224 -> SHA224 -> IO ()
peek :: Ptr SHA224 -> IO SHA224
$cpeek :: Ptr SHA224 -> IO SHA224
pokeByteOff :: Ptr b -> Int -> SHA224 -> IO ()
$cpokeByteOff :: forall b. Ptr b -> Int -> SHA224 -> IO ()
peekByteOff :: Ptr b -> Int -> IO SHA224
$cpeekByteOff :: forall b. Ptr b -> Int -> IO SHA224
pokeElemOff :: Ptr SHA224 -> Int -> SHA224 -> IO ()
$cpokeElemOff :: Ptr SHA224 -> Int -> SHA224 -> IO ()
peekElemOff :: Ptr SHA224 -> Int -> IO SHA224
$cpeekElemOff :: Ptr SHA224 -> Int -> IO SHA224
alignment :: SHA224 -> Int
$calignment :: SHA224 -> Int
sizeOf :: SHA224 -> Int
$csizeOf :: SHA224 -> Int
Storable, Storable SHA224
Ptr SHA224 -> IO SHA224
Ptr SHA224 -> Int -> IO ()
Ptr SHA224 -> SHA224 -> IO ()
Storable SHA224
-> (Ptr SHA224 -> SHA224 -> IO ())
-> (Ptr SHA224 -> IO SHA224)
-> (Ptr SHA224 -> Int -> IO ())
-> EndianStore SHA224
forall w.
Storable w
-> (Ptr w -> w -> IO ())
-> (Ptr w -> IO w)
-> (Ptr w -> Int -> IO ())
-> EndianStore w
adjustEndian :: Ptr SHA224 -> Int -> IO ()
$cadjustEndian :: Ptr SHA224 -> Int -> IO ()
load :: Ptr SHA224 -> IO SHA224
$cload :: Ptr SHA224 -> IO SHA224
store :: Ptr SHA224 -> SHA224 -> IO ()
$cstore :: Ptr SHA224 -> SHA224 -> IO ()
$cp1EndianStore :: Storable SHA224
EndianStore)

instance Encodable SHA224

instance IsString SHA224 where
  fromString :: String -> SHA224
fromString = String -> SHA224
forall a. Encodable a => String -> a
fromBase16

instance Show SHA224 where
  show :: SHA224 -> String
show =  SHA224 -> String
forall a. Encodable a => a -> String
showBase16

instance Primitive SHA224 where
  blockSize :: SHA224 -> BYTES Int
blockSize SHA224
_                = Int -> BYTES Int
forall a. a -> BYTES a
BYTES Int
64
  type Implementation SHA224 = SomeHashI SHA224

instance Hash SHA224 where
  additionalPadBlocks :: SHA224 -> BLOCKS SHA224
additionalPadBlocks SHA224
_ = Int -> BLOCKS SHA224
forall a. Enum a => Int -> a
toEnum Int
1