pkcs1-1.0.2: RSA encryption with PKCS1 padding

Codec.Encryption.PKCS1

Description

This module implements RSA encryption with PKCS1 padding.

Synopsis

Documentation

encryptSource

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

decryptSource

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.

data PublicKey Source

The public key is contained in a certificate.

Constructors

PublicKey 

Fields

publicN :: Integer

The modulus

publicE :: Integer

Public exponent

data PrivateKeyComplex Source

This private key variant is considerably faster.

Constructors

PrivateKeyComplex 

Fields

privateN' :: Integer

The modulus

privateD' :: Integer

The private exponent

privateP :: Integer

The first prime number

privateQ :: Integer

The second prime number

privateU :: Integer

Go read a book about it for god sake

data PrivateKeySimple Source

This private key variant takes longer to decrypt.

Constructors

PrivateKeySimple 

Fields

privateN :: Integer

The modulus

privateD :: Integer

Private exponent

os2ip :: (Bits a, Integral a) => ByteString -> aSource

Converts a block of bytes into a number

i2osp :: (Bits a, Integral a) => Int -> a -> ByteStringSource

Converts a number into a block of bytes