Ark Server API (ASE) - Wiki
Loading...
Searching...
No Matches
Poco::Crypto::EVPPKey Class Reference

#include <EVPPKey.h>

Public Member Functions

 EVPPKey (const std::string &ecCurveName)
 
 EVPPKey (const char *ecCurveName)
 
 EVPPKey (EVP_PKEY *pEVPPKey)
 
template<typename K >
 EVPPKey (K *pKey)
 
 EVPPKey (const std::string &publicKeyFile, const std::string &privateKeyFile, const std::string &privateKeyPassphrase="")
 
 EVPPKey (std::istream *pPublicKeyStream, std::istream *pPrivateKeyStream, const std::string &privateKeyPassphrase="")
 
 EVPPKey (const EVPPKey &other)
 
 EVPPKey (EVPPKey &&other) noexcept
 Copy constructor.
 
EVPPKeyoperator= (const EVPPKey &other)
 Move constructor.
 
EVPPKeyoperator= (EVPPKey &&other) noexcept
 Assignment operator.
 
 ~EVPPKey ()
 Assignment move operator.
 
bool operator== (const EVPPKey &other) const
 Destroys the EVPPKey.
 
bool operator!= (const EVPPKey &other) const
 
void save (const std::string &publicKeyFile, const std::string &privateKeyFile="", const std::string &privateKeyPassphrase="") const
 
void save (std::ostream *pPublicKeyStream, std::ostream *pPrivateKeyStream=0, const std::string &privateKeyPassphrase="") const
 
int type () const
 
bool isSupported (int type) const
 Retuns the EVPPKey type NID.
 
 operator const EVP_PKEY * () const
 Returns true if OpenSSL type is supported.
 
 operator EVP_PKEY * ()
 Returns const pointer to the OpenSSL EVP_PKEY structure.
 

Static Public Member Functions

static EVP_PKEYduplicate (const EVP_PKEY *pFromKey, EVP_PKEY **pToKey)
 Returns pointer to the OpenSSL EVP_PKEY structure.
 

Private Types

typedef EVP_PKEY *(* PEM_read_FILE_Key_fn) (FILE *, EVP_PKEY **, pem_password_cb *, void *)
 
typedef EVP_PKEY *(* PEM_read_BIO_Key_fn) (BIO *, EVP_PKEY **, pem_password_cb *, void *)
 
typedef void *(* EVP_PKEY_get_Key_fn) (EVP_PKEY *)
 

Private Member Functions

 EVPPKey ()
 Duplicates pFromKey into *pToKey and returns.
 
void newECKey (const char *group)
 
void duplicate (EVP_PKEY *pEVPPKey)
 
void setKey (ECKey *pKey)
 
void setKey (RSAKey *pKey)
 
void setKey (EC_KEY *pKey)
 
void setKey (RSA *pKey)
 

Static Private Member Functions

static int type (const EVP_PKEY *pEVPPKey)
 
static int passCB (char *buf, int size, int, void *pass)
 
template<typename K , typename F >
static bool loadKey (K **ppKey, PEM_read_FILE_Key_fn readFunc, F getFunc, const std::string &keyFile, const std::string &pass="")
 
template<typename K , typename F >
static bool loadKey (K **ppKey, PEM_read_BIO_Key_fn readFunc, F getFunc, std::istream *pIstr, const std::string &pass="")
 

Private Attributes

EVP_PKEY_pEVPPKey
 

Friends

class ECKeyImpl
 
class RSAKeyImpl
 

Detailed Description

Utility class for conversion of native keys to EVP. Currently, only RSA and EC keys are supported.

Definition at line 41 of file EVPPKey.h.

Member Typedef Documentation

◆ EVP_PKEY_get_Key_fn

typedef void *(* Poco::Crypto::EVPPKey::EVP_PKEY_get_Key_fn) (EVP_PKEY *)
private

Definition at line 155 of file EVPPKey.h.

◆ PEM_read_BIO_Key_fn

typedef EVP_PKEY *(* Poco::Crypto::EVPPKey::PEM_read_BIO_Key_fn) (BIO *, EVP_PKEY **, pem_password_cb *, void *)
private

Definition at line 154 of file EVPPKey.h.

◆ PEM_read_FILE_Key_fn

typedef EVP_PKEY *(* Poco::Crypto::EVPPKey::PEM_read_FILE_Key_fn) (FILE *, EVP_PKEY **, pem_password_cb *, void *)
private

Definition at line 153 of file EVPPKey.h.

Constructor & Destructor Documentation

◆ EVPPKey() [1/9]

Poco::Crypto::EVPPKey::EVPPKey ( const std::string & ecCurveName)
explicit

◆ EVPPKey() [2/9]

Poco::Crypto::EVPPKey::EVPPKey ( const char * ecCurveName)
explicit

Constructs EVPPKey from ECC curve name.

Only EC keys can be wrapped by an EVPPKey created using this constructor.

◆ EVPPKey() [3/9]

Poco::Crypto::EVPPKey::EVPPKey ( EVP_PKEY * pEVPPKey)
explicit

Constructs EVPPKey from ECC curve name.

Only EC keys can be wrapped by an EVPPKey created using this constructor.

◆ EVPPKey() [4/9]

template<typename K >
Poco::Crypto::EVPPKey::EVPPKey ( K * pKey)
inlineexplicit

Constructs EVPPKey from EVP_PKEY pointer. The content behind the supplied pointer is internally duplicated. Constructs EVPPKey from a "native" OpenSSL (RSA or EC_KEY), or a Poco wrapper (RSAKey, ECKey) key pointer.

Definition at line 63 of file EVPPKey.h.

◆ EVPPKey() [5/9]

Poco::Crypto::EVPPKey::EVPPKey ( const std::string & publicKeyFile,
const std::string & privateKeyFile,
const std::string & privateKeyPassphrase = "" )

◆ EVPPKey() [6/9]

Poco::Crypto::EVPPKey::EVPPKey ( std::istream * pPublicKeyStream,
std::istream * pPrivateKeyStream,
const std::string & privateKeyPassphrase = "" )

Creates the EVPPKey, 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.

◆ EVPPKey() [7/9]

Poco::Crypto::EVPPKey::EVPPKey ( const EVPPKey & other)

Creates the EVPPKey. 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.

◆ EVPPKey() [8/9]

Poco::Crypto::EVPPKey::EVPPKey ( EVPPKey && other)
noexcept

Copy constructor.

◆ ~EVPPKey()

Poco::Crypto::EVPPKey::~EVPPKey ( )

Assignment move operator.

◆ EVPPKey() [9/9]

Poco::Crypto::EVPPKey::EVPPKey ( )
private

Duplicates pFromKey into *pToKey and returns.

Member Function Documentation

◆ duplicate() [1/2]

static EVP_PKEY * Poco::Crypto::EVPPKey::duplicate ( const EVP_PKEY * pFromKey,
EVP_PKEY ** pToKey )
static

Returns pointer to the OpenSSL EVP_PKEY structure.

◆ duplicate() [2/2]

void Poco::Crypto::EVPPKey::duplicate ( EVP_PKEY * pEVPPKey)
private

◆ isSupported()

bool Poco::Crypto::EVPPKey::isSupported ( int type) const
inline

Retuns the EVPPKey type NID.

Definition at line 324 of file EVPPKey.h.

◆ loadKey() [1/2]

template<typename K , typename F >
static bool Poco::Crypto::EVPPKey::loadKey ( K ** ppKey,
PEM_read_BIO_Key_fn readFunc,
F getFunc,
std::istream * pIstr,
const std::string & pass = "" )
inlinestaticprivate

Definition at line 228 of file EVPPKey.h.

◆ loadKey() [2/2]

template<typename K , typename F >
static bool Poco::Crypto::EVPPKey::loadKey ( K ** ppKey,
PEM_read_FILE_Key_fn readFunc,
F getFunc,
const std::string & keyFile,
const std::string & pass = "" )
inlinestaticprivate

Definition at line 162 of file EVPPKey.h.

◆ newECKey()

void Poco::Crypto::EVPPKey::newECKey ( const char * group)
private

◆ operator const EVP_PKEY *()

Poco::Crypto::EVPPKey::operator const EVP_PKEY * ( ) const
inline

Returns true if OpenSSL type is supported.

Definition at line 330 of file EVPPKey.h.

◆ operator EVP_PKEY *()

Poco::Crypto::EVPPKey::operator EVP_PKEY * ( )
inline

Returns const pointer to the OpenSSL EVP_PKEY structure.

Definition at line 336 of file EVPPKey.h.

◆ operator!=()

bool Poco::Crypto::EVPPKey::operator!= ( const EVPPKey & other) const
inline

Comparison operator. Returns true if public key components and parameters of the other key are equal to this key.

Works as expected when one key contains only public key, while the other one contains private (thus also public) key.

Definition at line 304 of file EVPPKey.h.

+ Here is the call graph for this function:

◆ operator=() [1/2]

EVPPKey & Poco::Crypto::EVPPKey::operator= ( const EVPPKey & other)

Move constructor.

◆ operator=() [2/2]

EVPPKey & Poco::Crypto::EVPPKey::operator= ( EVPPKey && other)
noexcept

Assignment operator.

◆ operator==()

bool Poco::Crypto::EVPPKey::operator== ( const EVPPKey & other) const
inline

Destroys the EVPPKey.

Definition at line 296 of file EVPPKey.h.

+ Here is the caller graph for this function:

◆ passCB()

static int Poco::Crypto::EVPPKey::passCB ( char * buf,
int size,
int ,
void * pass )
staticprivate

◆ save() [1/2]

void Poco::Crypto::EVPPKey::save ( const std::string & publicKeyFile,
const std::string & privateKeyFile = "",
const std::string & privateKeyPassphrase = "" ) const

Comparison operator. Returns true if public key components and parameters of the other key are different from this key.

Works as expected when one key contains only public key, while the other one contains private (thus also public) key.

◆ save() [2/2]

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

Exports the public and/or private keys to the given files.

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

◆ setKey() [1/4]

void Poco::Crypto::EVPPKey::setKey ( EC_KEY * pKey)
inlineprivate

Definition at line 342 of file EVPPKey.h.

+ Here is the call graph for this function:

◆ setKey() [2/4]

void Poco::Crypto::EVPPKey::setKey ( ECKey * pKey)
private

◆ setKey() [3/4]

void Poco::Crypto::EVPPKey::setKey ( RSA * pKey)
inlineprivate

Definition at line 349 of file EVPPKey.h.

+ Here is the call graph for this function:

◆ setKey() [4/4]

void Poco::Crypto::EVPPKey::setKey ( RSAKey * pKey)
private

◆ type() [1/2]

int Poco::Crypto::EVPPKey::type ( ) const
inline

Exports the public and/or private key to the given streams.

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

Definition at line 318 of file EVPPKey.h.

+ Here is the call graph for this function:

◆ type() [2/2]

int Poco::Crypto::EVPPKey::type ( const EVP_PKEY * pEVPPKey)
inlinestaticprivate

Definition at line 310 of file EVPPKey.h.

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ ECKeyImpl

friend class ECKeyImpl
friend

Definition at line 286 of file EVPPKey.h.

◆ RSAKeyImpl

friend class RSAKeyImpl
friend

Definition at line 287 of file EVPPKey.h.

Member Data Documentation

◆ _pEVPPKey

EVP_PKEY* Poco::Crypto::EVPPKey::_pEVPPKey
private

Definition at line 284 of file EVPPKey.h.


The documentation for this class was generated from the following file: