Class Poco::Crypto::ECKey
Author: Applied Informatics Software Engineering GmbH and Contributors

# Poco::Crypto

# class ECKey

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: getCurveName, impl

Inherited Functions: impl, name, 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 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

~ECKey();

Destroys the ECKey.

## Member Functions

### getCurveName

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;

### impl

ECKeyImpl::Ptr impl() const;

Returns the impl object.