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:
Joey Hess 2019-07-05 15:29:00 -04:00
parent 9a5ddda511
commit 0c6b7e288d
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
5 changed files with 26 additions and 4 deletions

View file

@ -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