Add BLAKE2BP512 and BLAKE2BP512E backends
using a blake2 variant optimised for 4-way CPUs This had been deferred because the Debian package of cryptonite, and possibly other builds, was broken for blake2bp, but I've confirmed #892855 is fixed. This commit was sponsored by Brett Eisenberg on Patreon.
This commit is contained in:
parent
9a5ddda511
commit
0c6b7e288d
5 changed files with 26 additions and 4 deletions
|
@ -34,6 +34,7 @@ data Hash
|
|||
| SHA3Hash HashSize
|
||||
| SkeinHash HashSize
|
||||
| Blake2bHash HashSize
|
||||
| Blake2bpHash HashSize
|
||||
| Blake2sHash HashSize
|
||||
| Blake2spHash HashSize
|
||||
|
||||
|
@ -45,6 +46,7 @@ hashes = concat
|
|||
, map (SHA3Hash . HashSize) [256, 512, 224, 384]
|
||||
, map (SkeinHash . HashSize) [256, 512]
|
||||
, map (Blake2bHash . HashSize) [256, 512, 160, 224, 384]
|
||||
, map (Blake2bpHash . HashSize) [512]
|
||||
, map (Blake2sHash . HashSize) [256, 160, 224]
|
||||
, map (Blake2spHash . HashSize) [256, 224]
|
||||
, [SHA1Hash]
|
||||
|
@ -78,6 +80,7 @@ hashKeyVariety (SHA2Hash size) he = SHA2Key size he
|
|||
hashKeyVariety (SHA3Hash size) he = SHA3Key size he
|
||||
hashKeyVariety (SkeinHash size) he = SKEINKey size he
|
||||
hashKeyVariety (Blake2bHash size) he = Blake2bKey size he
|
||||
hashKeyVariety (Blake2bpHash size) he = Blake2bpKey size he
|
||||
hashKeyVariety (Blake2sHash size) he = Blake2sKey size he
|
||||
hashKeyVariety (Blake2spHash size) he = Blake2spKey size he
|
||||
|
||||
|
@ -217,6 +220,7 @@ hashFile hash file meterupdate =
|
|||
SHA3Hash hashsize -> sha3Hasher hashsize
|
||||
SkeinHash hashsize -> skeinHasher hashsize
|
||||
Blake2bHash hashsize -> blake2bHasher hashsize
|
||||
Blake2bpHash hashsize -> blake2bpHasher hashsize
|
||||
Blake2sHash hashsize -> blake2sHasher hashsize
|
||||
Blake2spHash hashsize -> blake2spHasher hashsize
|
||||
|
||||
|
@ -253,6 +257,11 @@ blake2bHasher (HashSize hashsize)
|
|||
| hashsize == 384 = show . blake2b_384
|
||||
| otherwise = error $ "unsupported BLAKE2B size " ++ show hashsize
|
||||
|
||||
blake2bpHasher :: HashSize -> (L.ByteString -> String)
|
||||
blake2bpHasher (HashSize hashsize)
|
||||
| hashsize == 512 = show . blake2bp_512
|
||||
| otherwise = error $ "unsupported BLAKE2BP size " ++ show hashsize
|
||||
|
||||
blake2sHasher :: HashSize -> (L.ByteString -> String)
|
||||
blake2sHasher (HashSize hashsize)
|
||||
| hashsize == 256 = show . blake2s_256
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
* Drop support for building with ghc older than 8.4.4,
|
||||
and with older versions of serveral haskell libraries.
|
||||
* Add BLAKE2BP512 and BLAKE2BP512E backends, using a blake2 variant
|
||||
optimised for 4-way CPUs.
|
||||
|
||||
git-annex (7.20190627) UNRELEASED; urgency=medium
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ data KeyVariety
|
|||
| SHA3Key HashSize HasExt
|
||||
| SKEINKey HashSize HasExt
|
||||
| Blake2bKey HashSize HasExt
|
||||
| Blake2bpKey HashSize HasExt
|
||||
| Blake2sKey HashSize HasExt
|
||||
| Blake2spKey HashSize HasExt
|
||||
| SHA1Key HasExt
|
||||
|
@ -60,6 +61,7 @@ hasExt (SHA2Key _ (HasExt b)) = b
|
|||
hasExt (SHA3Key _ (HasExt b)) = b
|
||||
hasExt (SKEINKey _ (HasExt b)) = b
|
||||
hasExt (Blake2bKey _ (HasExt b)) = b
|
||||
hasExt (Blake2bpKey _ (HasExt b)) = b
|
||||
hasExt (Blake2sKey _ (HasExt b)) = b
|
||||
hasExt (Blake2spKey _ (HasExt b)) = b
|
||||
hasExt (SHA1Key (HasExt b)) = b
|
||||
|
@ -73,6 +75,7 @@ sameExceptExt (SHA2Key sz1 _) (SHA2Key sz2 _) = sz1 == sz2
|
|||
sameExceptExt (SHA3Key sz1 _) (SHA3Key sz2 _) = sz1 == sz2
|
||||
sameExceptExt (SKEINKey sz1 _) (SKEINKey sz2 _) = sz1 == sz2
|
||||
sameExceptExt (Blake2bKey sz1 _) (Blake2bKey sz2 _) = sz1 == sz2
|
||||
sameExceptExt (Blake2bpKey sz1 _) (Blake2bpKey sz2 _) = sz1 == sz2
|
||||
sameExceptExt (Blake2sKey sz1 _) (Blake2sKey sz2 _) = sz1 == sz2
|
||||
sameExceptExt (Blake2spKey sz1 _) (Blake2spKey sz2 _) = sz1 == sz2
|
||||
sameExceptExt (SHA1Key _) (SHA1Key _) = True
|
||||
|
@ -86,6 +89,7 @@ cryptographicallySecure (SHA2Key _ _) = True
|
|||
cryptographicallySecure (SHA3Key _ _) = True
|
||||
cryptographicallySecure (SKEINKey _ _) = True
|
||||
cryptographicallySecure (Blake2bKey _ _) = True
|
||||
cryptographicallySecure (Blake2bpKey _ _) = True
|
||||
cryptographicallySecure (Blake2sKey _ _) = True
|
||||
cryptographicallySecure (Blake2spKey _ _) = True
|
||||
cryptographicallySecure _ = False
|
||||
|
@ -99,6 +103,7 @@ isVerifiable (SHA2Key _ _) = True
|
|||
isVerifiable (SHA3Key _ _) = True
|
||||
isVerifiable (SKEINKey _ _) = True
|
||||
isVerifiable (Blake2bKey _ _) = True
|
||||
isVerifiable (Blake2bpKey _ _) = True
|
||||
isVerifiable (Blake2sKey _ _) = True
|
||||
isVerifiable (Blake2spKey _ _) = True
|
||||
isVerifiable (SHA1Key _) = True
|
||||
|
@ -113,6 +118,7 @@ formatKeyVariety v = case v of
|
|||
SHA3Key sz e -> adde e (addsz sz "SHA3_")
|
||||
SKEINKey sz e -> adde e (addsz sz "SKEIN")
|
||||
Blake2bKey sz e -> adde e (addsz sz "BLAKE2B")
|
||||
Blake2bpKey sz e -> adde e (addsz sz "BLAKE2BP")
|
||||
Blake2sKey sz e -> adde e (addsz sz "BLAKE2S")
|
||||
Blake2spKey sz e -> adde e (addsz sz "BLAKE2SP")
|
||||
SHA1Key e -> adde e "SHA1"
|
||||
|
@ -164,6 +170,8 @@ parseKeyVariety "BLAKE2B384" = Blake2bKey (HashSize 384) (HasExt False)
|
|||
parseKeyVariety "BLAKE2B384E" = Blake2bKey (HashSize 384) (HasExt True)
|
||||
parseKeyVariety "BLAKE2B512" = Blake2bKey (HashSize 512) (HasExt False)
|
||||
parseKeyVariety "BLAKE2B512E" = Blake2bKey (HashSize 512) (HasExt True)
|
||||
parseKeyVariety "BLAKE2BP512" = Blake2bpKey (HashSize 512) (HasExt False)
|
||||
parseKeyVariety "BLAKE2BP512E" = Blake2bpKey (HashSize 512) (HasExt True)
|
||||
parseKeyVariety "BLAKE2S160" = Blake2sKey (HashSize 160) (HasExt False)
|
||||
parseKeyVariety "BLAKE2S160E" = Blake2sKey (HashSize 160) (HasExt True)
|
||||
parseKeyVariety "BLAKE2S224" = Blake2sKey (HashSize 224) (HasExt False)
|
||||
|
|
|
@ -22,6 +22,7 @@ module Utility.Hash (
|
|||
blake2b_256,
|
||||
blake2b_384,
|
||||
blake2b_512,
|
||||
blake2bp_512,
|
||||
md5,
|
||||
prop_hashes_stable,
|
||||
Mac(..),
|
||||
|
@ -99,9 +100,8 @@ blake2b_384 = hashlazy
|
|||
blake2b_512 :: L.ByteString -> Digest Blake2b_512
|
||||
blake2b_512 = hashlazy
|
||||
|
||||
-- Disabled because it's buggy with some versions of cryptonite.
|
||||
--blake2bp_512 :: L.ByteString -> Digest Blake2bp_512
|
||||
--blake2bp_512 = hashlazy
|
||||
blake2bp_512 :: L.ByteString -> Digest Blake2bp_512
|
||||
blake2bp_512 = hashlazy
|
||||
|
||||
md5 :: L.ByteString -> Digest MD5
|
||||
md5 = hashlazy
|
||||
|
@ -130,7 +130,7 @@ prop_hashes_stable = all (\(hasher, result) -> hasher foo == result)
|
|||
, (show . blake2b_256, "b8fe9f7f6255a6fa08f668ab632a8d081ad87983c77cd274e48ce450f0b349fd")
|
||||
, (show . blake2b_384, "e629ee880953d32c8877e479e3b4cb0a4c9d5805e2b34c675b5a5863c4ad7d64bb2a9b8257fac9d82d289b3d39eb9cc2")
|
||||
, (show . blake2b_512, "ca002330e69d3e6b84a46a56a6533fd79d51d97a3bb7cad6c2ff43b354185d6dc1e723fb3db4ae0737e120378424c714bb982d9dc5bbd7a0ab318240ddd18f8d")
|
||||
--, (show . blake2bp_512, "")
|
||||
, (show . blake2bp_512, "8ca9ccee7946afcb686fe7556628b5ba1bf9a691da37ca58cd049354d99f37042c007427e5f219b9ab5063707ec6823872dee413ee014b4d02f2ebb6abb5f643")
|
||||
, (show . md5, "acbd18db4cc2f85cedef654fccc4a4d8")
|
||||
]
|
||||
where
|
||||
|
|
|
@ -30,6 +30,9 @@ These are the recommended backends to use.
|
|||
`BLAKE2S160E`, `BLAKE2S224E`, `BLAKE2S256E`
|
||||
-- Fast [Blake2 hash](https://blake2.net/) variants optimised for 32 bit
|
||||
platforms.
|
||||
* `BLAKE2BP512`, `BLAKE2BP512E`
|
||||
-- Fast [Blake2 hash](https://blake2.net/) variants optimised for
|
||||
4-way CPUs.
|
||||
* `BLAKE2SP224`, `BLAKE2SP256`
|
||||
`BLAKE2SP224E`, `BLAKE2SP256E`
|
||||
-- Fast [Blake2 hash](https://blake2.net/) variants optimised for
|
||||
|
|
Loading…
Reference in a new issue