1-- | 2-- Module : Crypto.Hash.RIPEMD160 3-- License : BSD-style 4-- Maintainer : Vincent Hanquez <vincent@snarc.org> 5-- Stability : experimental 6-- Portability : unknown 7-- 8-- Module containing the binding functions to work with the 9-- RIPEMD160 cryptographic hash. 10-- 11{-# LANGUAGE ForeignFunctionInterface #-} 12{-# LANGUAGE DeriveDataTypeable #-} 13{-# LANGUAGE DataKinds #-} 14{-# LANGUAGE TypeFamilies #-} 15module Crypto.Hash.RIPEMD160 ( RIPEMD160 (..) ) where 16 17import Crypto.Hash.Types 18import Foreign.Ptr (Ptr) 19import Data.Data 20import Data.Word (Word8, Word32) 21 22-- | RIPEMD160 cryptographic hash algorithm 23data RIPEMD160 = RIPEMD160 24 deriving (Show,Data) 25 26instance HashAlgorithm RIPEMD160 where 27 type HashBlockSize RIPEMD160 = 64 28 type HashDigestSize RIPEMD160 = 20 29 type HashInternalContextSize RIPEMD160 = 128 30 hashBlockSize _ = 64 31 hashDigestSize _ = 20 32 hashInternalContextSize _ = 128 33 hashInternalInit = c_ripemd160_init 34 hashInternalUpdate = c_ripemd160_update 35 hashInternalFinalize = c_ripemd160_finalize 36 37foreign import ccall unsafe "cryptonite_ripemd160_init" 38 c_ripemd160_init :: Ptr (Context a)-> IO () 39 40foreign import ccall "cryptonite_ripemd160_update" 41 c_ripemd160_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO () 42 43foreign import ccall unsafe "cryptonite_ripemd160_finalize" 44 c_ripemd160_finalize :: Ptr (Context a) -> Ptr (Digest a) -> IO () 45