packages feed

cryptohash-cryptoapi 0.1.3 → 0.1.4

raw patch · 2 files changed

+56/−49 lines, 2 filesdep +cryptonitedep +memorydep −cryptohashdep ~basedep ~bytestringdep ~cereal

Dependencies added: cryptonite, memory

Dependencies removed: cryptohash

Dependency ranges changed: base, bytestring, cereal, crypto-api, tagged

Files

Crypto/Hash/CryptoAPI.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE PackageImports #-} -- | -- Module      : Crypto.Hash.CryptoAPI -- License     : BSD-style@@ -34,21 +35,8 @@     , CTXTiger, CTXWhirlpool     ) where -import qualified Crypto.Hash.MD2 as MD2 (Ctx(..), init, update, finalize, hash, hashlazy)-import qualified Crypto.Hash.MD4 as MD4 (Ctx(..), init, update, finalize, hash, hashlazy)-import qualified Crypto.Hash.MD5 as MD5 (Ctx(..), init, update, finalize, hash, hashlazy)-import qualified Crypto.Hash.SHA1 as SHA1 (Ctx(..), init, update, finalize, hash, hashlazy)-import qualified Crypto.Hash.SHA224 as SHA224 (Ctx(..), init, update, finalize, hash, hashlazy)-import qualified Crypto.Hash.SHA256 as SHA256 (Ctx(..), init, update, finalize, hash, hashlazy)-import qualified Crypto.Hash.SHA384 as SHA384 (Ctx(..), init, update, finalize, hash, hashlazy)-import qualified Crypto.Hash.SHA512 as SHA512 (Ctx(..), init, update, finalize, hash, hashlazy)-import qualified Crypto.Hash.SHA512t as SHA512t (Ctx(..), init, update, finalize, hash, hashlazy)-import qualified Crypto.Hash.SHA3 as SHA3 (Ctx(..), init, update, finalize, hash, hashlazy)-import qualified Crypto.Hash.RIPEMD160 as RIPEMD160 (Ctx(..), init, update, finalize, hash, hashlazy)-import qualified Crypto.Hash.Tiger as Tiger (Ctx(..), init, update, finalize, hash, hashlazy)-import qualified Crypto.Hash.Skein256 as Skein256 (Ctx(..), init, update, finalize, hash, hashlazy)-import qualified Crypto.Hash.Skein512 as Skein512 (Ctx(..), init, update, finalize, hash, hashlazy)-import qualified Crypto.Hash.Whirlpool as Whirlpool (Ctx(..), init, update, finalize, hash, hashlazy)+import qualified "cryptonite" Crypto.Hash as H+import qualified Data.ByteString.Lazy as L  import Control.Monad (liftM) import Data.ByteString (ByteString)@@ -57,6 +45,7 @@ import Data.Serialize.Put (putByteString) import Data.Tagged (Tagged(..)) import Crypto.Classes (Hash(..), hash, hash')+import qualified Data.ByteArray as B (convert)  --  -- need to redefine a context wrapper to not clash with the already existing@@ -71,8 +60,6 @@  #define DEFINE_TYPE_AND_INSTANCES(CTXNAME, NAME, MODULENAME, OUTPUTLEN, BLOCKLEN)    \ \-newtype CTXNAME = CTXNAME MODULENAME.Ctx; \-\ data NAME = NAME !ByteString deriving (Eq,Ord,Show); \ \ instance Serialize NAME where \@@ -80,23 +67,15 @@    ; put (NAME d) = putByteString d \    }; \ \-instance Serialize CTXNAME where \-  { get                              = liftM (CTXNAME . MODULENAME.Ctx) get \-  ; put (CTXNAME (MODULENAME.Ctx c)) = put c \-  }; \-\ instance Hash CTXNAME NAME where \    { outputLength    = Tagged (OUTPUTLEN * 8) \    ; blockLength     = Tagged (BLOCKLEN * 8)  \-   ; initialCtx      = CTXNAME MODULENAME.init        \-   ; updateCtx (CTXNAME ctx) = CTXNAME . MODULENAME.update ctx      \-   ; finalize (CTXNAME ctx) bs = NAME $ MODULENAME.finalize (MODULENAME.update ctx bs) \-   ; hash  = NAME . MODULENAME.hashlazy+   ; initialCtx      = CTXNAME H.hashInit       \+   ; updateCtx (CTXNAME ctx) = CTXNAME . H.hashUpdate ctx \+   ; finalize (CTXNAME ctx) bs = NAME $ B.convert $ H.hashFinalize (H.hashUpdate ctx bs) \  #define DEFINE_TYPE_AND_INSTANCES_WITHLEN(CTXNAME, NAME, ILEN, MODULENAME, OUTPUTLEN, BLOCKLEN)    \ \-newtype CTXNAME = CTXNAME MODULENAME.Ctx; \-\ data NAME = NAME !ByteString deriving (Eq,Ord,Show); \ \ instance Serialize NAME where \@@ -107,61 +86,88 @@ instance Hash CTXNAME NAME where \    { outputLength    = Tagged (OUTPUTLEN * 8) \    ; blockLength     = Tagged (BLOCKLEN * 8)  \-   ; initialCtx      = CTXNAME (MODULENAME.init ILEN) \-   ; updateCtx (CTXNAME ctx) = CTXNAME . MODULENAME.update ctx      \-   ; finalize (CTXNAME ctx) bs = NAME $ MODULENAME.finalize (MODULENAME.update ctx bs) \-   ; hash  = NAME . MODULENAME.hashlazy OUTPUTLEN+   ; initialCtx      = CTXNAME (H.hashInit) \+   ; updateCtx (CTXNAME ctx) = CTXNAME . H.hashUpdate ctx      \+   ; finalize (CTXNAME ctx) bs = NAME $ B.convert $ H.hashFinalize (H.hashUpdate ctx bs) \  ++newtype CTXMD2 = CTXMD2 (H.Context H.MD2)+newtype CTXMD4 = CTXMD4 (H.Context H.MD4)+newtype CTXMD5 = CTXMD5 (H.Context H.MD5)+newtype CTXSHA1 = CTXSHA1 (H.Context H.SHA1)+newtype CTXSHA224 = CTXSHA224 (H.Context H.SHA224)+newtype CTXSHA256 = CTXSHA256 (H.Context H.SHA256)+newtype CTXSHA384 = CTXSHA384 (H.Context H.SHA384)+newtype CTXSHA512 = CTXSHA512 (H.Context H.SHA512)+newtype CTXRIPEMD160 = CTXRIPEMD160 (H.Context H.RIPEMD160)+newtype CTXTiger = CTXTiger (H.Context H.Tiger)+newtype CTXWhirlpool = CTXWhirlpool (H.Context H.Whirlpool)+newtype CTXSkein256_256 = CTXSkein256_256 (H.Context H.Skein256_256)+newtype CTXSkein512_512 = CTXSkein512_512 (H.Context H.Skein512_512)+ DEFINE_TYPE_AND_INSTANCES_SIMPLE(CTXMD2, MD2, 16, 16)-   ; hash' = MD2 . MD2.hash+   ; hash  = MD2 . B.convert . (H.hashlazy :: L.ByteString -> H.Digest H.MD2)+   ; hash' = MD2 . B.convert . (H.hashWith H.MD2)    };  DEFINE_TYPE_AND_INSTANCES_SIMPLE(CTXMD4, MD4, 16, 64)-   ; hash' = MD4 . MD4.hash+   ; hash = MD4 . B.convert . (H.hashlazy :: L.ByteString -> H.Digest H.MD4)+   ; hash' = MD4 . B.convert . (H.hashWith H.MD4)    };  DEFINE_TYPE_AND_INSTANCES_SIMPLE(CTXMD5, MD5, 16, 64)-   ; hash' = MD5 . MD5.hash+   ; hash = MD5 . B.convert . (H.hashlazy :: L.ByteString -> H.Digest H.MD5)+   ; hash' = MD5 . B.convert . (H.hashWith H.MD5)    };  DEFINE_TYPE_AND_INSTANCES_SIMPLE(CTXSHA1, SHA1, 20, 64)-   ; hash' = SHA1 . SHA1.hash+   ; hash = SHA1 . B.convert . (H.hashlazy :: L.ByteString -> H.Digest H.SHA1)+   ; hash' = SHA1 . B.convert . (H.hashWith H.SHA1)    };  DEFINE_TYPE_AND_INSTANCES_SIMPLE(CTXSHA224, SHA224, 28, 64)-   ; hash' = SHA224 . SHA224.hash+   ; hash = SHA224 . B.convert . (H.hashlazy :: L.ByteString -> H.Digest H.SHA224)+   ; hash' = SHA224 . B.convert . (H.hashWith H.SHA224)    };  DEFINE_TYPE_AND_INSTANCES_SIMPLE(CTXSHA256, SHA256, 32, 64)-   ; hash' = SHA256 . SHA256.hash+   ; hash = SHA256 . B.convert . (H.hashlazy :: L.ByteString -> H.Digest H.SHA256)+   ; hash' = SHA256 . B.convert . (H.hashWith H.SHA256)    };  DEFINE_TYPE_AND_INSTANCES_SIMPLE(CTXSHA384, SHA384, 48, 128)-   ; hash' = SHA384 . SHA384.hash+   ; hash = SHA384 . B.convert . (H.hashlazy :: L.ByteString -> H.Digest H.SHA384)+   ; hash' = SHA384 . B.convert . (H.hashWith H.SHA384)    };  DEFINE_TYPE_AND_INSTANCES_SIMPLE(CTXSHA512, SHA512, 64, 128)-   ; hash' = SHA512 . SHA512.hash+   ; hash = SHA512 . B.convert . (H.hashlazy :: L.ByteString -> H.Digest H.SHA512)+   ; hash' = SHA512 . B.convert . (H.hashWith H.SHA512)    };  DEFINE_TYPE_AND_INSTANCES_SIMPLE(CTXRIPEMD160, RIPEMD160, 20, 64)-   ; hash' = RIPEMD160 . RIPEMD160.hash+   ; hash = RIPEMD160 . B.convert . (H.hashlazy :: L.ByteString -> H.Digest H.RIPEMD160)+   ; hash' = RIPEMD160 . B.convert . (H.hashWith H.RIPEMD160)    };  DEFINE_TYPE_AND_INSTANCES_SIMPLE(CTXTiger, Tiger, 24, 64)-   ; hash' = Tiger . Tiger.hash+   ; hash = Tiger . B.convert . (H.hashlazy :: L.ByteString -> H.Digest H.Tiger)+   ; hash' = Tiger . B.convert . (H.hashWith H.Tiger)    };  DEFINE_TYPE_AND_INSTANCES_SIMPLE(CTXWhirlpool, Whirlpool, 64, 64)-   ; hash' = Whirlpool . Whirlpool.hash+   ; hash = Whirlpool . B.convert . (H.hashlazy :: L.ByteString -> H.Digest H.Whirlpool)+   ; hash' = Whirlpool . B.convert . (H.hashWith H.Whirlpool)    };  DEFINE_TYPE_AND_INSTANCES_WITHLEN(CTXSkein256_256, Skein256_256, 256, Skein256, 32, 32)-   ; hash' = Skein256_256 . Skein256.hash 32+   ; hash = Skein256_256 . B.convert . (H.hashlazy :: L.ByteString -> H.Digest H.Skein256_256)+   ; hash' = Skein256_256 . B.convert . (H.hashWith H.Skein256_256)    };  DEFINE_TYPE_AND_INSTANCES_WITHLEN(CTXSkein512_512, Skein512_512, 512, Skein512, 64, 64)-   ; hash' = Skein512_512 . Skein512.hash 64+   ; hash = Skein512_512 . B.convert . (H.hashlazy :: L.ByteString -> H.Digest H.Skein512_512)+   ; hash' = Skein512_512 . B.convert . (H.hashWith H.Skein512_512)    }; 
cryptohash-cryptoapi.cabal view
@@ -1,5 +1,5 @@ Name:                cryptohash-cryptoapi-Version:             0.1.3+Version:             0.1.4 Description:         Crypto-api interfaces for cryptohash License:             BSD3 License-file:        LICENSE@@ -10,13 +10,14 @@ Category:            Cryptography Build-Type:          Simple Cabal-Version:       >=1.6-Homepage:            http://github.com/vincenthz/hs-cryptohash-cryptoapi+Homepage:            https://github.com/vincenthz/hs-cryptohash-cryptoapi data-files:          README.md  Library   Build-Depends:     base >= 4 && < 6                    , bytestring-                   , cryptohash >= 0.8.0+                   , memory+                   , cryptonite >= 0.13                    , crypto-api >= 0.11                    , tagged >= 0.1                    , cereal >= 0.2@@ -24,4 +25,4 @@  source-repository head   type:     git-  location: git://github.com/vincenthz/hs-cryptohash-cryptoapi+  location: https://github.com/vincenthz/hs-cryptohash-cryptoapi