From 8b6bd1ed5e30f2ce519569627d9152ff822d1d07 Mon Sep 17 00:00:00 2001 From: Nicolas DI PRIMA Date: Mon, 13 Mar 2017 18:53:07 +0000 Subject: [PATCH] check for at least one byte and at most 256 or 512 (blake2s or blake2b) --- Crypto/Hash/Blake2.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Crypto/Hash/Blake2.hs b/Crypto/Hash/Blake2.hs index b957fa3..d86a0d5 100644 --- a/Crypto/Hash/Blake2.hs +++ b/Crypto/Hash/Blake2.hs @@ -60,7 +60,7 @@ import Crypto.Internal.Nat data Blake2s (bitlen :: Nat) = Blake2s deriving (Show, Typeable) -instance (IsDivisibleBy8 bitlen, KnownNat bitlen) +instance (IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 256) => HashAlgorithm (Blake2s bitlen) where hashBlockSize _ = 64 @@ -92,7 +92,7 @@ foreign import ccall unsafe "cryptonite_blake2s_finalize" data Blake2b (bitlen :: Nat) = Blake2b deriving (Show, Typeable) -instance (IsDivisibleBy8 bitlen, KnownNat bitlen) +instance (IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 512) => HashAlgorithm (Blake2b bitlen) where hashBlockSize _ = 128 @@ -112,7 +112,7 @@ foreign import ccall unsafe "cryptonite_blake2b_finalize" data Blake2sp (bitlen :: Nat) = Blake2sp deriving (Show, Typeable) -instance (IsDivisibleBy8 bitlen, KnownNat bitlen) +instance (IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 256) => HashAlgorithm (Blake2sp bitlen) where hashBlockSize _ = 64 @@ -132,7 +132,7 @@ foreign import ccall unsafe "cryptonite_blake2sp_finalize" data Blake2bp (bitlen :: Nat) = Blake2bp deriving (Show, Typeable) -instance (IsDivisibleBy8 bitlen, KnownNat bitlen) +instance (IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 512) => HashAlgorithm (Blake2bp bitlen) where hashBlockSize _ = 128