fix build with cryptonite-0.20
Some blake hash varieties were not yet available in that version. Rather than tracking exact details of what cryptonite supported when, disable blake unless using a current cryptonite.
This commit is contained in:
parent
bee328a7fe
commit
521d4ede1e
4 changed files with 25 additions and 1 deletions
|
@ -5,6 +5,8 @@
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Backend.Hash (
|
module Backend.Hash (
|
||||||
backends,
|
backends,
|
||||||
testKeyBackend,
|
testKeyBackend,
|
||||||
|
@ -28,9 +30,11 @@ data Hash
|
||||||
| SHA2Hash HashSize
|
| SHA2Hash HashSize
|
||||||
| SHA3Hash HashSize
|
| SHA3Hash HashSize
|
||||||
| SkeinHash HashSize
|
| SkeinHash HashSize
|
||||||
|
#if MIN_VERSION_cryptonite(0,23,0)
|
||||||
| Blake2bHash HashSize
|
| Blake2bHash HashSize
|
||||||
| Blake2sHash HashSize
|
| Blake2sHash HashSize
|
||||||
| Blake2spHash HashSize
|
| Blake2spHash HashSize
|
||||||
|
#endif
|
||||||
|
|
||||||
{- Order is slightly significant; want SHA256 first, and more general
|
{- Order is slightly significant; want SHA256 first, and more general
|
||||||
- sizes earlier. -}
|
- sizes earlier. -}
|
||||||
|
@ -39,9 +43,11 @@ hashes = concat
|
||||||
[ map (SHA2Hash . HashSize) [256, 512, 224, 384]
|
[ map (SHA2Hash . HashSize) [256, 512, 224, 384]
|
||||||
, map (SHA3Hash . HashSize) [256, 512, 224, 384]
|
, map (SHA3Hash . HashSize) [256, 512, 224, 384]
|
||||||
, map (SkeinHash . HashSize) [256, 512]
|
, map (SkeinHash . HashSize) [256, 512]
|
||||||
|
#if MIN_VERSION_cryptonite(0,23,0)
|
||||||
, map (Blake2bHash . HashSize) [256, 512, 160, 224, 384]
|
, map (Blake2bHash . HashSize) [256, 512, 160, 224, 384]
|
||||||
, map (Blake2sHash . HashSize) [256, 160, 224]
|
, map (Blake2sHash . HashSize) [256, 160, 224]
|
||||||
, map (Blake2spHash . HashSize) [256, 224]
|
, map (Blake2spHash . HashSize) [256, 224]
|
||||||
|
#endif
|
||||||
, [SHA1Hash]
|
, [SHA1Hash]
|
||||||
, [MD5Hash]
|
, [MD5Hash]
|
||||||
]
|
]
|
||||||
|
@ -72,9 +78,11 @@ hashKeyVariety SHA1Hash = SHA1Key
|
||||||
hashKeyVariety (SHA2Hash size) = SHA2Key size
|
hashKeyVariety (SHA2Hash size) = SHA2Key size
|
||||||
hashKeyVariety (SHA3Hash size) = SHA3Key size
|
hashKeyVariety (SHA3Hash size) = SHA3Key size
|
||||||
hashKeyVariety (SkeinHash size) = SKEINKey size
|
hashKeyVariety (SkeinHash size) = SKEINKey size
|
||||||
|
#if MIN_VERSION_cryptonite(0,23,0)
|
||||||
hashKeyVariety (Blake2bHash size) = Blake2bKey size
|
hashKeyVariety (Blake2bHash size) = Blake2bKey size
|
||||||
hashKeyVariety (Blake2sHash size) = Blake2sKey size
|
hashKeyVariety (Blake2sHash size) = Blake2sKey size
|
||||||
hashKeyVariety (Blake2spHash size) = Blake2spKey size
|
hashKeyVariety (Blake2spHash size) = Blake2spKey size
|
||||||
|
#endif
|
||||||
|
|
||||||
{- A key is a hash of its contents. -}
|
{- A key is a hash of its contents. -}
|
||||||
keyValue :: Hash -> KeySource -> Annex (Maybe Key)
|
keyValue :: Hash -> KeySource -> Annex (Maybe Key)
|
||||||
|
@ -177,9 +185,11 @@ hashFile hash file filesize = go hash
|
||||||
go (SHA2Hash hashsize) = usehasher hashsize
|
go (SHA2Hash hashsize) = usehasher hashsize
|
||||||
go (SHA3Hash hashsize) = use (sha3Hasher hashsize)
|
go (SHA3Hash hashsize) = use (sha3Hasher hashsize)
|
||||||
go (SkeinHash hashsize) = use (skeinHasher hashsize)
|
go (SkeinHash hashsize) = use (skeinHasher hashsize)
|
||||||
|
#if MIN_VERSION_cryptonite(0,23,0)
|
||||||
go (Blake2bHash hashsize) = use (blake2bHasher hashsize)
|
go (Blake2bHash hashsize) = use (blake2bHasher hashsize)
|
||||||
go (Blake2sHash hashsize) = use (blake2sHasher hashsize)
|
go (Blake2sHash hashsize) = use (blake2sHasher hashsize)
|
||||||
go (Blake2spHash hashsize) = use (blake2spHasher hashsize)
|
go (Blake2spHash hashsize) = use (blake2spHasher hashsize)
|
||||||
|
#endif
|
||||||
|
|
||||||
use hasher = liftIO $ do
|
use hasher = liftIO $ do
|
||||||
h <- hasher <$> L.readFile file
|
h <- hasher <$> L.readFile file
|
||||||
|
@ -231,6 +241,7 @@ skeinHasher (HashSize hashsize)
|
||||||
| hashsize == 512 = show . skein512
|
| hashsize == 512 = show . skein512
|
||||||
| otherwise = error $ "unsupported SKEIN size " ++ show hashsize
|
| otherwise = error $ "unsupported SKEIN size " ++ show hashsize
|
||||||
|
|
||||||
|
#if MIN_VERSION_cryptonite(0,23,0)
|
||||||
blake2bHasher :: HashSize -> (L.ByteString -> String)
|
blake2bHasher :: HashSize -> (L.ByteString -> String)
|
||||||
blake2bHasher (HashSize hashsize)
|
blake2bHasher (HashSize hashsize)
|
||||||
| hashsize == 256 = show . blake2b_256
|
| hashsize == 256 = show . blake2b_256
|
||||||
|
@ -252,6 +263,7 @@ blake2spHasher (HashSize hashsize)
|
||||||
| hashsize == 256 = show . blake2sp_256
|
| hashsize == 256 = show . blake2sp_256
|
||||||
| hashsize == 224 = show . blake2sp_224
|
| hashsize == 224 = show . blake2sp_224
|
||||||
| otherwise = error $ "unsupported BLAKE2SP size " ++ show hashsize
|
| otherwise = error $ "unsupported BLAKE2SP size " ++ show hashsize
|
||||||
|
#endif
|
||||||
|
|
||||||
md5Hasher :: L.ByteString -> String
|
md5Hasher :: L.ByteString -> String
|
||||||
md5Hasher = show . md5
|
md5Hasher = show . md5
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Types.Key where
|
module Types.Key where
|
||||||
|
|
||||||
import Utility.PartialPrelude
|
import Utility.PartialPrelude
|
||||||
|
@ -125,6 +127,7 @@ parseKeyVariety "SKEIN512" = SKEINKey (HashSize 512) (HasExt False)
|
||||||
parseKeyVariety "SKEIN512E" = SKEINKey (HashSize 512) (HasExt True)
|
parseKeyVariety "SKEIN512E" = SKEINKey (HashSize 512) (HasExt True)
|
||||||
parseKeyVariety "SKEIN256" = SKEINKey (HashSize 256) (HasExt False)
|
parseKeyVariety "SKEIN256" = SKEINKey (HashSize 256) (HasExt False)
|
||||||
parseKeyVariety "SKEIN256E" = SKEINKey (HashSize 256) (HasExt True)
|
parseKeyVariety "SKEIN256E" = SKEINKey (HashSize 256) (HasExt True)
|
||||||
|
#if MIN_VERSION_cryptonite(0,23,0)
|
||||||
parseKeyVariety "BLAKE2B160" = Blake2bKey (HashSize 160) (HasExt False)
|
parseKeyVariety "BLAKE2B160" = Blake2bKey (HashSize 160) (HasExt False)
|
||||||
parseKeyVariety "BLAKE2B160E" = Blake2bKey (HashSize 160) (HasExt True)
|
parseKeyVariety "BLAKE2B160E" = Blake2bKey (HashSize 160) (HasExt True)
|
||||||
parseKeyVariety "BLAKE2B224" = Blake2bKey (HashSize 224) (HasExt False)
|
parseKeyVariety "BLAKE2B224" = Blake2bKey (HashSize 224) (HasExt False)
|
||||||
|
@ -145,6 +148,7 @@ parseKeyVariety "BLAKE2SP224" = Blake2spKey (HashSize 224) (HasExt False)
|
||||||
parseKeyVariety "BLAKE2SP224E" = Blake2spKey (HashSize 224) (HasExt True)
|
parseKeyVariety "BLAKE2SP224E" = Blake2spKey (HashSize 224) (HasExt True)
|
||||||
parseKeyVariety "BLAKE2SP256" = Blake2spKey (HashSize 256) (HasExt False)
|
parseKeyVariety "BLAKE2SP256" = Blake2spKey (HashSize 256) (HasExt False)
|
||||||
parseKeyVariety "BLAKE2SP256E" = Blake2spKey (HashSize 256) (HasExt True)
|
parseKeyVariety "BLAKE2SP256E" = Blake2spKey (HashSize 256) (HasExt True)
|
||||||
|
#endif
|
||||||
parseKeyVariety "SHA1" = SHA1Key (HasExt False)
|
parseKeyVariety "SHA1" = SHA1Key (HasExt False)
|
||||||
parseKeyVariety "SHA1E" = SHA1Key (HasExt True)
|
parseKeyVariety "SHA1E" = SHA1Key (HasExt True)
|
||||||
parseKeyVariety "MD5" = MD5Key (HasExt False)
|
parseKeyVariety "MD5" = MD5Key (HasExt False)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{- Convenience wrapper around cryptonite's hashing. -}
|
{- Convenience wrapper around cryptonite's hashing. -}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Utility.Hash (
|
module Utility.Hash (
|
||||||
sha1,
|
sha1,
|
||||||
sha2_224,
|
sha2_224,
|
||||||
|
@ -12,6 +14,7 @@ module Utility.Hash (
|
||||||
sha3_512,
|
sha3_512,
|
||||||
skein256,
|
skein256,
|
||||||
skein512,
|
skein512,
|
||||||
|
#if MIN_VERSION_cryptonite(0,23,0)
|
||||||
blake2s_160,
|
blake2s_160,
|
||||||
blake2s_224,
|
blake2s_224,
|
||||||
blake2s_256,
|
blake2s_256,
|
||||||
|
@ -22,6 +25,7 @@ module Utility.Hash (
|
||||||
blake2b_256,
|
blake2b_256,
|
||||||
blake2b_384,
|
blake2b_384,
|
||||||
blake2b_512,
|
blake2b_512,
|
||||||
|
#endif
|
||||||
md5,
|
md5,
|
||||||
prop_hashes_stable,
|
prop_hashes_stable,
|
||||||
Mac(..),
|
Mac(..),
|
||||||
|
@ -69,6 +73,7 @@ skein256 = hashlazy
|
||||||
skein512 :: L.ByteString -> Digest Skein512_512
|
skein512 :: L.ByteString -> Digest Skein512_512
|
||||||
skein512 = hashlazy
|
skein512 = hashlazy
|
||||||
|
|
||||||
|
#if MIN_VERSION_cryptonite(0,23,0)
|
||||||
blake2s_160 :: L.ByteString -> Digest Blake2s_160
|
blake2s_160 :: L.ByteString -> Digest Blake2s_160
|
||||||
blake2s_160 = hashlazy
|
blake2s_160 = hashlazy
|
||||||
|
|
||||||
|
@ -98,6 +103,7 @@ blake2b_384 = hashlazy
|
||||||
|
|
||||||
blake2b_512 :: L.ByteString -> Digest Blake2b_512
|
blake2b_512 :: L.ByteString -> Digest Blake2b_512
|
||||||
blake2b_512 = hashlazy
|
blake2b_512 = hashlazy
|
||||||
|
#endif
|
||||||
|
|
||||||
-- Disabled because it's buggy with some versions of cryptonite.
|
-- Disabled because it's buggy with some versions of cryptonite.
|
||||||
--blake2bp_512 :: L.ByteString -> Digest Blake2bp_512
|
--blake2bp_512 :: L.ByteString -> Digest Blake2bp_512
|
||||||
|
@ -120,6 +126,7 @@ prop_hashes_stable = all (\(hasher, result) -> hasher foo == result)
|
||||||
, (show . sha3_256, "76d3bc41c9f588f7fcd0d5bf4718f8f84b1c41b20882703100b9eb9413807c01")
|
, (show . sha3_256, "76d3bc41c9f588f7fcd0d5bf4718f8f84b1c41b20882703100b9eb9413807c01")
|
||||||
, (show . sha3_384, "665551928d13b7d84ee02734502b018d896a0fb87eed5adb4c87ba91bbd6489410e11b0fbcc06ed7d0ebad559e5d3bb5")
|
, (show . sha3_384, "665551928d13b7d84ee02734502b018d896a0fb87eed5adb4c87ba91bbd6489410e11b0fbcc06ed7d0ebad559e5d3bb5")
|
||||||
, (show . sha3_512, "4bca2b137edc580fe50a88983ef860ebaca36c857b1f492839d6d7392452a63c82cbebc68e3b70a2a1480b4bb5d437a7cba6ecf9d89f9ff3ccd14cd6146ea7e7")
|
, (show . sha3_512, "4bca2b137edc580fe50a88983ef860ebaca36c857b1f492839d6d7392452a63c82cbebc68e3b70a2a1480b4bb5d437a7cba6ecf9d89f9ff3ccd14cd6146ea7e7")
|
||||||
|
#if MIN_VERSION_cryptonite(0,23,0)
|
||||||
, (show . blake2s_160, "52fb63154f958a5c56864597273ea759e52c6f00")
|
, (show . blake2s_160, "52fb63154f958a5c56864597273ea759e52c6f00")
|
||||||
, (show . blake2s_224, "9466668503ac415d87b8e1dfd7f348ab273ac1d5e4f774fced5fdb55")
|
, (show . blake2s_224, "9466668503ac415d87b8e1dfd7f348ab273ac1d5e4f774fced5fdb55")
|
||||||
, (show . blake2s_256, "08d6cad88075de8f192db097573d0e829411cd91eb6ec65e8fc16c017edfdb74")
|
, (show . blake2s_256, "08d6cad88075de8f192db097573d0e829411cd91eb6ec65e8fc16c017edfdb74")
|
||||||
|
@ -131,6 +138,7 @@ prop_hashes_stable = all (\(hasher, result) -> hasher foo == result)
|
||||||
, (show . blake2b_384, "e629ee880953d32c8877e479e3b4cb0a4c9d5805e2b34c675b5a5863c4ad7d64bb2a9b8257fac9d82d289b3d39eb9cc2")
|
, (show . blake2b_384, "e629ee880953d32c8877e479e3b4cb0a4c9d5805e2b34c675b5a5863c4ad7d64bb2a9b8257fac9d82d289b3d39eb9cc2")
|
||||||
, (show . blake2b_512, "ca002330e69d3e6b84a46a56a6533fd79d51d97a3bb7cad6c2ff43b354185d6dc1e723fb3db4ae0737e120378424c714bb982d9dc5bbd7a0ab318240ddd18f8d")
|
, (show . blake2b_512, "ca002330e69d3e6b84a46a56a6533fd79d51d97a3bb7cad6c2ff43b354185d6dc1e723fb3db4ae0737e120378424c714bb982d9dc5bbd7a0ab318240ddd18f8d")
|
||||||
--, (show . blake2bp_512, "")
|
--, (show . blake2bp_512, "")
|
||||||
|
#endif
|
||||||
, (show . md5, "acbd18db4cc2f85cedef654fccc4a4d8")
|
, (show . md5, "acbd18db4cc2f85cedef654fccc4a4d8")
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
|
|
|
@ -360,7 +360,7 @@ Executable git-annex
|
||||||
stm-chans,
|
stm-chans,
|
||||||
securemem,
|
securemem,
|
||||||
crypto-api,
|
crypto-api,
|
||||||
cryptonite (>= 0.16),
|
cryptonite,
|
||||||
memory,
|
memory,
|
||||||
split,
|
split,
|
||||||
QuickCheck (>= 2.1),
|
QuickCheck (>= 2.1),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue