1-- | 2-- Module : Crypto.Hash.SHA512t 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-- SHA512t cryptographic hash. 10-- 11{-# LANGUAGE ForeignFunctionInterface #-} 12{-# LANGUAGE DeriveDataTypeable #-} 13{-# LANGUAGE DataKinds #-} 14{-# LANGUAGE TypeFamilies #-} 15module Crypto.Hash.SHA512t 16 ( SHA512t_224 (..), SHA512t_256 (..) 17 ) where 18 19import Crypto.Hash.Types 20import Foreign.Ptr (Ptr) 21import Data.Data 22import Data.Word (Word8, Word32) 23 24 25-- | SHA512t (224 bits) cryptographic hash algorithm 26data SHA512t_224 = SHA512t_224 27 deriving (Show,Data) 28 29instance HashAlgorithm SHA512t_224 where 30 type HashBlockSize SHA512t_224 = 128 31 type HashDigestSize SHA512t_224 = 28 32 type HashInternalContextSize SHA512t_224 = 256 33 hashBlockSize _ = 128 34 hashDigestSize _ = 28 35 hashInternalContextSize _ = 256 36 hashInternalInit p = c_sha512t_init p 224 37 hashInternalUpdate = c_sha512t_update 38 hashInternalFinalize p = c_sha512t_finalize p 224 39 40-- | SHA512t (256 bits) cryptographic hash algorithm 41data SHA512t_256 = SHA512t_256 42 deriving (Show,Data) 43 44instance HashAlgorithm SHA512t_256 where 45 type HashBlockSize SHA512t_256 = 128 46 type HashDigestSize SHA512t_256 = 32 47 type HashInternalContextSize SHA512t_256 = 256 48 hashBlockSize _ = 128 49 hashDigestSize _ = 32 50 hashInternalContextSize _ = 256 51 hashInternalInit p = c_sha512t_init p 256 52 hashInternalUpdate = c_sha512t_update 53 hashInternalFinalize p = c_sha512t_finalize p 256 54 55 56foreign import ccall unsafe "cryptonite_sha512t_init" 57 c_sha512t_init :: Ptr (Context a) -> Word32 -> IO () 58 59foreign import ccall "cryptonite_sha512t_update" 60 c_sha512t_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO () 61 62foreign import ccall unsafe "cryptonite_sha512t_finalize" 63 c_sha512t_finalize :: Ptr (Context a) -> Word32 -> Ptr (Digest a) -> IO () 64