Codec.Encryption.PKCS1
Description
This module implements RSA encryption with PKCS1 padding.
- encrypt :: RandomGen g => Int -> PublicKey -> g -> ByteString -> ByteString
- decrypt :: Int -> PrivateKey -> ByteString -> Maybe ByteString
- data PublicKey = PublicKey {}
- newtype PrivateKey = PrivateKey (Either PrivateKeySimple PrivateKeyComplex)
- data PrivateKeyComplex = PrivateKeyComplex {}
- data PrivateKeySimple = PrivateKeySimple {}
- os2ip :: (Bits a, Integral a) => ByteString -> a
- i2osp :: (Bits a, Integral a) => Int -> a -> ByteString
Documentation
Arguments
:: RandomGen g | |
=> Int | Size of the modulus in bytes |
-> PublicKey | The public key to use |
-> g | The padding is random, so we just need this |
-> ByteString | The string to encrypt |
-> ByteString |
Encrypts a ByteString using RSA with PKCS1 padding
Arguments
:: Int | Size of the modulus in bytes |
-> PrivateKey | The private key to use |
-> ByteString | The string to decrypt |
-> Maybe ByteString |
Decrypts a ByteString using RSA with PKCS1 padding. If the ByteString couldn't be decrypted, nothing is returned.
The public key is contained in a certificate.
newtype PrivateKey Source
Constructors
PrivateKey (Either PrivateKeySimple PrivateKeyComplex) |
data PrivateKeyComplex Source
This private key variant is considerably faster.
Constructors
PrivateKeyComplex | |
Instances
data PrivateKeySimple Source
This private key variant takes longer to decrypt.
Constructors
PrivateKeySimple | |
Instances
os2ip :: (Bits a, Integral a) => ByteString -> aSource
Converts a block of bytes into a number