From 393b159d5f001ed876fb7893cd718700bf8646c3 Mon Sep 17 00:00:00 2001 From: Vincent Hanquez Date: Tue, 19 May 2015 11:51:18 +0100 Subject: [PATCH] [hash] add haddock documentation --- Crypto/Hash/IO.hs | 11 ++++++++++- Crypto/Hash/Kekkak.hs | 10 +++++++--- Crypto/Hash/MD2.hs | 7 ++++--- Crypto/Hash/MD4.hs | 7 ++++--- Crypto/Hash/MD5.hs | 7 ++++--- Crypto/Hash/RIPEMD160.hs | 7 ++++--- Crypto/Hash/SHA1.hs | 7 ++++--- Crypto/Hash/SHA224.hs | 7 ++++--- Crypto/Hash/SHA256.hs | 7 ++++--- Crypto/Hash/SHA3.hs | 10 +++++++--- Crypto/Hash/SHA384.hs | 7 ++++--- Crypto/Hash/SHA512.hs | 7 ++++--- Crypto/Hash/SHA512t.hs | 2 ++ Crypto/Hash/Skein256.hs | 8 +++++--- Crypto/Hash/Skein512.hs | 10 +++++++--- Crypto/Hash/Tiger.hs | 7 ++++--- Crypto/Hash/Whirlpool.hs | 7 ++++--- gen/template/hash-len.hs | 1 + gen/template/hash.hs | 1 + 19 files changed, 84 insertions(+), 46 deletions(-) diff --git a/Crypto/Hash/IO.hs b/Crypto/Hash/IO.hs index 50cd8b9..f9f5b8e 100644 --- a/Crypto/Hash/IO.hs +++ b/Crypto/Hash/IO.hs @@ -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 diff --git a/Crypto/Hash/Kekkak.hs b/Crypto/Hash/Kekkak.hs index 677e8d1..427156f 100644 --- a/Crypto/Hash/Kekkak.hs +++ b/Crypto/Hash/Kekkak.hs @@ -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 () diff --git a/Crypto/Hash/MD2.hs b/Crypto/Hash/MD2.hs index ba5f1eb..9de866b 100644 --- a/Crypto/Hash/MD2.hs +++ b/Crypto/Hash/MD2.hs @@ -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 () diff --git a/Crypto/Hash/MD4.hs b/Crypto/Hash/MD4.hs index 1eda9f0..3a089c7 100644 --- a/Crypto/Hash/MD4.hs +++ b/Crypto/Hash/MD4.hs @@ -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 () diff --git a/Crypto/Hash/MD5.hs b/Crypto/Hash/MD5.hs index 8844f8a..0148fe8 100644 --- a/Crypto/Hash/MD5.hs +++ b/Crypto/Hash/MD5.hs @@ -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 () diff --git a/Crypto/Hash/RIPEMD160.hs b/Crypto/Hash/RIPEMD160.hs index 9bbe317..d9a3f0e 100644 --- a/Crypto/Hash/RIPEMD160.hs +++ b/Crypto/Hash/RIPEMD160.hs @@ -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 () diff --git a/Crypto/Hash/SHA1.hs b/Crypto/Hash/SHA1.hs index 1087fdc..19348be 100644 --- a/Crypto/Hash/SHA1.hs +++ b/Crypto/Hash/SHA1.hs @@ -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 () diff --git a/Crypto/Hash/SHA224.hs b/Crypto/Hash/SHA224.hs index 1f03abe..652af92 100644 --- a/Crypto/Hash/SHA224.hs +++ b/Crypto/Hash/SHA224.hs @@ -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 () diff --git a/Crypto/Hash/SHA256.hs b/Crypto/Hash/SHA256.hs index 88b2fa8..11bd2a0 100644 --- a/Crypto/Hash/SHA256.hs +++ b/Crypto/Hash/SHA256.hs @@ -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 () diff --git a/Crypto/Hash/SHA3.hs b/Crypto/Hash/SHA3.hs index d29d5d1..7ecdfa8 100644 --- a/Crypto/Hash/SHA3.hs +++ b/Crypto/Hash/SHA3.hs @@ -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 () diff --git a/Crypto/Hash/SHA384.hs b/Crypto/Hash/SHA384.hs index 9fed2ab..6c20dd7 100644 --- a/Crypto/Hash/SHA384.hs +++ b/Crypto/Hash/SHA384.hs @@ -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 () diff --git a/Crypto/Hash/SHA512.hs b/Crypto/Hash/SHA512.hs index b9306ce..fd4305b 100644 --- a/Crypto/Hash/SHA512.hs +++ b/Crypto/Hash/SHA512.hs @@ -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 () diff --git a/Crypto/Hash/SHA512t.hs b/Crypto/Hash/SHA512t.hs index 65ba584..5e0f7fc 100644 --- a/Crypto/Hash/SHA512t.hs +++ b/Crypto/Hash/SHA512t.hs @@ -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) diff --git a/Crypto/Hash/Skein256.hs b/Crypto/Hash/Skein256.hs index 1657843..b5a97fb 100644 --- a/Crypto/Hash/Skein256.hs +++ b/Crypto/Hash/Skein256.hs @@ -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 () diff --git a/Crypto/Hash/Skein512.hs b/Crypto/Hash/Skein512.hs index 8a64179..bd2de5d 100644 --- a/Crypto/Hash/Skein512.hs +++ b/Crypto/Hash/Skein512.hs @@ -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 () diff --git a/Crypto/Hash/Tiger.hs b/Crypto/Hash/Tiger.hs index 3aa3701..35e14ee 100644 --- a/Crypto/Hash/Tiger.hs +++ b/Crypto/Hash/Tiger.hs @@ -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 () diff --git a/Crypto/Hash/Whirlpool.hs b/Crypto/Hash/Whirlpool.hs index b493722..07bb2cb 100644 --- a/Crypto/Hash/Whirlpool.hs +++ b/Crypto/Hash/Whirlpool.hs @@ -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 () diff --git a/gen/template/hash-len.hs b/gen/template/hash-len.hs index 37257c4..df2a7f9 100644 --- a/gen/template/hash-len.hs +++ b/gen/template/hash-len.hs @@ -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) diff --git a/gen/template/hash.hs b/gen/template/hash.hs index 06ac18c..6fa0431 100644 --- a/gen/template/hash.hs +++ b/gen/template/hash.hs @@ -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)