libcryptosec
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members

#include <KeyPair.h>

Inheritance diagram for KeyPair:
DSAKeyPair ECDSAKeyPair RSAKeyPair

Public Member Functions

 KeyPair (AsymmetricKey::Algorithm algorithm, int length) throw (AsymmetricKeyException)
 
 KeyPair (Engine *engine, std::string keyId) throw (EngineException)
 
 KeyPair (std::string pemEncoded, ByteArray passphrase) throw (EncodeException)
 
 KeyPair (std::string pemEncoded) throw (EncodeException)
 
 KeyPair (ByteArray derEncoded) throw (EncodeException)
 
 KeyPair (const KeyPair &keyPair)
 
virtual ~KeyPair ()
 
virtual PublicKeygetPublicKey () throw (AsymmetricKeyException, EncodeException)
 
virtual PrivateKeygetPrivateKey () throw (AsymmetricKeyException)
 
std::string getPemEncoded (SymmetricKey &passphrase, SymmetricCipher::OperationMode mode) throw (SymmetricCipherException, EncodeException)
 
std::string getPemEncoded () throw (EncodeException)
 
ByteArray getDerEncoded () throw (EncodeException)
 
virtual AsymmetricKey::Algorithm getAlgorithm () throw (AsymmetricKeyException)
 
int getSize () throw (AsymmetricKeyException)
 
int getSizeBits () throw (AsymmetricKeyException)
 
EVP_PKEY * getEvpPkey () const
 
ENGINE * getEngine () const
 
std::string getKeyId () const
 

Protected Member Functions

 KeyPair ()
 
std::string getPublicKeyPemEncoded () throw (EncodeException)
 

Static Protected Member Functions

static int passphraseCallBack (char *buf, int size, int rwflag, void *u)
 

Protected Attributes

EVP_PKEY * key
 
std::string keyId
 
ENGINE * engine
 

Detailed Description

Representa um par de chaves assimétricas. Essa classe deve ser usada para a criação de chaves assimétricas bem como a condificação e decodificação do par para os formatos PEM e DER.

Constructor & Destructor Documentation

◆ KeyPair() [1/7]

KeyPair::KeyPair ( AsymmetricKey::Algorithm  algorithm,
int  length 
)
throw (AsymmetricKeyException
)

create a KeyPair object, creating a new key pair

Parameters
algorithmkey pair algorithm
lengthkey lenght
Exceptions
AsymmetricKeyExceptionif the key cannot be created

◆ KeyPair() [2/7]

KeyPair::KeyPair ( Engine engine,
std::string  keyId 
)
throw (EngineException
)

◆ KeyPair() [3/7]

KeyPair::KeyPair ( std::string  pemEncoded,
ByteArray  passphrase 
)
throw (EncodeException
)

create a KeyPair object, loading the key pair from encoded (PEM format), decrypting with key

Parameters
pemEncodedkey pair encoded em PEM format
passphrasepassphrase to decrypt the key pair

◆ KeyPair() [4/7]

KeyPair::KeyPair ( std::string  pemEncoded)
throw (EncodeException
)

create a KeyPair object, loading the key pair from encoded (PEM format)

Parameters
pemEncodedkey pair encoded em PEM format

◆ KeyPair() [5/7]

KeyPair::KeyPair ( ByteArray  derEncoded)
throw (EncodeException
)

create a KeyPair object, loading the key pair from encoded (DER format)

Parameters
derEncodedkey pair encoded em DER format

◆ KeyPair() [6/7]

KeyPair::KeyPair ( const KeyPair keyPair)

◆ ~KeyPair()

KeyPair::~KeyPair ( )
virtual

◆ KeyPair() [7/7]

KeyPair::KeyPair ( )
protected

Member Function Documentation

◆ getAlgorithm()

AsymmetricKey::Algorithm KeyPair::getAlgorithm ( )
throw (AsymmetricKeyException
)
virtual

gets algorithm id from the key

Returns
algorithm id

Reimplemented in ECDSAKeyPair, DSAKeyPair, and RSAKeyPair.

◆ getDerEncoded()

ByteArray KeyPair::getDerEncoded ( )
throw (EncodeException
)

encode the key pair in DER format

Returns
key pair encoded in DER format

◆ getEngine()

ENGINE * KeyPair::getEngine ( ) const

◆ getEvpPkey()

EVP_PKEY * KeyPair::getEvpPkey ( ) const

◆ getKeyId()

std::string KeyPair::getKeyId ( ) const

◆ getPemEncoded() [1/2]

std::string KeyPair::getPemEncoded ( SymmetricKey passphrase,
SymmetricCipher::OperationMode  mode 
)
throw (SymmetricCipherException,
EncodeException
)

encode the key pair in PEM format encrypted

Parameters
passphrasekey for encrypt the key pair
modecipher operation mode
Returns
key pair encrypted encoded in PEM format

◆ getPemEncoded() [2/2]

std::string KeyPair::getPemEncoded ( )
throw (EncodeException
)

encode the key pair in PEM format

Returns
key pair encoded in PEM format

◆ getPrivateKey()

PrivateKey * KeyPair::getPrivateKey ( )
throw (AsymmetricKeyException
)
virtual

gets the private from key pair

Returns
a private key from key pair

Reimplemented in ECDSAKeyPair, DSAKeyPair, and RSAKeyPair.

◆ getPublicKey()

PublicKey * KeyPair::getPublicKey ( )
throw (AsymmetricKeyException,
EncodeException
)
virtual

gets the public key from key pair

Returns
a public key from key pair

Reimplemented in ECDSAKeyPair, DSAKeyPair, and RSAKeyPair.

◆ getPublicKeyPemEncoded()

std::string KeyPair::getPublicKeyPemEncoded ( )
throw (EncodeException
)
protected

◆ getSize()

int KeyPair::getSize ( )
throw (AsymmetricKeyException
)

gets the key size

Returns
key size

◆ getSizeBits()

int KeyPair::getSizeBits ( )
throw (AsymmetricKeyException
)

gets the key size in bits

Returns
key size in bits

◆ passphraseCallBack()

int KeyPair::passphraseCallBack ( char *  buf,
int  size,
int  rwflag,
void *  u 
)
staticprotected

Member Data Documentation

◆ engine

ENGINE* KeyPair::engine
protected

◆ key

EVP_PKEY* KeyPair::key
protected

struct from OpenSSL that represents the key pair

◆ keyId

std::string KeyPair::keyId
protected

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