leekspin.rsa

OpenSSL RSA key utilities.

exception OpenSSLKeyGenError[source]

Bases: exceptions.Exception

Raised when there is a problem generating a new key.

createRSAKey(bits=1024)[source]

Create a new RSA keypair.

The current keysize for OR RSA keys is 1024 bits.

Parameters:bits (int) – The bitlength of the keypair to generate.
Raises OpenSSLKeyGenError:
 If key creation failed.
Return type:OpenSSL.crypto.PKey
Returns:An RSA keypair of bitlength bits.
createKey(selfsign=True, digest='sha1')[source]

Create a set of public and private RSA keypairs and corresponding certs.

Parameters:
  • selfsign (bool) – If True, use the private key to sign the public certificate (otherwise, the private key will only sign the private certificate to which it is attached).
  • digest (str) – The digest to use.
Raises OpenSSLKeyGenError:
 

If key creation failed.

Return type:

4-tuple

Returns:

(private_key, private_cert, public_key, public_cert)