{-# LANGUAGE CPP                        #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE DataKinds                  #-}
{-# LANGUAGE TypeFamilies               #-}
{-# LANGUAGE FlexibleInstances          #-}
{-# LANGUAGE MultiParamTypeClasses      #-}
{-# CFILES raaz/hash/sha1/portable.c    #-}

-- | Internals of Sha384.
module Raaz.Hash.Sha384.Internal
       ( SHA384(..)
       ) where

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

import           Raaz.Core
import           Raaz.Hash.Internal


----------------------------- SHA384 -------------------------------------------

-- | The Sha384 hash value.
newtype SHA384 = SHA384 (Tuple 6 (BE Word64))
                 deriving (SHA384 -> SHA384 -> Bool
(SHA384 -> SHA384 -> Bool)
-> (SHA384 -> SHA384 -> Bool) -> Eq SHA384
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SHA384 -> SHA384 -> Bool
$c/= :: SHA384 -> SHA384 -> Bool
== :: SHA384 -> SHA384 -> Bool
$c== :: SHA384 -> SHA384 -> Bool
Eq, SHA384 -> SHA384 -> Result
(SHA384 -> SHA384 -> Result) -> Equality SHA384
forall a. (a -> a -> Result) -> Equality a
eq :: SHA384 -> SHA384 -> Result
$ceq :: SHA384 -> SHA384 -> Result
Equality, Ptr b -> Int -> IO SHA384
Ptr b -> Int -> SHA384 -> IO ()
Ptr SHA384 -> IO SHA384
Ptr SHA384 -> Int -> IO SHA384
Ptr SHA384 -> Int -> SHA384 -> IO ()
Ptr SHA384 -> SHA384 -> IO ()
SHA384 -> Int
(SHA384 -> Int)
-> (SHA384 -> Int)
-> (Ptr SHA384 -> Int -> IO SHA384)
-> (Ptr SHA384 -> Int -> SHA384 -> IO ())
-> (forall b. Ptr b -> Int -> IO SHA384)
-> (forall b. Ptr b -> Int -> SHA384 -> IO ())
-> (Ptr SHA384 -> IO SHA384)
-> (Ptr SHA384 -> SHA384 -> IO ())
-> Storable SHA384
forall b. Ptr b -> Int -> IO SHA384
forall b. Ptr b -> Int -> SHA384 -> 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 SHA384 -> SHA384 -> IO ()
$cpoke :: Ptr SHA384 -> SHA384 -> IO ()
peek :: Ptr SHA384 -> IO SHA384
$cpeek :: Ptr SHA384 -> IO SHA384
pokeByteOff :: Ptr b -> Int -> SHA384 -> IO ()
$cpokeByteOff :: forall b. Ptr b -> Int -> SHA384 -> IO ()
peekByteOff :: Ptr b -> Int -> IO SHA384
$cpeekByteOff :: forall b. Ptr b -> Int -> IO SHA384
pokeElemOff :: Ptr SHA384 -> Int -> SHA384 -> IO ()
$cpokeElemOff :: Ptr SHA384 -> Int -> SHA384 -> IO ()
peekElemOff :: Ptr SHA384 -> Int -> IO SHA384
$cpeekElemOff :: Ptr SHA384 -> Int -> IO SHA384
alignment :: SHA384 -> Int
$calignment :: SHA384 -> Int
sizeOf :: SHA384 -> Int
$csizeOf :: SHA384 -> Int
Storable, Storable SHA384
Ptr SHA384 -> IO SHA384
Ptr SHA384 -> Int -> IO ()
Ptr SHA384 -> SHA384 -> IO ()
Storable SHA384
-> (Ptr SHA384 -> SHA384 -> IO ())
-> (Ptr SHA384 -> IO SHA384)
-> (Ptr SHA384 -> Int -> IO ())
-> EndianStore SHA384
forall w.
Storable w
-> (Ptr w -> w -> IO ())
-> (Ptr w -> IO w)
-> (Ptr w -> Int -> IO ())
-> EndianStore w
adjustEndian :: Ptr SHA384 -> Int -> IO ()
$cadjustEndian :: Ptr SHA384 -> Int -> IO ()
load :: Ptr SHA384 -> IO SHA384
$cload :: Ptr SHA384 -> IO SHA384
store :: Ptr SHA384 -> SHA384 -> IO ()
$cstore :: Ptr SHA384 -> SHA384 -> IO ()
$cp1EndianStore :: Storable SHA384
EndianStore)

instance Encodable SHA384

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

instance Show SHA384 where
  show :: SHA384 -> String
show =  SHA384 -> String
forall a. Encodable a => a -> String
showBase16
instance Primitive SHA384 where
  blockSize :: SHA384 -> BYTES Int
blockSize SHA384
_ = Int -> BYTES Int
forall a. a -> BYTES a
BYTES Int
128
  type Implementation SHA384 = SomeHashI SHA384

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