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 the pbkdf2 key derivation function from the output
generate :: (ByteArrayAccess salt, ByteArray ba) generate :: (ByteArrayAccess password, ByteArrayAccess salt, ByteArray ba)
=> PRF password => PRF password
-> Parameters -> Parameters
-> password -> 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. -- | Just like 'i2osp', but takes an extra parameter for size.
-- If the number is too big to fit in @len@ bytes, 'Nothing' is returned -- 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. -- otherwise the number is padded with 0 to fit the @len@ required.
{-# INLINABLE i2ospOf #-}
i2ospOf :: B.ByteArray ba => Int -> Integer -> Maybe ba i2ospOf :: B.ByteArray ba => Int -> Integer -> Maybe ba
i2ospOf len m i2ospOf len m
| len <= 0 = Nothing | len <= 0 = Nothing

View File

@ -129,8 +129,8 @@ defaultTOTPParams :: TOTPParams SHA1
defaultTOTPParams = TP SHA1 0 30 OTP6 TwoSteps defaultTOTPParams = TP SHA1 0 30 OTP6 TwoSteps
-- | Create a TOTP configuration with customized parameters. -- | Create a TOTP configuration with customized parameters.
mkTOTPParams :: mkTOTPParams :: (HashAlgorithm hash)
hash => hash
-> OTPTime -> OTPTime
-- ^ The T0 parameter in seconds. This is the Unix time from which to start -- ^ The T0 parameter in seconds. This is the Unix time from which to start
-- counting steps (default 0). Must be before the current time. -- 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 -- | Run a pure computation with a Deterministic Random Generator
-- in the 'MonadPseudoRandom' -- 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 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) generateIvAEAD = choose (12,90) >>= \sz -> (B.pack <$> replicateM sz arbitrary)
-- | Generate a plaintext multiple of blocksize bytes -- | 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 generatePlaintextMultipleBS = choose (1,128) >>= \size -> replicateM (size * 16) arbitrary >>= return . PlaintextBS . B.pack
-- | Generate any sized plaintext -- | Generate any sized plaintext
@ -474,7 +474,7 @@ testBlockCipher kats cipher = testGroup (cipherName cipher)
++ testModes cipher ++ testIvArith cipher ++ testModes cipher ++ testIvArith cipher
) )
cipherMakeKey :: cipher -> ByteString -> Key cipher cipherMakeKey :: Cipher cipher => cipher -> ByteString -> Key cipher
cipherMakeKey _ bs = Key bs cipherMakeKey _ bs = Key bs
cipherMakeIV :: BlockCipher cipher => cipher -> ByteString -> IV cipher cipherMakeIV :: BlockCipher cipher => cipher -> ByteString -> IV cipher