Package M2Crypto :: Module EVP :: Class PKey
[frames] | no frames]

Class PKey



Public Key

Instance Methods
 
m2_pkey_free(...)
 
m2_md_ctx_free(...)
 
__init__(self, pkey=None, _pyfree=0, md='sha1')
 
__del__(self)
 
reset_context(self, md='sha1')
Reset internal message digest context.
 
sign_init(self)
Initialise signing operation with self.
 
sign_update(self, data)
Feed data to signing operation.
string
sign_final(self)
Return signature.
 
update(self, data)
Feed data to signing operation.
string
final(self)
Return signature.
 
verify_init(self)
Initialise signature verification operation with self.
 
verify_update(self, data)
Feed data to verification operation.
int
verify_final(self, sign)
Return result of verification.
int
assign_rsa(self, rsa, capture=1)
Assign the RSA key pair to self.
 
get_rsa(self)
Return the underlying RSA key if that is what the EVP instance is holding.
 
save_key(self, file, cipher='aes_128_cbc', callback=<function passphrase_callback at 0x83b2a04>)
Save the key pair to a file in PEM format.
 
save_key_bio(self, bio, cipher='aes_128_cbc', callback=<function passphrase_callback at 0x83b2a04>)
Save the key pair to the M2Crypto.BIO object 'bio' in PEM format.
 
as_pem(self, cipher='aes_128_cbc', callback=<function passphrase_callback at 0x83b2a04>)
Return key in PEM format in a string.
 
as_der(self)
Return key in DER format in a string
 
size(self)
Return the size of the key in bytes.
 
get_modulus(self)
Return the modulus in hex format.
Method Details

reset_context(self, md='sha1')

 

Reset internal message digest context.

Parameters:
  • md (string) - The message digest algorithm.

sign_update(self, data)

 

Feed data to signing operation.

Parameters:
  • data (string) - Data to be signed.

sign_final(self)

 

Return signature.

Returns: string
The signature.

update(self, data)

 

Feed data to signing operation.

Parameters:
  • data (string) - Data to be signed.

final(self)

 

Return signature.

Returns: string
The signature.

verify_update(self, data)

 

Feed data to verification operation.

Parameters:
  • data (string) - Data to be verified.
Returns:
-1 on Python error, 1 for success, 0 for OpenSSL error

verify_final(self, sign)

 

Return result of verification.

Parameters:
  • sign - Signature to use for verification
Returns: int
Result of verification: 1 for success, 0 for failure, -1 on other error.

assign_rsa(self, rsa, capture=1)

 

Assign the RSA key pair to self.

Parameters:
  • rsa (M2Crypto.RSA.RSA) - M2Crypto.RSA.RSA object to be assigned to self.
  • capture (boolean) - If true (default), this PKey object will own the RSA object, meaning that once the PKey object gets deleted it is no longer safe to use the RSA object.
Returns: int
Return 1 for success and 0 for failure.

save_key(self, file, cipher='aes_128_cbc', callback=<function passphrase_callback at 0x83b2a04>)

 

Save the key pair to a file in PEM format.

Parameters:
  • file (string) - Name of file to save key to.
  • cipher (string) - Symmetric cipher to protect the key. The default cipher is 'aes_128_cbc'. If cipher is None, then the key is saved in the clear.
  • callback (Python callable) - A Python callable object that is invoked to acquire a passphrase with which to protect the key. The default is util.passphrase_callback.

save_key_bio(self, bio, cipher='aes_128_cbc', callback=<function passphrase_callback at 0x83b2a04>)

 

Save the key pair to the M2Crypto.BIO object 'bio' in PEM format.

Parameters:
  • bio (M2Crypto.BIO) - M2Crypto.BIO object to save key to.
  • cipher (string) - Symmetric cipher to protect the key. The default cipher is 'aes_128_cbc'. If cipher is None, then the key is saved in the clear.
  • callback (Python callable) - A Python callable object that is invoked to acquire a passphrase with which to protect the key. The default is util.passphrase_callback.

as_pem(self, cipher='aes_128_cbc', callback=<function passphrase_callback at 0x83b2a04>)

 

Return key in PEM format in a string.

Parameters:
  • cipher (string) - Symmetric cipher to protect the key. The default cipher is 'aes_128_cbc'. If cipher is None, then the key is saved in the clear.
  • callback (Python callable) - A Python callable object that is invoked to acquire a passphrase with which to protect the key. The default is util.passphrase_callback.