Added some redundant constraints for documentation/consistency. Added an INLINABLE pragma to i2ospOf to hopefully increase specializations.

This commit is contained in:
Crockett 2019-02-24 17:04:10 -08:00
parent 0fb8a73d3b
commit 133c6e1b2d
5 changed files with 7 additions and 6 deletions

View File

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

View File

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

View File

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

View File

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

View File

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