diff --git a/Crypto/KDF/PBKDF2.hs b/Crypto/KDF/PBKDF2.hs index 7a3337c..027086e 100644 --- a/Crypto/KDF/PBKDF2.hs +++ b/Crypto/KDF/PBKDF2.hs @@ -54,7 +54,7 @@ data Parameters = Parameters } -- | generate the pbkdf2 key derivation function from the output -generate :: (ByteArrayAccess salt, ByteArray ba) +generate :: (ByteArrayAccess password, ByteArrayAccess salt, ByteArray ba) => PRF password -> Parameters -> password diff --git a/Crypto/Number/Serialize.hs b/Crypto/Number/Serialize.hs index 9855c5b..858e848 100644 --- a/Crypto/Number/Serialize.hs +++ b/Crypto/Number/Serialize.hs @@ -35,6 +35,7 @@ i2osp m = B.allocAndFreeze sz (\p -> Internal.i2osp m p sz >> return ()) -- | Just like 'i2osp', but takes an extra parameter for size. -- If the number is too big to fit in @len@ bytes, 'Nothing' is returned -- otherwise the number is padded with 0 to fit the @len@ required. +{-# INLINABLE i2ospOf #-} i2ospOf :: B.ByteArray ba => Int -> Integer -> Maybe ba i2ospOf len m | len <= 0 = Nothing diff --git a/Crypto/OTP.hs b/Crypto/OTP.hs index 9b5b383..44503ff 100644 --- a/Crypto/OTP.hs +++ b/Crypto/OTP.hs @@ -129,8 +129,8 @@ defaultTOTPParams :: TOTPParams SHA1 defaultTOTPParams = TP SHA1 0 30 OTP6 TwoSteps -- | Create a TOTP configuration with customized parameters. -mkTOTPParams :: - hash +mkTOTPParams :: (HashAlgorithm hash) + => hash -> OTPTime -- ^ The T0 parameter in seconds. This is the Unix time from which to start -- counting steps (default 0). Must be before the current time. diff --git a/Crypto/Random/Types.hs b/Crypto/Random/Types.hs index 2806fc3..961be8a 100644 --- a/Crypto/Random/Types.hs +++ b/Crypto/Random/Types.hs @@ -56,5 +56,5 @@ instance DRG gen => MonadRandom (MonadPseudoRandom gen) where -- | Run a pure computation with a Deterministic Random Generator -- in the 'MonadPseudoRandom' -withDRG :: gen -> MonadPseudoRandom gen a -> (a, gen) +withDRG :: DRG gen => gen -> MonadPseudoRandom gen a -> (a, gen) withDRG gen m = runPseudoRandom m gen diff --git a/tests/BlockCipher.hs b/tests/BlockCipher.hs index 38adcb2..2fc1248 100644 --- a/tests/BlockCipher.hs +++ b/tests/BlockCipher.hs @@ -307,7 +307,7 @@ generateIvAEAD :: Gen B.ByteString generateIvAEAD = choose (12,90) >>= \sz -> (B.pack <$> replicateM sz arbitrary) -- | Generate a plaintext multiple of blocksize bytes -generatePlaintextMultipleBS :: Gen (PlaintextBS a) +generatePlaintextMultipleBS :: BlockCipher a => Gen (PlaintextBS a) generatePlaintextMultipleBS = choose (1,128) >>= \size -> replicateM (size * 16) arbitrary >>= return . PlaintextBS . B.pack -- | Generate any sized plaintext @@ -474,7 +474,7 @@ testBlockCipher kats cipher = testGroup (cipherName cipher) ++ testModes cipher ++ testIvArith cipher ) -cipherMakeKey :: cipher -> ByteString -> Key cipher +cipherMakeKey :: Cipher cipher => cipher -> ByteString -> Key cipher cipherMakeKey _ bs = Key bs cipherMakeIV :: BlockCipher cipher => cipher -> ByteString -> IV cipher