Package M2Crypto :: Module RSA
[frames] | no frames]

Module RSA



M2Crypto wrapper for OpenSSL RSA API.

Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved.

Classes
  RSAError
  RSA
RSA Key Pair.
  RSA_pub
Object interface to an RSA public key.
Functions
 
rsa_error()
 
keygen_callback(p, n, out=sys.stdout)
Default callback for gen_key().
M2Crypto.RSA.RSA
gen_key(bits, e, callback=<function keygen_callback at 0x83c3bfc>)
Generate an RSA key pair.
M2Crypto.RSA.RSA
load_key(file, callback=<function passphrase_callback at 0x83b2a04>)
Load an RSA key pair from file.
M2Crypto.RSA.RSA
load_key_bio(bio, callback=<function passphrase_callback at 0x83b2a04>)
Load an RSA key pair from an M2Crypto.BIO.BIO object.
M2Crypto.RSA.RSA
load_key_string(string, callback=<function passphrase_callback at 0x83b2a04>)
Load an RSA key pair from a string.
M2Crypto.RSA.RSA_pub
load_pub_key(file)
Load an RSA public key from file.
M2Crypto.RSA.RSA_pub
load_pub_key_bio(bio)
Load an RSA public key from an M2Crypto.BIO.BIO object.
M2Crypto.RSA.RSA_pub
new_pub_key((e, n))
Instantiate an RSA_pub object from an (e, n) tuple.
Variables
  no_padding = 3
  pkcs1_padding = 1
  sslv23_padding = 2
  pkcs1_oaep_padding = 4
Function Details

gen_key(bits, e, callback=<function keygen_callback at 0x83c3bfc>)

 

Generate an RSA key pair.

Parameters:
  • bits (int) - Key length, in bits.
  • e (int) - The RSA public exponent.
  • callback (Python callable) - A Python callable object that is invoked during key generation; its usual purpose is to provide visual feedback. The default callback is keygen_callback.
Returns: M2Crypto.RSA.RSA
M2Crypto.RSA.RSA object.

load_key(file, callback=<function passphrase_callback at 0x83b2a04>)

 

Load an RSA key pair from file.

Parameters:
  • file (string) - Name of file containing RSA public key in PEM format.
  • callback (Python callable) - A Python callable object that is invoked to acquire a passphrase with which to unlock the key. The default is util.passphrase_callback.
Returns: M2Crypto.RSA.RSA
M2Crypto.RSA.RSA object.

load_key_bio(bio, callback=<function passphrase_callback at 0x83b2a04>)

 

Load an RSA key pair from an M2Crypto.BIO.BIO object.

Parameters:
  • bio (M2Crypto.BIO.BIO) - M2Crypto.BIO.BIO object containing RSA key pair in PEM format.
  • callback (Python callable) - A Python callable object that is invoked to acquire a passphrase with which to unlock the key. The default is util.passphrase_callback.
Returns: M2Crypto.RSA.RSA
M2Crypto.RSA.RSA object.

load_key_string(string, callback=<function passphrase_callback at 0x83b2a04>)

 

Load an RSA key pair from a string.

Parameters:
  • string (string) - String containing RSA key pair in PEM format.
  • callback (Python callable) - A Python callable object that is invoked to acquire a passphrase with which to unlock the key. The default is util.passphrase_callback.
Returns: M2Crypto.RSA.RSA
M2Crypto.RSA.RSA object.

load_pub_key(file)

 

Load an RSA public key from file.

Parameters:
  • file (string) - Name of file containing RSA public key in PEM format.
Returns: M2Crypto.RSA.RSA_pub
M2Crypto.RSA.RSA_pub object.

load_pub_key_bio(bio)

 

Load an RSA public key from an M2Crypto.BIO.BIO object.

Parameters:
  • bio (M2Crypto.BIO.BIO) - M2Crypto.BIO.BIO object containing RSA public key in PEM format.
Returns: M2Crypto.RSA.RSA_pub
M2Crypto.RSA.RSA_pub object.

new_pub_key((e, n))

 

Instantiate an RSA_pub object from an (e, n) tuple.

Parameters:
  • e (string) - The RSA public exponent; it is a string in OpenSSL's MPINT format - 4-byte big-endian bit-count followed by the appropriate number of bits.
  • n (string) - The RSA composite of primes; it is a string in OpenSSL's MPINT format - 4-byte big-endian bit-count followed by the appropriate number of bits.
Returns: M2Crypto.RSA.RSA_pub
M2Crypto.RSA.RSA_pub object.