1-- | 2-- Module : Crypto.Hash.Skein512 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-- Skein512 cryptographic hash. 10-- 11{-# LANGUAGE ForeignFunctionInterface #-} 12{-# LANGUAGE DeriveDataTypeable #-} 13{-# LANGUAGE DataKinds #-} 14{-# LANGUAGE TypeFamilies #-} 15module Crypto.Hash.Skein512 16 ( Skein512_224 (..), Skein512_256 (..), Skein512_384 (..), Skein512_512 (..) 17 ) where 18 19import Crypto.Hash.Types 20import Foreign.Ptr (Ptr) 21import Data.Data 22import Data.Word (Word8, Word32) 23 24 25-- | Skein512 (224 bits) cryptographic hash algorithm 26data Skein512_224 = Skein512_224 27 deriving (Show,Data) 28 29instance HashAlgorithm Skein512_224 where 30 type HashBlockSize Skein512_224 = 64 31 type HashDigestSize Skein512_224 = 28 32 type HashInternalContextSize Skein512_224 = 160 33 hashBlockSize _ = 64 34 hashDigestSize _ = 28 35 hashInternalContextSize _ = 160 36 hashInternalInit p = c_skein512_init p 224 37 hashInternalUpdate = c_skein512_update 38 hashInternalFinalize p = c_skein512_finalize p 224 39 40-- | Skein512 (256 bits) cryptographic hash algorithm 41data Skein512_256 = Skein512_256 42 deriving (Show,Data) 43 44instance HashAlgorithm Skein512_256 where 45 type HashBlockSize Skein512_256 = 64 46 type HashDigestSize Skein512_256 = 32 47 type HashInternalContextSize Skein512_256 = 160 48 hashBlockSize _ = 64 49 hashDigestSize _ = 32 50 hashInternalContextSize _ = 160 51 hashInternalInit p = c_skein512_init p 256 52 hashInternalUpdate = c_skein512_update 53 hashInternalFinalize p = c_skein512_finalize p 256 54 55-- | Skein512 (384 bits) cryptographic hash algorithm 56data Skein512_384 = Skein512_384 57 deriving (Show,Data) 58 59instance HashAlgorithm Skein512_384 where 60 type HashBlockSize Skein512_384 = 64 61 type HashDigestSize Skein512_384 = 48 62 type HashInternalContextSize Skein512_384 = 160 63 hashBlockSize _ = 64 64 hashDigestSize _ = 48 65 hashInternalContextSize _ = 160 66 hashInternalInit p = c_skein512_init p 384 67 hashInternalUpdate = c_skein512_update 68 hashInternalFinalize p = c_skein512_finalize p 384 69 70-- | Skein512 (512 bits) cryptographic hash algorithm 71data Skein512_512 = Skein512_512 72 deriving (Show,Data) 73 74instance HashAlgorithm Skein512_512 where 75 type HashBlockSize Skein512_512 = 64 76 type HashDigestSize Skein512_512 = 64 77 type HashInternalContextSize Skein512_512 = 160 78 hashBlockSize _ = 64 79 hashDigestSize _ = 64 80 hashInternalContextSize _ = 160 81 hashInternalInit p = c_skein512_init p 512 82 hashInternalUpdate = c_skein512_update 83 hashInternalFinalize p = c_skein512_finalize p 512 84 85 86foreign import ccall unsafe "cryptonite_skein512_init" 87 c_skein512_init :: Ptr (Context a) -> Word32 -> IO () 88 89foreign import ccall "cryptonite_skein512_update" 90 c_skein512_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO () 91 92foreign import ccall unsafe "cryptonite_skein512_finalize" 93 c_skein512_finalize :: Ptr (Context a) -> Word32 -> Ptr (Digest a) -> IO () 94