Package Crypto :: Package PublicKey :: Module RSA :: Class _RSAobj
[hide private]
[frames] | no frames]

Class _RSAobj

pubkey.pubkey --+
                |
               _RSAobj

Class defining an actual RSA key.
Instance Methods [hide private]
 
__init__(self, implementation, key, randfunc=None)
 
__getattr__(self, attrname)
 
_encrypt(self, c, K)
 
_decrypt(self, c)
 
_blind(self, m, r)
 
_unblind(self, m, r)
 
_sign(self, m, K=None)
 
_verify(self, m, sig)
 
has_private(self)
has_private() : bool Return a Boolean denoting whether the object contains private components.
 
size(self)
size() : int Return the maximum number of bits that can be handled by this key.
 
can_blind(self)
can_blind() : bool Return a Boolean value recording whether this algorithm can blind data. (This does not imply that this particular key object has the private information required to to blind a message.)
 
can_encrypt(self)
can_encrypt() : bool Return a Boolean value recording whether this algorithm can encrypt data. (This does not imply that this particular key object has the private information required to to decrypt a message.)
 
can_sign(self)
can_sign() : bool Return a Boolean value recording whether this algorithm can generate signatures. (This does not imply that this particular key object has the private information required to to generate a signature.)
 
publickey(self)
publickey(): object Return a new key object containing only the public information.
 
__getstate__(self)
To keep key objects platform-independent, the key data is converted to standard Python long integers before being written out. It will then be reconverted as necessary on restoration.
 
__setstate__(self, d)
On unpickling a key object, the key data is converted to the big number representation being used, whether that is Python long integers, MPZ objects, or whatever.
 
__repr__(self)
 
exportKey(self, format='PEM', passphrase=None, pkcs=1)
Export this RSA key.

Inherited from pubkey.pubkey: __eq__, __ne__, blind, decrypt, encrypt, sign, unblind, validate, verify

Class Variables [hide private]
  keydata = ['n', 'e', 'd', 'p', 'q', 'u']
Dictionary of RSA parameters.
Method Details [hide private]

__init__(self, implementation, key, randfunc=None)
(Constructor)

 
Overrides: pubkey.pubkey.__init__

has_private(self)

 
has_private() : bool Return a Boolean denoting whether the object contains private components.
Overrides: pubkey.pubkey.has_private
(inherited documentation)

size(self)

 
size() : int Return the maximum number of bits that can be handled by this key.
Overrides: pubkey.pubkey.size
(inherited documentation)

can_blind(self)

 
can_blind() : bool Return a Boolean value recording whether this algorithm can blind data. (This does not imply that this particular key object has the private information required to to blind a message.)
Overrides: pubkey.pubkey.can_blind
(inherited documentation)

can_encrypt(self)

 
can_encrypt() : bool Return a Boolean value recording whether this algorithm can encrypt data. (This does not imply that this particular key object has the private information required to to decrypt a message.)
Overrides: pubkey.pubkey.can_encrypt
(inherited documentation)

can_sign(self)

 
can_sign() : bool Return a Boolean value recording whether this algorithm can generate signatures. (This does not imply that this particular key object has the private information required to to generate a signature.)
Overrides: pubkey.pubkey.can_sign
(inherited documentation)

publickey(self)

 
publickey(): object Return a new key object containing only the public information.
Overrides: pubkey.pubkey.publickey
(inherited documentation)

__getstate__(self)

 
To keep key objects platform-independent, the key data is converted to standard Python long integers before being written out. It will then be reconverted as necessary on restoration.
Overrides: pubkey.pubkey.__getstate__
(inherited documentation)

__setstate__(self, d)

 
On unpickling a key object, the key data is converted to the big number representation being used, whether that is Python long integers, MPZ objects, or whatever.
Overrides: pubkey.pubkey.__setstate__
(inherited documentation)

exportKey(self, format='PEM', passphrase=None, pkcs=1)

 
Export this RSA key.
Parameters:
  • format (string) - The format to use for wrapping the key.

    • 'DER'. Binary encoding, always unencrypted.
    • 'PEM'. Textual encoding, done according to RFC1421/3. Unencrypted (default) or encrypted.
    • 'OpenSSH'. Textual encoding, done according to OpenSSH specification. Only suitable for public keys (not private keys).
  • passphrase (string) - In case of PEM, the pass phrase to derive the encryption key from.
  • pkcs (integer) - The PKCS standard to follow for encoding the key. You have two choices: 1 (PKCS#1, RFC3447) or 8 (PKCS#8, RFC5208). PKCS#8 is only available for private keys. PKCS#1 is the default. PKCS standards are not relevant for the OpenSSH format.
Returns:
A string with the encoded public or private half.
Raises:
  • ValueError - When the format is unknown.

Class Variable Details [hide private]

keydata

Dictionary of RSA parameters.

A public key will only have the following entries:

  • n, the modulus.
  • e, the public exponent.

A private key will also have:

  • d, the private exponent.
  • p, the first factor of n.
  • q, the second factor of n.
  • u, the CRT coefficient (1/p) mod q.
Value:
['n', 'e', 'd', 'p', 'q', 'u']