Package Cryptodome :: Package PublicKey :: Module ECC :: Class EccKey

Class EccKey

object --+
         |
        EccKey

A private or public key over an Elliptic Curve.
Instance Methods
 
has_private(self)
True if this key can be used for making signatures or decrypting
 
public_key(self)
Create a new EccKey, by retaining only the public components
 
export_key(self, **kwargs)
Export this ECC key.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties
  d
An integer (scalar), representating the private component
  pointQ
An EccPoint, representating the public component

Inherited from object: __class__

Method Details

export_key(self, **kwargs)

 

Export this ECC key.

Parameters:
  • format (string) - The format to use for wrapping the key:

    • 'DER'. The key will be encoded in an ASN.1 DER structure (binary).
    • 'PEM'. The key will be encoded in a PEM envelope (ASCII).
    • 'OpenSSH'. The key will be encoded in the OpenSSH format (ASCII, public keys only).
  • passphrase (byte string or string) - The passphrase to use for protecting the private key. If not provided, the private key will remain in clear form!
  • use_pkcs8 (boolean) - In case of a private key, whether the PKCS#8_ representation should be (internally) used. By default it will.

    Not using PKCS#8 when exporting a private key in password-protected PEM form means that the much weaker and unflexible PEM encryption mechanism will be used. PKCS#8 is therefore always recommended.

  • protection (string) - In case of a private key being exported with password-protection and PKCS#8 (both DER and PEM formats), this parameter MUST be present and be a valid algorithm supported by Cryptodome.IO.PKCS8. It is recommended to use PBKDF2WithHMAC-SHA1AndAES128-CBC.
Returns:
A multi-line string (for PEM and OpenSSH) or bytes (for DER) with the encoded key.

Note: In case of a private key being exported with password-protection and PKCS#8_ (both DER and PEM formats), all additional parameters will be passed to Cryptodome.IO.PKCS8.


Property Details

d

An integer (scalar), representating the private component
Get Method:
unreachable.d(self) - An integer (scalar), representating the private component

pointQ

An EccPoint, representating the public component
Get Method:
unreachable.pointQ(self) - An EccPoint, representating the public component