From f6c1f21e598c7a9aef575a87da9b967bb3198a0e Mon Sep 17 00:00:00 2001 From: Fraser Tweedale Date: Mon, 26 Jun 2017 19:44:31 +1000 Subject: [PATCH] clarify padding requirements for PKCS15 encrypt/decrypt The types do not say whether it is necessary to apply pad/unpad to the input/output of the PKCS15 encrypt/decrypt functions. Add comments to clarify that it is not necessary to manually pad/unpad the message. --- Crypto/PubKey/RSA/PKCS15.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Crypto/PubKey/RSA/PKCS15.hs b/Crypto/PubKey/RSA/PKCS15.hs index 4c9a04d..a6c7286 100644 --- a/Crypto/PubKey/RSA/PKCS15.hs +++ b/Crypto/PubKey/RSA/PKCS15.hs @@ -137,6 +137,8 @@ unpad packed -- information from the timing of the operation, the blinder can be set to None. -- -- If unsure always set a blinder or use decryptSafer +-- +-- The message is returned un-padded. decrypt :: Maybe Blinder -- ^ optional blinder -> PrivateKey -- ^ RSA private key -> ByteString -- ^ cipher text @@ -156,7 +158,8 @@ decryptSafer pk b = do -- | encrypt a bytestring using the public key. -- --- the message needs to be smaller than the key size - 11 +-- The message needs to be smaller than the key size - 11. +-- The message should not be padded. encrypt :: MonadRandom m => PublicKey -> ByteString -> m (Either Error ByteString) encrypt pk m = do r <- pad (public_size pk) m