Poco::Crypto

class ECKey

File Information

Library: Crypto
Package: EC
Header: Poco/Crypto/ECKey.h

Description

This class stores an EC key pair, consisting of private and public key. Storage of the private key is optional.

If a private key is available, the ECKey can be used for decrypting data (encrypted with the public key) or computing secure digital signatures.

Inheritance

Direct Base Classes: KeyPair

All Base Classes: KeyPair

Member Summary

Member Functions: getCurveNID, getCurveName, hasCurve, impl, operator =

Inherited Functions: impl, name, operator =, save, size, type

Constructors

ECKey

ECKey(
    const EVPPKey & key
);

Constructs ECKeyImpl by extracting the EC key.

ECKey

ECKey(
    const X509Certificate & cert
);

Extracts the EC public key from the given certificate.

ECKey

ECKey(
    const PKCS12Container & cert
);

Extracts the EC private key from the given certificate.

ECKey

ECKey(
    const std::string & eccGroup
);

Creates the ECKey. Creates a new public/private keypair using the given parameters. Can be used to sign data and verify signatures.

ECKey

ECKey(
    const ECKey & key
);

Creates the ECKey by copying another one.

ECKey

ECKey(
    ECKey && key
) noexcept;

Creates the ECKey by moving another one.

ECKey

ECKey(
    const std::string & publicKeyFile,
    const std::string & privateKeyFile,
    const std::string & privateKeyPassphrase = ""
);

Creates the ECKey, by reading public and private key from the given files and using the given passphrase for the private key.

Cannot be used for signing or decryption unless a private key is available.

If a private key is specified, you don't need to specify a public key file. OpenSSL will auto-create the public key from the private key.

ECKey

ECKey(
    std::istream * pPublicKeyStream,
    std::istream * pPrivateKeyStream = 0,
    const std::string & privateKeyPassphrase = ""
);

Creates the ECKey, by reading public and private key from the given streams and using the given passphrase for the private key.

Cannot be used for signing or decryption unless a private key is available.

If a private key is specified, you don't need to specify a public key file. OpenSSL will auto-create the public key from the private key.

Destructor

~ECKey virtual

~ECKey();

Destroys the ECKey.

Member Functions

getCurveNID static inline

static int getCurveNID(
    std::string & name
);

Returns the NID of the specified curve.

If name is empty, returns the first curve NID and updates the name accordingly.

getCurveName static inline

static std::string getCurveName(
    int nid = - 1
);

Returns elliptical curve name corresponding to the given nid; if nid is not found, returns empty string.

If nid is -1, returns first curve name.

If no curves are found, returns empty string;

hasCurve static inline

static bool hasCurve(
    const std::string & name
);

Returns true if the named curve is found, false otherwise.

impl inline

ECKeyImpl::Ptr impl() const;

Returns the impl object.

operator =

ECKey & operator = (
    const ECKey & other
);

Assignment.

operator =

ECKey & operator = (
    ECKey && other
) noexcept;

Move assignment.

Securely control IoT edge devices from anywhere   Connect a Device