{-# LANGUAGE ForeignFunctionInterface   #-}
-- | The portable C-implementation of SHA1
module Raaz.Hash.Sha1.Implementation.CPortable
       ( implementation
       ) where

import Foreign.Ptr              ( Ptr )
import Raaz.Core
import Raaz.Hash.Internal
import Raaz.Hash.Sha.Util
import Raaz.Hash.Sha1.Internal

-- | The portable C implementation of SHA1.
implementation :: Implementation SHA1
implementation :: Implementation SHA1
implementation =  HashI SHA1 (HashMemory SHA1) -> SomeHashI SHA1
forall h m. HashM h m => HashI h m -> SomeHashI h
SomeHashI HashI SHA1 (HashMemory SHA1)
cPortable

cPortable :: HashI SHA1 (HashMemory SHA1)
cPortable :: HashI SHA1 (HashMemory SHA1)
cPortable = String
-> String
-> Compressor SHA1
-> LengthWrite SHA1
-> HashI SHA1 (HashMemory SHA1)
forall h.
IsSha h =>
String
-> String
-> Compressor h
-> LengthWrite h
-> HashI h (HashMemory h)
shaImplementation
            String
"sha1-cportable"
            String
"Sha1 Implementation using portable C and Haskell FFI"
            Compressor SHA1
c_sha1_compress LengthWrite SHA1
forall h. LengthWrite h
length64Write

foreign import ccall unsafe
  "raaz/hash/sha1/portable.h raazHashSha1PortableCompress"
  c_sha1_compress  :: Pointer -> Int -> Ptr SHA1 -> IO ()