Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
An interface to RSA public key generator.
Synopsis
- class RSAKey k where
- rsaSize :: k -> Int
- rsaN :: k -> Integer
- rsaE :: k -> Integer
- withRSAPtr :: k -> (Ptr RSA -> IO a) -> IO a
- peekRSAPtr :: Ptr RSA -> IO (Maybe k)
- absorbRSAPtr :: Ptr RSA -> IO (Maybe k)
- 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
.
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 #
peekRSAPtr :: Ptr RSA -> IO (Maybe k) Source #
absorbRSAPtr :: Ptr RSA -> IO (Maybe k) Source #
Instances
RSAKey RSAKeyPair Source # | |
Defined in OpenSSL.RSA rsaSize :: RSAKeyPair -> Int Source # rsaN :: RSAKeyPair -> Integer Source # rsaE :: RSAKeyPair -> Integer Source # withRSAPtr :: RSAKeyPair -> (Ptr RSA -> IO a) -> IO a Source # peekRSAPtr :: Ptr RSA -> IO (Maybe RSAKeyPair) Source # absorbRSAPtr :: Ptr RSA -> IO (Maybe RSAKeyPair) Source # | |
RSAKey RSAPubKey Source # | |
Defined in OpenSSL.RSA |
is an opaque object that represents RSA public key.RSAPubKey
Instances
PKey RSAPubKey Source # | |
PublicKey RSAPubKey Source # | |
Defined in OpenSSL.EVP.PKey fromPublicKey :: RSAPubKey -> SomePublicKey Source # toPublicKey :: SomePublicKey -> Maybe RSAPubKey Source # | |
RSAKey RSAPubKey Source # | |
Defined in OpenSSL.RSA | |
Show RSAPubKey Source # | |
Eq RSAPubKey Source # | |
Ord RSAPubKey Source # | |
Defined in OpenSSL.RSA |
data RSAKeyPair Source #
is an opaque object that represents RSA keypair.RSAKeyPair
Instances
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 -> 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.
rsaDMP1 :: RSAKeyPair -> Maybe Integer Source #
returns rsaDMP1
privkeyd mod (p-1)
of the key.
rsaDMQ1 :: RSAKeyPair -> Maybe Integer Source #
returns rsaDMQ1
privkeyd mod (q-1)
of the key.
rsaIQMP :: RSAKeyPair -> Maybe Integer Source #
returns rsaIQMP
privkeyq^-1 mod p
of the key.
rsaCopyPublic :: RSAKey key => key -> IO RSAPubKey Source #
Make a copy of the public parameters of the given key.