Crypto.PublicKey.RSA
provides facilities for generating new RSA keys,reconstructing them from known components, exporting them, and importing them.mykey.pem
, and then read it back:Crypto.PublicKey.RSA.
generate
(bits, randfunc=None, e=65537)¶Parameters: |
|
---|
RsaKey
, with private key).Crypto.PublicKey.RSA.
construct
(rsa_components, consistency_check=True)¶Parameters: |
|
---|---|
Raises: | ValueError – when the key being imported fails the most basic RSA validity checks. |
RsaKey
).Crypto.PublicKey.RSA.
import_key
(extern_key, passphrase=None)¶Parameters: |
|
---|
RsaKey
).Raises: | ValueError/IndexError/TypeError – When the given key cannot be parsed (possibly because the passphrase is wrong). |
---|
Crypto.PublicKey.RSA.
RsaKey
(**kwargs)¶generate()
, construct()
or import_key()
instead.Variables: |
|
---|
exportKey
(format='PEM', passphrase=None, pkcs=1, protection=None, randfunc=None)¶Parameters: |
|
---|---|
Returns: | the encoded key |
Return type: | byte string |
Raises: | ValueError – when the format is unknown or when you try to encrypt a privatekey with DER format and PKCS#1. |
export_key
(format='PEM', passphrase=None, pkcs=1, protection=None, randfunc=None)¶Parameters: |
|
---|---|
Returns: | the encoded key |
Return type: | byte string |
Raises: | ValueError – when the format is unknown or when you try to encrypt a privatekey with DER format and PKCS#1. |
has_private
()¶publickey
()¶Returns: | a new RsaKey object |
---|
size_in_bits
()¶size_in_bytes
()¶Crypto.PublicKey.RSA.
oid
= '1.2.840.113549.1.1.1'¶