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
.
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 i
is called after generating thei
-th potential prime number. - While the number is being tested for primality,
callback 1 j
is 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 n
is called. - When a random
p
has been found withp
-1 relatively prime toe
, it is called ascallback 3 0
. - The process is then repeated for prime
q
withcallback 3 1
.
:: 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
:: 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 -> IntegerSource
returns the private exponent of the key.
rsaD
privKey
rsaP :: RSAKeyPair -> IntegerSource
returns the secret prime factor rsaP
privkeyp
of the key.
rsaQ :: RSAKeyPair -> IntegerSource
returns the secret prime factor rsaQ
privkeyq
of the key.
rsaCopyPublic :: RSAKey key => key -> IO RSAPubKeySource
Make a copy of the public parameters of the given key.