[hash] add haddock documentation
This commit is contained in:
parent
9794e2132b
commit
393b159d5f
@ -23,18 +23,26 @@ import Crypto.Hash.Types
|
||||
import qualified Crypto.Internal.ByteArray as B
|
||||
import Foreign.Ptr
|
||||
|
||||
-- | A Mutable hash context
|
||||
newtype MutableContext a = MutableContext B.Bytes
|
||||
deriving (B.ByteArrayAccess)
|
||||
|
||||
-- | Create a new mutable hash context.
|
||||
--
|
||||
-- the algorithm used is automatically determined from the return constraint.
|
||||
hashMutableInit :: HashAlgorithm alg => IO (MutableContext alg)
|
||||
hashMutableInit = doInit undefined B.alloc
|
||||
where
|
||||
doInit :: HashAlgorithm a => a -> (Int -> (Ptr (Context a) -> IO ()) -> IO B.Bytes) -> IO (MutableContext a)
|
||||
doInit alg alloc = MutableContext `fmap` alloc (hashInternalContextSize alg) hashInternalInit
|
||||
|
||||
-- | Create a new mutable hash context.
|
||||
--
|
||||
-- The algorithm is explicitely passed as parameter
|
||||
hashMutableInitWith :: HashAlgorithm alg => alg -> IO (MutableContext alg)
|
||||
hashMutableInitWith _ = hashMutableInit
|
||||
|
||||
-- | Update a mutable hash context in place
|
||||
hashMutableUpdate :: (B.ByteArrayAccess ba, HashAlgorithm a) => MutableContext a -> ba -> IO ()
|
||||
hashMutableUpdate mc dat = doUpdate mc (B.withByteArray mc)
|
||||
where doUpdate :: HashAlgorithm a => MutableContext a -> ((Ptr (Context a) -> IO ()) -> IO ()) -> IO ()
|
||||
@ -43,11 +51,12 @@ hashMutableUpdate mc dat = doUpdate mc (B.withByteArray mc)
|
||||
B.withByteArray dat $ \d ->
|
||||
hashInternalUpdate ctx d (fromIntegral $ B.length dat)
|
||||
|
||||
-- | Finalize a mutable hash context and compute a digest
|
||||
hashMutableFinalize :: HashAlgorithm a => MutableContext a -> IO (Digest a)
|
||||
hashMutableFinalize mc = doFinalize undefined (B.withByteArray mc) B.alloc
|
||||
where doFinalize :: HashAlgorithm alg
|
||||
=> alg
|
||||
-> ((Ptr (Context alg) -> IO ()) -> IO ())
|
||||
-> ((Ptr (Context alg) -> IO ()) -> IO ())
|
||||
-> (Int -> (Ptr (Digest alg) -> IO ()) -> IO B.Bytes)
|
||||
-> IO (Digest alg)
|
||||
doFinalize alg withCtx allocDigest = do
|
||||
|
||||
@ -18,6 +18,7 @@ import Foreign.Ptr (Ptr)
|
||||
import Data.Word (Word8, Word32)
|
||||
|
||||
|
||||
-- | Kekkak (224 bits) cryptographic hash algorithm
|
||||
data Kekkak_224 = Kekkak_224
|
||||
deriving (Show)
|
||||
|
||||
@ -29,6 +30,7 @@ instance HashAlgorithm Kekkak_224 where
|
||||
hashInternalUpdate = c_kekkak_update
|
||||
hashInternalFinalize = c_kekkak_finalize
|
||||
|
||||
-- | Kekkak (256 bits) cryptographic hash algorithm
|
||||
data Kekkak_256 = Kekkak_256
|
||||
deriving (Show)
|
||||
|
||||
@ -40,6 +42,7 @@ instance HashAlgorithm Kekkak_256 where
|
||||
hashInternalUpdate = c_kekkak_update
|
||||
hashInternalFinalize = c_kekkak_finalize
|
||||
|
||||
-- | Kekkak (384 bits) cryptographic hash algorithm
|
||||
data Kekkak_384 = Kekkak_384
|
||||
deriving (Show)
|
||||
|
||||
@ -51,6 +54,7 @@ instance HashAlgorithm Kekkak_384 where
|
||||
hashInternalUpdate = c_kekkak_update
|
||||
hashInternalFinalize = c_kekkak_finalize
|
||||
|
||||
-- | Kekkak (512 bits) cryptographic hash algorithm
|
||||
data Kekkak_512 = Kekkak_512
|
||||
deriving (Show)
|
||||
|
||||
@ -63,11 +67,11 @@ instance HashAlgorithm Kekkak_512 where
|
||||
hashInternalFinalize = c_kekkak_finalize
|
||||
|
||||
|
||||
foreign import ccall unsafe "cryptonite_kekkak.h cryptonite_kekkak_init"
|
||||
foreign import ccall unsafe "cryptonite_kekkak_init"
|
||||
c_kekkak_init :: Ptr (Context a) -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall "cryptonite_kekkak.h cryptonite_kekkak_update"
|
||||
foreign import ccall "cryptonite_kekkak_update"
|
||||
c_kekkak_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_kekkak.h cryptonite_kekkak_finalize"
|
||||
foreign import ccall unsafe "cryptonite_kekkak_finalize"
|
||||
c_kekkak_finalize :: Ptr (Context a) -> Ptr (Digest a) -> IO ()
|
||||
|
||||
@ -15,6 +15,7 @@ import Crypto.Hash.Types
|
||||
import Foreign.Ptr (Ptr)
|
||||
import Data.Word (Word8, Word32)
|
||||
|
||||
-- | MD2 cryptographic hash algorithm
|
||||
data MD2 = MD2
|
||||
deriving (Show)
|
||||
|
||||
@ -26,11 +27,11 @@ instance HashAlgorithm MD2 where
|
||||
hashInternalUpdate = c_md2_update
|
||||
hashInternalFinalize = c_md2_finalize
|
||||
|
||||
foreign import ccall unsafe "cryptonite_md2.h cryptonite_md2_init"
|
||||
foreign import ccall unsafe "cryptonite_md2_init"
|
||||
c_md2_init :: Ptr (Context a)-> IO ()
|
||||
|
||||
foreign import ccall "cryptonite_md2.h cryptonite_md2_update"
|
||||
foreign import ccall "cryptonite_md2_update"
|
||||
c_md2_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_md2.h cryptonite_md2_finalize"
|
||||
foreign import ccall unsafe "cryptonite_md2_finalize"
|
||||
c_md2_finalize :: Ptr (Context a) -> Ptr (Digest a) -> IO ()
|
||||
|
||||
@ -15,6 +15,7 @@ import Crypto.Hash.Types
|
||||
import Foreign.Ptr (Ptr)
|
||||
import Data.Word (Word8, Word32)
|
||||
|
||||
-- | MD4 cryptographic hash algorithm
|
||||
data MD4 = MD4
|
||||
deriving (Show)
|
||||
|
||||
@ -26,11 +27,11 @@ instance HashAlgorithm MD4 where
|
||||
hashInternalUpdate = c_md4_update
|
||||
hashInternalFinalize = c_md4_finalize
|
||||
|
||||
foreign import ccall unsafe "cryptonite_md4.h cryptonite_md4_init"
|
||||
foreign import ccall unsafe "cryptonite_md4_init"
|
||||
c_md4_init :: Ptr (Context a)-> IO ()
|
||||
|
||||
foreign import ccall "cryptonite_md4.h cryptonite_md4_update"
|
||||
foreign import ccall "cryptonite_md4_update"
|
||||
c_md4_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_md4.h cryptonite_md4_finalize"
|
||||
foreign import ccall unsafe "cryptonite_md4_finalize"
|
||||
c_md4_finalize :: Ptr (Context a) -> Ptr (Digest a) -> IO ()
|
||||
|
||||
@ -15,6 +15,7 @@ import Crypto.Hash.Types
|
||||
import Foreign.Ptr (Ptr)
|
||||
import Data.Word (Word8, Word32)
|
||||
|
||||
-- | MD5 cryptographic hash algorithm
|
||||
data MD5 = MD5
|
||||
deriving (Show)
|
||||
|
||||
@ -26,11 +27,11 @@ instance HashAlgorithm MD5 where
|
||||
hashInternalUpdate = c_md5_update
|
||||
hashInternalFinalize = c_md5_finalize
|
||||
|
||||
foreign import ccall unsafe "cryptonite_md5.h cryptonite_md5_init"
|
||||
foreign import ccall unsafe "cryptonite_md5_init"
|
||||
c_md5_init :: Ptr (Context a)-> IO ()
|
||||
|
||||
foreign import ccall "cryptonite_md5.h cryptonite_md5_update"
|
||||
foreign import ccall "cryptonite_md5_update"
|
||||
c_md5_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_md5.h cryptonite_md5_finalize"
|
||||
foreign import ccall unsafe "cryptonite_md5_finalize"
|
||||
c_md5_finalize :: Ptr (Context a) -> Ptr (Digest a) -> IO ()
|
||||
|
||||
@ -15,6 +15,7 @@ import Crypto.Hash.Types
|
||||
import Foreign.Ptr (Ptr)
|
||||
import Data.Word (Word8, Word32)
|
||||
|
||||
-- | RIPEMD160 cryptographic hash algorithm
|
||||
data RIPEMD160 = RIPEMD160
|
||||
deriving (Show)
|
||||
|
||||
@ -26,11 +27,11 @@ instance HashAlgorithm RIPEMD160 where
|
||||
hashInternalUpdate = c_ripemd160_update
|
||||
hashInternalFinalize = c_ripemd160_finalize
|
||||
|
||||
foreign import ccall unsafe "cryptonite_ripemd.h cryptonite_ripemd160_init"
|
||||
foreign import ccall unsafe "cryptonite_ripemd160_init"
|
||||
c_ripemd160_init :: Ptr (Context a)-> IO ()
|
||||
|
||||
foreign import ccall "cryptonite_ripemd.h cryptonite_ripemd160_update"
|
||||
foreign import ccall "cryptonite_ripemd160_update"
|
||||
c_ripemd160_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_ripemd.h cryptonite_ripemd160_finalize"
|
||||
foreign import ccall unsafe "cryptonite_ripemd160_finalize"
|
||||
c_ripemd160_finalize :: Ptr (Context a) -> Ptr (Digest a) -> IO ()
|
||||
|
||||
@ -15,6 +15,7 @@ import Crypto.Hash.Types
|
||||
import Foreign.Ptr (Ptr)
|
||||
import Data.Word (Word8, Word32)
|
||||
|
||||
-- | SHA1 cryptographic hash algorithm
|
||||
data SHA1 = SHA1
|
||||
deriving (Show)
|
||||
|
||||
@ -26,11 +27,11 @@ instance HashAlgorithm SHA1 where
|
||||
hashInternalUpdate = c_sha1_update
|
||||
hashInternalFinalize = c_sha1_finalize
|
||||
|
||||
foreign import ccall unsafe "cryptonite_sha1.h cryptonite_sha1_init"
|
||||
foreign import ccall unsafe "cryptonite_sha1_init"
|
||||
c_sha1_init :: Ptr (Context a)-> IO ()
|
||||
|
||||
foreign import ccall "cryptonite_sha1.h cryptonite_sha1_update"
|
||||
foreign import ccall "cryptonite_sha1_update"
|
||||
c_sha1_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_sha1.h cryptonite_sha1_finalize"
|
||||
foreign import ccall unsafe "cryptonite_sha1_finalize"
|
||||
c_sha1_finalize :: Ptr (Context a) -> Ptr (Digest a) -> IO ()
|
||||
|
||||
@ -15,6 +15,7 @@ import Crypto.Hash.Types
|
||||
import Foreign.Ptr (Ptr)
|
||||
import Data.Word (Word8, Word32)
|
||||
|
||||
-- | SHA224 cryptographic hash algorithm
|
||||
data SHA224 = SHA224
|
||||
deriving (Show)
|
||||
|
||||
@ -26,11 +27,11 @@ instance HashAlgorithm SHA224 where
|
||||
hashInternalUpdate = c_sha224_update
|
||||
hashInternalFinalize = c_sha224_finalize
|
||||
|
||||
foreign import ccall unsafe "cryptonite_sha256.h cryptonite_sha224_init"
|
||||
foreign import ccall unsafe "cryptonite_sha224_init"
|
||||
c_sha224_init :: Ptr (Context a)-> IO ()
|
||||
|
||||
foreign import ccall "cryptonite_sha256.h cryptonite_sha224_update"
|
||||
foreign import ccall "cryptonite_sha224_update"
|
||||
c_sha224_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_sha256.h cryptonite_sha224_finalize"
|
||||
foreign import ccall unsafe "cryptonite_sha224_finalize"
|
||||
c_sha224_finalize :: Ptr (Context a) -> Ptr (Digest a) -> IO ()
|
||||
|
||||
@ -15,6 +15,7 @@ import Crypto.Hash.Types
|
||||
import Foreign.Ptr (Ptr)
|
||||
import Data.Word (Word8, Word32)
|
||||
|
||||
-- | SHA256 cryptographic hash algorithm
|
||||
data SHA256 = SHA256
|
||||
deriving (Show)
|
||||
|
||||
@ -26,11 +27,11 @@ instance HashAlgorithm SHA256 where
|
||||
hashInternalUpdate = c_sha256_update
|
||||
hashInternalFinalize = c_sha256_finalize
|
||||
|
||||
foreign import ccall unsafe "cryptonite_sha256.h cryptonite_sha256_init"
|
||||
foreign import ccall unsafe "cryptonite_sha256_init"
|
||||
c_sha256_init :: Ptr (Context a)-> IO ()
|
||||
|
||||
foreign import ccall "cryptonite_sha256.h cryptonite_sha256_update"
|
||||
foreign import ccall "cryptonite_sha256_update"
|
||||
c_sha256_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_sha256.h cryptonite_sha256_finalize"
|
||||
foreign import ccall unsafe "cryptonite_sha256_finalize"
|
||||
c_sha256_finalize :: Ptr (Context a) -> Ptr (Digest a) -> IO ()
|
||||
|
||||
@ -18,6 +18,7 @@ import Foreign.Ptr (Ptr)
|
||||
import Data.Word (Word8, Word32)
|
||||
|
||||
|
||||
-- | SHA3 (224 bits) cryptographic hash algorithm
|
||||
data SHA3_224 = SHA3_224
|
||||
deriving (Show)
|
||||
|
||||
@ -29,6 +30,7 @@ instance HashAlgorithm SHA3_224 where
|
||||
hashInternalUpdate = c_sha3_update
|
||||
hashInternalFinalize = c_sha3_finalize
|
||||
|
||||
-- | SHA3 (256 bits) cryptographic hash algorithm
|
||||
data SHA3_256 = SHA3_256
|
||||
deriving (Show)
|
||||
|
||||
@ -40,6 +42,7 @@ instance HashAlgorithm SHA3_256 where
|
||||
hashInternalUpdate = c_sha3_update
|
||||
hashInternalFinalize = c_sha3_finalize
|
||||
|
||||
-- | SHA3 (384 bits) cryptographic hash algorithm
|
||||
data SHA3_384 = SHA3_384
|
||||
deriving (Show)
|
||||
|
||||
@ -51,6 +54,7 @@ instance HashAlgorithm SHA3_384 where
|
||||
hashInternalUpdate = c_sha3_update
|
||||
hashInternalFinalize = c_sha3_finalize
|
||||
|
||||
-- | SHA3 (512 bits) cryptographic hash algorithm
|
||||
data SHA3_512 = SHA3_512
|
||||
deriving (Show)
|
||||
|
||||
@ -63,11 +67,11 @@ instance HashAlgorithm SHA3_512 where
|
||||
hashInternalFinalize = c_sha3_finalize
|
||||
|
||||
|
||||
foreign import ccall unsafe "cryptonite_sha3.h cryptonite_sha3_init"
|
||||
foreign import ccall unsafe "cryptonite_sha3_init"
|
||||
c_sha3_init :: Ptr (Context a) -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall "cryptonite_sha3.h cryptonite_sha3_update"
|
||||
foreign import ccall "cryptonite_sha3_update"
|
||||
c_sha3_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_sha3.h cryptonite_sha3_finalize"
|
||||
foreign import ccall unsafe "cryptonite_sha3_finalize"
|
||||
c_sha3_finalize :: Ptr (Context a) -> Ptr (Digest a) -> IO ()
|
||||
|
||||
@ -15,6 +15,7 @@ import Crypto.Hash.Types
|
||||
import Foreign.Ptr (Ptr)
|
||||
import Data.Word (Word8, Word32)
|
||||
|
||||
-- | SHA384 cryptographic hash algorithm
|
||||
data SHA384 = SHA384
|
||||
deriving (Show)
|
||||
|
||||
@ -26,11 +27,11 @@ instance HashAlgorithm SHA384 where
|
||||
hashInternalUpdate = c_sha384_update
|
||||
hashInternalFinalize = c_sha384_finalize
|
||||
|
||||
foreign import ccall unsafe "cryptonite_sha512.h cryptonite_sha384_init"
|
||||
foreign import ccall unsafe "cryptonite_sha384_init"
|
||||
c_sha384_init :: Ptr (Context a)-> IO ()
|
||||
|
||||
foreign import ccall "cryptonite_sha512.h cryptonite_sha384_update"
|
||||
foreign import ccall "cryptonite_sha384_update"
|
||||
c_sha384_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_sha512.h cryptonite_sha384_finalize"
|
||||
foreign import ccall unsafe "cryptonite_sha384_finalize"
|
||||
c_sha384_finalize :: Ptr (Context a) -> Ptr (Digest a) -> IO ()
|
||||
|
||||
@ -15,6 +15,7 @@ import Crypto.Hash.Types
|
||||
import Foreign.Ptr (Ptr)
|
||||
import Data.Word (Word8, Word32)
|
||||
|
||||
-- | SHA512 cryptographic hash algorithm
|
||||
data SHA512 = SHA512
|
||||
deriving (Show)
|
||||
|
||||
@ -26,11 +27,11 @@ instance HashAlgorithm SHA512 where
|
||||
hashInternalUpdate = c_sha512_update
|
||||
hashInternalFinalize = c_sha512_finalize
|
||||
|
||||
foreign import ccall unsafe "cryptonite_sha512.h cryptonite_sha512_init"
|
||||
foreign import ccall unsafe "cryptonite_sha512_init"
|
||||
c_sha512_init :: Ptr (Context a)-> IO ()
|
||||
|
||||
foreign import ccall "cryptonite_sha512.h cryptonite_sha512_update"
|
||||
foreign import ccall "cryptonite_sha512_update"
|
||||
c_sha512_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_sha512.h cryptonite_sha512_finalize"
|
||||
foreign import ccall unsafe "cryptonite_sha512_finalize"
|
||||
c_sha512_finalize :: Ptr (Context a) -> Ptr (Digest a) -> IO ()
|
||||
|
||||
@ -18,6 +18,7 @@ import Foreign.Ptr (Ptr)
|
||||
import Data.Word (Word8, Word32)
|
||||
|
||||
|
||||
-- | SHA512t (224 bits) cryptographic hash algorithm
|
||||
data SHA512t_224 = SHA512t_224
|
||||
deriving (Show)
|
||||
|
||||
@ -29,6 +30,7 @@ instance HashAlgorithm SHA512t_224 where
|
||||
hashInternalUpdate = c_sha512t_update
|
||||
hashInternalFinalize = c_sha512t_finalize
|
||||
|
||||
-- | SHA512t (256 bits) cryptographic hash algorithm
|
||||
data SHA512t_256 = SHA512t_256
|
||||
deriving (Show)
|
||||
|
||||
|
||||
@ -18,6 +18,7 @@ import Foreign.Ptr (Ptr)
|
||||
import Data.Word (Word8, Word32)
|
||||
|
||||
|
||||
-- | Skein256 (224 bits) cryptographic hash algorithm
|
||||
data Skein256_224 = Skein256_224
|
||||
deriving (Show)
|
||||
|
||||
@ -29,6 +30,7 @@ instance HashAlgorithm Skein256_224 where
|
||||
hashInternalUpdate = c_skein256_update
|
||||
hashInternalFinalize = c_skein256_finalize
|
||||
|
||||
-- | Skein256 (256 bits) cryptographic hash algorithm
|
||||
data Skein256_256 = Skein256_256
|
||||
deriving (Show)
|
||||
|
||||
@ -41,11 +43,11 @@ instance HashAlgorithm Skein256_256 where
|
||||
hashInternalFinalize = c_skein256_finalize
|
||||
|
||||
|
||||
foreign import ccall unsafe "cryptonite_skein256.h cryptonite_skein256_init"
|
||||
foreign import ccall unsafe "cryptonite_skein256_init"
|
||||
c_skein256_init :: Ptr (Context a) -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall "cryptonite_skein256.h cryptonite_skein256_update"
|
||||
foreign import ccall "cryptonite_skein256_update"
|
||||
c_skein256_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_skein256.h cryptonite_skein256_finalize"
|
||||
foreign import ccall unsafe "cryptonite_skein256_finalize"
|
||||
c_skein256_finalize :: Ptr (Context a) -> Ptr (Digest a) -> IO ()
|
||||
|
||||
@ -18,6 +18,7 @@ import Foreign.Ptr (Ptr)
|
||||
import Data.Word (Word8, Word32)
|
||||
|
||||
|
||||
-- | Skein512 (224 bits) cryptographic hash algorithm
|
||||
data Skein512_224 = Skein512_224
|
||||
deriving (Show)
|
||||
|
||||
@ -29,6 +30,7 @@ instance HashAlgorithm Skein512_224 where
|
||||
hashInternalUpdate = c_skein512_update
|
||||
hashInternalFinalize = c_skein512_finalize
|
||||
|
||||
-- | Skein512 (256 bits) cryptographic hash algorithm
|
||||
data Skein512_256 = Skein512_256
|
||||
deriving (Show)
|
||||
|
||||
@ -40,6 +42,7 @@ instance HashAlgorithm Skein512_256 where
|
||||
hashInternalUpdate = c_skein512_update
|
||||
hashInternalFinalize = c_skein512_finalize
|
||||
|
||||
-- | Skein512 (384 bits) cryptographic hash algorithm
|
||||
data Skein512_384 = Skein512_384
|
||||
deriving (Show)
|
||||
|
||||
@ -51,6 +54,7 @@ instance HashAlgorithm Skein512_384 where
|
||||
hashInternalUpdate = c_skein512_update
|
||||
hashInternalFinalize = c_skein512_finalize
|
||||
|
||||
-- | Skein512 (512 bits) cryptographic hash algorithm
|
||||
data Skein512_512 = Skein512_512
|
||||
deriving (Show)
|
||||
|
||||
@ -63,11 +67,11 @@ instance HashAlgorithm Skein512_512 where
|
||||
hashInternalFinalize = c_skein512_finalize
|
||||
|
||||
|
||||
foreign import ccall unsafe "cryptonite_skein512.h cryptonite_skein512_init"
|
||||
foreign import ccall unsafe "cryptonite_skein512_init"
|
||||
c_skein512_init :: Ptr (Context a) -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall "cryptonite_skein512.h cryptonite_skein512_update"
|
||||
foreign import ccall "cryptonite_skein512_update"
|
||||
c_skein512_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_skein512.h cryptonite_skein512_finalize"
|
||||
foreign import ccall unsafe "cryptonite_skein512_finalize"
|
||||
c_skein512_finalize :: Ptr (Context a) -> Ptr (Digest a) -> IO ()
|
||||
|
||||
@ -15,6 +15,7 @@ import Crypto.Hash.Types
|
||||
import Foreign.Ptr (Ptr)
|
||||
import Data.Word (Word8, Word32)
|
||||
|
||||
-- | Tiger cryptographic hash algorithm
|
||||
data Tiger = Tiger
|
||||
deriving (Show)
|
||||
|
||||
@ -26,11 +27,11 @@ instance HashAlgorithm Tiger where
|
||||
hashInternalUpdate = c_tiger_update
|
||||
hashInternalFinalize = c_tiger_finalize
|
||||
|
||||
foreign import ccall unsafe "cryptonite_tiger.h cryptonite_tiger_init"
|
||||
foreign import ccall unsafe "cryptonite_tiger_init"
|
||||
c_tiger_init :: Ptr (Context a)-> IO ()
|
||||
|
||||
foreign import ccall "cryptonite_tiger.h cryptonite_tiger_update"
|
||||
foreign import ccall "cryptonite_tiger_update"
|
||||
c_tiger_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_tiger.h cryptonite_tiger_finalize"
|
||||
foreign import ccall unsafe "cryptonite_tiger_finalize"
|
||||
c_tiger_finalize :: Ptr (Context a) -> Ptr (Digest a) -> IO ()
|
||||
|
||||
@ -15,6 +15,7 @@ import Crypto.Hash.Types
|
||||
import Foreign.Ptr (Ptr)
|
||||
import Data.Word (Word8, Word32)
|
||||
|
||||
-- | Whirlpool cryptographic hash algorithm
|
||||
data Whirlpool = Whirlpool
|
||||
deriving (Show)
|
||||
|
||||
@ -26,11 +27,11 @@ instance HashAlgorithm Whirlpool where
|
||||
hashInternalUpdate = c_whirlpool_update
|
||||
hashInternalFinalize = c_whirlpool_finalize
|
||||
|
||||
foreign import ccall unsafe "cryptonite_whirlpool.h cryptonite_whirlpool_init"
|
||||
foreign import ccall unsafe "cryptonite_whirlpool_init"
|
||||
c_whirlpool_init :: Ptr (Context a)-> IO ()
|
||||
|
||||
foreign import ccall "cryptonite_whirlpool.h cryptonite_whirlpool_update"
|
||||
foreign import ccall "cryptonite_whirlpool_update"
|
||||
c_whirlpool_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_whirlpool.h cryptonite_whirlpool_finalize"
|
||||
foreign import ccall unsafe "cryptonite_whirlpool_finalize"
|
||||
c_whirlpool_finalize :: Ptr (Context a) -> Ptr (Digest a) -> IO ()
|
||||
|
||||
@ -18,6 +18,7 @@ import Foreign.Ptr (Ptr)
|
||||
import Data.Word (Word8, Word32)
|
||||
|
||||
%{CUSTOMIZABLE%}
|
||||
-- | %%MODULENAME%% (%%CUSTOM_BITSIZE%% bits) cryptographic hash algorithm
|
||||
data %%MODULENAME%%_%%CUSTOM_BITSIZE%% = %%MODULENAME%%_%%CUSTOM_BITSIZE%%
|
||||
deriving (Show)
|
||||
|
||||
|
||||
@ -15,6 +15,7 @@ import Crypto.Hash.Types
|
||||
import Foreign.Ptr (Ptr)
|
||||
import Data.Word (Word8, Word32)
|
||||
|
||||
-- | %%MODULENAME%% cryptographic hash algorithm
|
||||
data %%MODULENAME%% = %%MODULENAME%%
|
||||
deriving (Show)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user