ContentsIndex
Codec.Encryption.PKCS1
Description
This module implements RSA encryption with PKCS1 padding.
Synopsis
encrypt :: RandomGen g => Int -> PublicKey -> g -> ByteString -> ByteString
decrypt :: Int -> PrivateKey -> ByteString -> Maybe ByteString
data PublicKey = PublicKey {
publicN :: Integer
publicE :: Integer
}
newtype PrivateKey = PrivateKey (Either PrivateKeySimple PrivateKeyComplex)
data PrivateKeyComplex = PrivateKeyComplex {
privateN' :: Integer
privateD' :: Integer
privateP :: Integer
privateQ :: Integer
privateU :: Integer
}
data PrivateKeySimple = PrivateKeySimple {
privateN :: Integer
privateD :: Integer
}
os2ip :: (Bits a, Integral a) => ByteString -> a
i2osp :: (Bits a, Integral a) => Int -> a -> ByteString
Documentation
encrypt
:: RandomGen g
=> IntSize of the modulus in bytes
-> PublicKeyThe public key to use
-> gThe padding is random, so we just need this
-> ByteStringThe string to encrypt
-> ByteString
Encrypts a ByteString using RSA with PKCS1 padding
decrypt
:: IntSize of the modulus in bytes
-> PrivateKeyThe private key to use
-> ByteStringThe string to decrypt
-> Maybe ByteString
Decrypts a ByteString using RSA with PKCS1 padding. If the ByteString couldn't be decrypted, nothing is returned.
data PublicKey
The public key is contained in a certificate.
Constructors
PublicKey
publicN :: IntegerThe modulus
publicE :: IntegerPublic exponent
show/hide Instances
newtype PrivateKey
Constructors
PrivateKey (Either PrivateKeySimple PrivateKeyComplex)
data PrivateKeyComplex
This private key variant is considerably faster.
Constructors
PrivateKeyComplex
privateN' :: IntegerThe modulus
privateD' :: IntegerThe private exponent
privateP :: IntegerThe first prime number
privateQ :: IntegerThe second prime number
privateU :: IntegerGo read a book about it for god sake
show/hide Instances
data PrivateKeySimple
This private key variant takes longer to decrypt.
Constructors
PrivateKeySimple
privateN :: IntegerThe modulus
privateD :: IntegerPrivate exponent
show/hide Instances
os2ip :: (Bits a, Integral a) => ByteString -> a
Converts a block of bytes into a number
i2osp :: (Bits a, Integral a) => Int -> a -> ByteString
Converts a number into a block of bytes
Produced by Haddock version 0.8