HsOpenSSL-0.11.2: Partial OpenSSL binding for Haskell

OpenSSL.RSA

Description

An interface to RSA public key generator.

Synopsis

# Type

class RSAKey k where Source #

RSAKey a is either RSAPubKey or RSAKeyPair.

Minimal complete definition

Methods

rsaSize :: k -> Int Source #

rsaSize key returns the length of key.

rsaN :: k -> Integer Source #

rsaN key returns the public modulus of the key.

rsaE :: k -> Integer Source #

rsaE key returns the public exponent of the key.

withRSAPtr :: k -> (Ptr RSA -> IO a) -> IO a Source #

Instances

 Source # MethodswithRSAPtr :: RSAKeyPair -> (Ptr RSA -> IO a) -> IO a Source # Source # MethodswithRSAPtr :: RSAPubKey -> (Ptr RSA -> IO a) -> IO a Source #

data RSAPubKey Source #

RSAPubKey is an opaque object that represents RSA public key.

Instances

 Source # Methods Source # Methods Source # MethodsshowList :: [RSAPubKey] -> ShowS # Source # MethodswithRSAPtr :: RSAPubKey -> (Ptr RSA -> IO a) -> IO a Source # Source # Methods

RSAKeyPair is an opaque object that represents RSA keypair.

Instances

 Source # Methods Source # Methods Source # MethodsshowList :: [RSAKeyPair] -> ShowS # Source # MethodswithRSAPtr :: RSAKeyPair -> (Ptr RSA -> IO a) -> IO a Source # Source # Methods Source # Methods

# Generating keypair

type RSAGenKeyCallback = Int -> Int -> IO () Source #

RSAGenKeyCallback represents a callback function to get informed the progress of RSA key generation.

• callback 0 i is called after generating the i-th potential prime number.
• While the number is being tested for primality, callback 1 j is called after the j-th iteration (j = 0, 1, ...).
• When the n-th randomly generated prime is rejected as not suitable for the key, callback 2 n is called.
• When a random p has been found with p-1 relatively prime to e, it is called as callback 3 0.
• The process is then repeated for prime q with callback 3 1.

Arguments

 :: Int The number of bits of the public modulus (i.e. key size). Key sizes with n < 1024 should be considered insecure. -> Int The public exponent. It is an odd number, typically 3, 17 or 65537. -> Maybe RSAGenKeyCallback A callback function. -> IO RSAKeyPair The generated keypair.

generateRSAKey generates an RSA keypair.

Arguments

 :: Int The number of bits of the public modulus (i.e. key size). Key sizes with n < 1024 should be considered insecure. -> Int The public exponent. It is an odd number, typically 3, 17 or 65537. -> IO RSAKeyPair The generated keypair.

A simplified alternative to generateRSAKey

# Exploring keypair

rsaD privKey returns the private exponent of the key.

rsaP privkey returns the secret prime factor p of the key.

rsaQ privkey returns the secret prime factor q of the key.

rsaDMP1 privkey returns d mod (p-1) of the key.

rsaDMQ1 privkey returns d mod (q-1) of the key.

rsaIQMP privkey returns q^-1 mod p of the key.

rsaCopyPublic :: RSAKey key => key -> IO RSAPubKey Source #

Make a copy of the public parameters of the given key.

# DER encoding

Parse a public key from ASN.1 DER format

toDERPub :: RSAKey k => k -> ByteString Source #

Dump a public key to ASN.1 DER format