| Safe Haskell | None |
|---|---|
| Language | Haskell98 |
OpenSSL.RSA
Description
An interface to RSA public key generator.
- class RSAKey k where
- data RSAPubKey
- data RSAKeyPair
- type RSAGenKeyCallback = Int -> Int -> IO ()
- generateRSAKey :: Int -> Int -> Maybe RSAGenKeyCallback -> IO RSAKeyPair
- generateRSAKey' :: Int -> Int -> IO RSAKeyPair
- rsaD :: RSAKeyPair -> Integer
- rsaP :: RSAKeyPair -> Integer
- rsaQ :: RSAKeyPair -> Integer
- rsaDMP1 :: RSAKeyPair -> Maybe Integer
- rsaDMQ1 :: RSAKeyPair -> Maybe Integer
- rsaIQMP :: RSAKeyPair -> Maybe Integer
- rsaCopyPublic :: RSAKey key => key -> IO RSAPubKey
Type
is either RSAKey aRSAPubKey or RSAKeyPair.
Minimal complete definition
Methods
returns the length of key.rsaSize key
returns the public modulus of the key.rsaN key
returns the public exponent of the key.rsaE key
withRSAPtr :: k -> (Ptr RSA -> IO a) -> IO a Source
Instances
is an opaque object that represents RSA public key.RSAPubKey
data RSAKeyPair Source
is an opaque object that represents RSA keypair.RSAKeyPair
Generating keypair
type RSAGenKeyCallback = Int -> Int -> IO () Source
represents a callback function to get
informed the progress of RSA key generation.RSAGenKeyCallback
callback 0 iis called after generating thei-th potential prime number.- While the number is being tested for primality,
callback 1 jis called after thej-th iteration (j = 0, 1, ...). - When the
n-th randomly generated prime is rejected as not suitable for the key,callback 2 nis called. - When a random
phas been found withp-1 relatively prime toe, it is called ascallback 3 0. - The process is then repeated for prime
qwithcallback 3 1.
Arguments
| :: Int | The number of bits of the public modulus
(i.e. key size). Key sizes with |
| -> Int | The public exponent. It is an odd number, typically 3, 17 or 65537. |
| -> Maybe RSAGenKeyCallback | A callback function. |
| -> IO RSAKeyPair | The generated keypair. |
generates an RSA keypair.generateRSAKey
Arguments
| :: Int | The number of bits of the public modulus
(i.e. key size). Key sizes with |
| -> 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 :: RSAKeyPair -> Integer Source
returns the private exponent of the key.rsaD privKey
rsaP :: RSAKeyPair -> Integer Source
returns the secret prime factor rsaP privkeyp of the key.
rsaQ :: RSAKeyPair -> Integer Source
returns the secret prime factor rsaQ privkeyq of the key.
rsaCopyPublic :: RSAKey key => key -> IO RSAPubKey Source
Make a copy of the public parameters of the given key.