Poco::Crypto

class ECKeyImpl

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

Description

Elliptic Curve key clas implementation.

Inheritance

Direct Base Classes: KeyPairImpl

All Base Classes: KeyPairImpl, Poco::RefCountedObject

Member Summary

Member Functions: getCurveNID, getCurveName, getECKey, groupId, groupName, hasCurve, save, size

Inherited Functions: duplicate, name, referenceCount, release, save, size, type

Types Aliases

ByteVec

using ByteVec = std::vector < unsigned char >;

Ptr

using Ptr = Poco::AutoPtr < ECKeyImpl >;

Constructors

ECKeyImpl

ECKeyImpl(
    const EVPPKey & key
);

Constructs ECKeyImpl by extracting the EC key.

ECKeyImpl

ECKeyImpl(
    const X509Certificate & cert
);

Constructs ECKeyImpl by extracting the EC public key from the given certificate.

ECKeyImpl

ECKeyImpl(
    const PKCS12Container & cert
);

Constructs ECKeyImpl by extracting the EC private key from the given certificate.

ECKeyImpl

ECKeyImpl(
    int eccGroup
);

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

ECKeyImpl

ECKeyImpl(
    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. Can only by used for signing if a private key is available.

ECKeyImpl

ECKeyImpl(
    std::istream * pPublicKeyStream,
    std::istream * pPrivateKeyStream,
    const std::string & privateKeyPassphrase
);

Creates the ECKey. Can only by used for signing if pPrivKey is not null. If a private key file is specified, you don't need to specify a public key file. OpenSSL will auto-create it from the private key.

Destructor

~ECKeyImpl virtual

~ECKeyImpl();

Destroys the ECKeyImpl.

Member Functions

getCurveNID static

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

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;

getECKey inline

EC_KEY * getECKey();

Returns the OpenSSL EC key.

getECKey

const EC_KEY * getECKey() const;

Returns the OpenSSL EC key.

groupId

int groupId() const;

Returns the EC key group integer Id.

groupName inline

std::string groupName() const;

Returns the EC key group name.

hasCurve static

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

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

save virtual inline

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

Exports the public and private keys to the given files.

If an empty filename is specified, the corresponding key is not exported.

save virtual

void save(
    std::ostream * pPublicKeyStream,
    std::ostream * pPrivateKeyStream = 0,
    const std::string & privateKeyPassphrase = ""
) const;

Exports the public and private key to the given streams.

If a null pointer is passed for a stream, the corresponding key is not exported.

size virtual

int size() const;

Returns the EC key length in bits.