packages feed

cryptohash 0.11.8 → 0.11.9

raw patch · 7 files changed

+22/−154 lines, 7 filesdep ~basedep ~cryptonitePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base, cryptonite

API changes (from Hackage documentation)

Files

Crypto/Hash.hs view
@@ -62,11 +62,11 @@     ) where  import Crypto.Hash.Types-import Crypto.Hash.Utils import Data.ByteString (ByteString) import Data.Byteable import Data.Bits (xor) import qualified Data.ByteString as B+import qualified Data.ByteArray.Encoding as B import qualified Data.ByteString.Lazy as L  import qualified "cryptonite" Crypto.Hash as H@@ -91,7 +91,7 @@  -- | Return the hexadecimal (base16) bytestring of the digest digestToHexByteString :: Digest a -> ByteString-digestToHexByteString = toHex . toBytes+digestToHexByteString = B.convertToBase B.Base16 . toBytes  -- | Class representing hashing algorithms. --
Crypto/Hash/SHA3.hs view
@@ -1,5 +1,4 @@ {-# LANGUAGE ForeignFunctionInterface #-}- -- | -- Module      : Crypto.Hash.SHA3 -- License     : BSD-style@@ -9,7 +8,16 @@ -- -- A module containing SHA3 bindings --+-- WARNING: this implementation is not SHA3 as standardize, but+-- SHA3 as submitted before standardisation. also known at the Keccak.+--+-- A matching implementation is available as Keccak in cryptonite+-- for people that are using the pre-standard SHA3.+--+-- do not use.+-- module Crypto.Hash.SHA3+{-# WARNING "this implementation is not SHA3 as standardized, but SHA3 as submitted before standardisation (Keccak)" #-}     ( Ctx(..)      -- * Incremental hashing Functions
− Crypto/Hash/Utils.hs
@@ -1,77 +0,0 @@-{-# LANGUAGE MagicHash, BangPatterns #-}--- |--- Module      : Crypto.Hash.Utils--- License     : BSD-style--- Maintainer  : Vincent Hanquez <vincent@snarc.org>--- Stability   : experimental--- Portability : unknown------ Crypto hash utility for hexadecimal----module Crypto.Hash.Utils-    ( toHex-    ) where--import Data.ByteString (ByteString)-import qualified Data.ByteString.Internal as B-import GHC.Prim-import GHC.Types-import GHC.Word-import Foreign.ForeignPtr (withForeignPtr)-import Foreign.Ptr (plusPtr, castPtr)-import Foreign.Storable (poke, peek)-import Crypto.Hash.Utils.Cpu-import Data.Bits (testBit)---- | Convert a bytestring to the hexadecimal equivalent--- using 0123456789abcdef as digit-toHex :: ByteString -> ByteString-toHex (B.PS fp off len) = B.unsafeCreate (len*2) $ \d ->-        withForeignPtr fp $ \s -> start d (s `plusPtr` off)-    where start db sb-            | use32Hex && (len `testBit` 0) == False = loop32 db sb-            | otherwise                              = loop8 db sb-                where end            = sb `plusPtr` len-                      -- write the hex output using 32 bits write.-                      loop32 d s-                         | s == end  = return ()-                         | otherwise = do b1 <- fromIntegral `fmap` (peek s :: IO Word8)-                                          b2 <- fromIntegral `fmap` (peek (s `plusPtr` 1) :: IO Word8)-                                          poke (castPtr d) (to32 b1 b2)-                                          loop32 (d `plusPtr` 4) (s `plusPtr` 2)-                      -- write the hex output 8 bits, 2 at a time-                      loop8 d s-                         | s == end  = return ()-                         | otherwise = do b <- fromIntegral `fmap` (peek s :: IO Word8)-                                          poke d               (r tableHi b)-                                          poke (d `plusPtr` 1) (r tableLo b)-                                          loop8 (d `plusPtr` 2) (s `plusPtr` 1)--          -- little endian version-          to32 (I# i1) (I# i2) = W32# (or# (or# (or# hi2 lo2) hi1) lo1)-            where hi2 = uncheckedShiftL# (indexWord8OffAddr# tableLo i2) 24#-                  lo2 = uncheckedShiftL# (indexWord8OffAddr# tableHi i2) 16#-                  hi1 = uncheckedShiftL# (indexWord8OffAddr# tableLo i1) 8#-                  lo1 = indexWord8OffAddr# tableHi i1--          r :: Addr# -> Int -> Word8-          r table (I# index) = W8# (indexWord8OffAddr# table index)--          !tableLo =-                "0123456789abcdef0123456789abcdef\-                \0123456789abcdef0123456789abcdef\-                \0123456789abcdef0123456789abcdef\-                \0123456789abcdef0123456789abcdef\-                \0123456789abcdef0123456789abcdef\-                \0123456789abcdef0123456789abcdef\-                \0123456789abcdef0123456789abcdef\-                \0123456789abcdef0123456789abcdef"#-          !tableHi =-                "00000000000000001111111111111111\-                \22222222222222223333333333333333\-                \44444444444444445555555555555555\-                \66666666666666667777777777777777\-                \88888888888888889999999999999999\-                \aaaaaaaaaaaaaaaabbbbbbbbbbbbbbbb\-                \ccccccccccccccccdddddddddddddddd\-                \eeeeeeeeeeeeeeeeffffffffffffffff"#
− Crypto/Hash/Utils/Cpu.hs
@@ -1,11 +0,0 @@-{-# LANGUAGE CPP #-}-module Crypto.Hash.Utils.Cpu-    ( use32Hex-    ) where--use32Hex :: Bool-#ifdef ARCH_X86-use32Hex = True-#else-use32Hex = False-#endif
README.md view
@@ -3,6 +3,13 @@ you should *not* use this library anymore, and preferably you should convert old projects to `cryptonite` too. +:warning: the SHA3 implementation available in Crypto.Hash.SHA3 is+not SHA3 as standardized by NIST, but Keccak as submitted for the SHA3 contest.+A matching implementation is available as Keccak in `cryptonite`, although I would+recommend not to use unless you happens to really really need your digest value+to be compatible. On the other hand, the centralized `Crypto.Hash` export+a proper SHA3 implementation (as standardized by NIST)+ CryptoHash ========== 
Tests/KAT.hs view
@@ -18,7 +18,6 @@ import qualified Crypto.Hash.SHA384 as SHA384 import qualified Crypto.Hash.SHA512 as SHA512 import qualified Crypto.Hash.SHA512t as SHA512t-import qualified Crypto.Hash.SHA3 as SHA3 import qualified Crypto.Hash.RIPEMD160 as RIPEMD160 import qualified Crypto.Hash.Tiger as Tiger import qualified Crypto.Hash.Skein256 as Skein256@@ -60,8 +59,6 @@ sha512_224Hash = HashFct { fctHash = SHA512t.hash 224, fctInc = hashinc (SHA512t.init 224) SHA512t.update SHA512t.finalize } sha512_256Hash = HashFct { fctHash = SHA512t.hash 256, fctInc = hashinc (SHA512t.init 256) SHA512t.update SHA512t.finalize } -sha3Hash i = HashFct { fctHash = SHA3.hash i, fctInc = hashinc (SHA3.init i) SHA3.update SHA3.finalize }- ripemd160Hash = HashFct { fctHash = RIPEMD160.hash, fctInc = hashinc RIPEMD160.init RIPEMD160.update RIPEMD160.finalize } tigerHash = HashFct { fctHash = Tiger.hash, fctInc = hashinc Tiger.init Tiger.update Tiger.finalize } @@ -149,22 +146,6 @@         "19fa61d75522a4669b44e39c1d2e1726c530232130d407f89afee0964997f7a73e83be698b288febcf88e3e03c4f0757ea8964e59b63d93708b138cc42a66eb3",         "b97de512e91e3828b40d2b0fdce9ceb3c4a71f9bea8d88e75c4fa854df36725fd2b52eb6544edcacd6f8beddfea403cb55ae31f03ad62a5ef54e42ee82c3fb35",         "dce81fc695cfea3d7e1446509238daf89f24cc61896f2d265927daa70f2108f8902f0dfd68be085d5abb9fcd2e482c1dc24f2fabf81f40b73495cad44d7360d3"])-    , ("SHA3-224", sha3Hash 224, [-        "f71837502ba8e10837bdd8d365adb85591895602fc552b48b7390abd",-        "310aee6b30c47350576ac2873fa89fd190cdc488442f3ef654cf23fe",-        "0b27ff3b732133287f6831e2af47cf342b7ef1f3fcdee248811090cd" ])-    , ("SHA3-256", sha3Hash 256, [-        "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",-        "4d741b6f1eb29cb2a9b9911c82f56fa8d73b04959d3d9d222895df6c0b28aa15",-        "ed6c07f044d7573cc53bf1276f8cba3dac497919597a45b4599c8f73e22aa334" ])-    , ("SHA3-384", sha3Hash 384, [-        "2c23146a63a29acf99e73b88f8c24eaa7dc60aa771780ccc006afbfa8fe2479b2dd2b21362337441ac12b515911957ff",-        "283990fa9d5fb731d786c5bbee94ea4db4910f18c62c03d173fc0a5e494422e8a0b3da7574dae7fa0baf005e504063b3",-        "1cc515e1812491058d8b8b226fd85045e746b4937a58b0111b6b7a39dd431b6295bd6b6d05e01e225586b4dab3cbb87a" ])-    , ("SHA3-512", sha3Hash 512, [-        "0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e",-        "d135bb84d0439dbac432247ee573a23ea7d3c9deb2a968eb31d47c4fb45f1ef4422d6c531b5b9bd6f449ebcc449ea94d0a8f05f62130fda612da53c79659f609",-        "10f8caabb5b179861da5e447d34b84d604e3eb81830880e1c2135ffc94580a47cb21f6243ec0053d58b1124d13af2090033659075ee718e0f111bb3f69fb24cf" ])     ]  hexalise s = concatMap (\c -> [ hex $ c `div` 16, hex $ c `mod` 16 ]) s@@ -218,9 +199,6 @@     [ testCase "sha1 api" (runhash sha1Hash B.empty @=? show (hash B.empty :: Digest SHA1))     , testCase "sha256 api" (runhash sha256Hash B.empty @=? show (hash B.empty :: Digest SHA256))     , testCase "sha512 api" (runhash sha512Hash B.empty @=? show (hash B.empty :: Digest SHA512))-    , testCase "sha3-224 api" (runhash (sha3Hash 224) B.empty @=? show (hash B.empty :: Digest SHA3_224))-    , testCase "sha3-256 api" (runhash (sha3Hash 256) B.empty @=? show (hash B.empty :: Digest SHA3_256))-    , testCase "sha3-512 api" (runhash (sha3Hash 512) B.empty @=? show (hash B.empty :: Digest SHA3_512))     ]  @@ -244,34 +222,11 @@     , MACVector "key"   v1      "\xf7\xbc\x83\xf4\x30\x53\x84\x24\xb1\x32\x98\xe6\xaa\x6f\xb1\x43\xef\x4d\x59\xa1\x49\x46\x17\x59\x97\x47\x9d\xbc\x2d\x1a\x3c\xd8"     ] -sha3_key1 = "\x4a\x65\x66\x65"-sha3_data1 = "\x77\x68\x61\x74\x20\x64\x6f\x20\x79\x61\x20\x77\x61\x6e\x74\x20\x66\x6f\x72\x20\x6e\x6f\x74\x68\x69\x6e\x67\x3f"--sha3_224_MAC_Vectors =-    [ MACVector sha3_key1 sha3_data1 "\xe8\x24\xfe\xc9\x6c\x07\x4f\x22\xf9\x92\x35\xbb\x94\x2d\xa1\x98\x26\x64\xab\x69\x2c\xa8\x50\x10\x53\xcb\xd4\x14"-    ]--sha3_256_MAC_Vectors =-    [  MACVector sha3_key1 sha3_data1 "\xaa\x9a\xed\x44\x8c\x7a\xbc\x8b\x5e\x32\x6f\xfa\x6a\x01\xcd\xed\xf7\xb4\xb8\x31\x88\x14\x68\xc0\x44\xba\x8d\xd4\x56\x63\x69\xa1"-    ]--sha3_384_MAC_Vectors =-    [ MACVector sha3_key1 sha3_data1 "\x5a\xf5\xc9\xa7\x7a\x23\xa6\xa9\x3d\x80\x64\x9e\x56\x2a\xb7\x7f\x4f\x35\x52\xe3\xc5\xca\xff\xd9\x3b\xdf\x8b\x3c\xfc\x69\x20\xe3\x02\x3f\xc2\x67\x75\xd9\xdf\x1f\x3c\x94\x61\x31\x46\xad\x2c\x9d"-    ]--sha3_512_MAC_Vectors =-    [ MACVector sha3_key1 sha3_data1 "\xc2\x96\x2e\x5b\xbe\x12\x38\x00\x78\x52\xf7\x9d\x81\x4d\xbb\xec\xd4\x68\x2e\x6f\x09\x7d\x37\xa3\x63\x58\x7c\x03\xbf\xa2\xeb\x08\x59\xd8\xd9\xc7\x01\xe0\x4c\xec\xec\xfd\x3d\xd7\xbf\xd4\x38\xf2\x0b\x8b\x64\x8e\x01\xbf\x8c\x11\xd2\x68\x24\xb9\x6c\xeb\xbd\xcb"-    ]- macTests :: [TestTree] macTests =     [ testGroup "hmac-md5" $ map (toMACTest MD5) $ zip [0..] md5MACVectors     , testGroup "hmac-sha1" $ map (toMACTest SHA1) $ zip [0..] sha1MACVectors     , testGroup "hmac-sha256" $ map (toMACTest SHA256) $ zip [0..] sha256MACVectors-    , testGroup "hmac-sha3-224" $ map (toMACTest SHA3_224) $ zip [0..] sha3_224_MAC_Vectors-    , testGroup "hmac-sha3-256" $ map (toMACTest SHA3_256) $ zip [0..] sha3_256_MAC_Vectors-    , testGroup "hmac-sha3-384" $ map (toMACTest SHA3_384) $ zip [0..] sha3_384_MAC_Vectors-    , testGroup "hmac-sha3-512" $ map (toMACTest SHA3_512) $ zip [0..] sha3_512_MAC_Vectors     ]     where toMACTest hashAlg (i, macVector) =             testCase (show i) (macResult macVector @=? toBytes (hmacAlg hashAlg (macKey macVector) (macSecret macVector)))@@ -281,10 +236,6 @@     [ testGroup "hmac-md5" $ map (toMACTest MD5) $ zip [0..] md5MACVectors     , testGroup "hmac-sha1" $ map (toMACTest SHA1) $ zip [0..] sha1MACVectors     , testGroup "hmac-sha256" $ map (toMACTest SHA256) $ zip [0..] sha256MACVectors-    , testGroup "hmac-sha3-224" $ map (toMACTest SHA3_224) $ zip [0..] sha3_224_MAC_Vectors-    , testGroup "hmac-sha3-256" $ map (toMACTest SHA3_256) $ zip [0..] sha3_256_MAC_Vectors-    , testGroup "hmac-sha3-384" $ map (toMACTest SHA3_384) $ zip [0..] sha3_384_MAC_Vectors-    , testGroup "hmac-sha3-512" $ map (toMACTest SHA3_512) $ zip [0..] sha3_512_MAC_Vectors      , testProperty "hmac-md5" $ prop_inc0 MD5     , testProperty "hmac-md5" $ prop_inc1 MD5@@ -292,14 +243,6 @@     , testProperty "hmac-sha1" $ prop_inc1 SHA1     , testProperty "hmac-sha256" $ prop_inc0 SHA256     , testProperty "hmac-sha256" $ prop_inc1 SHA256-    , testProperty "hmac-sha3-224" $ prop_inc0 SHA3_224-    , testProperty "hmac-sha3-224" $ prop_inc1 SHA3_224-    , testProperty "hmac-sha3-256" $ prop_inc0 SHA3_256-    , testProperty "hmac-sha3-256" $ prop_inc1 SHA3_256-    , testProperty "hmac-sha3-384" $ prop_inc0 SHA3_384-    , testProperty "hmac-sha3-384" $ prop_inc1 SHA3_384-    , testProperty "hmac-sha3-512" $ prop_inc0 SHA3_512-    , testProperty "hmac-sha3-512" $ prop_inc1 SHA3_512     ]     where toMACTest hashAlg (i, macVector) =             testCase (show i) (macResult macVector @=? toBytes (hmacFinalize $ hmacUpdate initCtx (macSecret macVector)))
cryptohash.cabal view
@@ -1,5 +1,5 @@ Name:                cryptohash-Version:             0.11.8+Version:             0.11.9 Description:     DEPRECATED: this library is still fully functional, but please use cryptonite for new projects     and convert old one to use cryptonite. This is where things are at nowadays.@@ -48,7 +48,7 @@   README.md  Library-  Build-Depends:     base >= 4 && < 6, bytestring, byteable, cryptonite, memory, ghc-prim+  Build-Depends:     base >= 4 && < 6, bytestring, byteable, cryptonite >= 0.13, memory, ghc-prim   if impl(ghc >= 7.2.1)     Extensions:      Trustworthy   Extensions:        ForeignFunctionInterface@@ -72,10 +72,8 @@                      Crypto.Hash.Whirlpool                      Crypto.MAC.HMAC                      Crypto.MAC.SHA3-  Other-modules:     Crypto.Hash.Utils-                     Crypto.Hash.Utils.Cpu-                     Crypto.Hash.Internal-  ghc-options:       -Wall -O2 -optc-O3 -fno-cse -fwarn-tabs+  Other-modules:     Crypto.Hash.Internal+  ghc-options:       -Wall -optc-O3 -fno-cse -fwarn-tabs   C-sources:         cbits/sha512.c                      cbits/sha3.c                      cbits/skein256.c