PcapPlusPlus  Next
pcpp::PKCS8PrivateKey Class Reference

Represents a private key in PKCS#8 format This class provides methods to decode and access the components of the private key and its data. More...

#include <CryptoKeyDecoder.h>

Inheritance diagram for pcpp::PKCS8PrivateKey:
pcpp::internal::CryptographicKey< PKCS8PrivateKey > pcpp::internal::CryptoDataReader< PKCS8PrivateKey >

Classes

class  ECPrivateKeyData
 Contains EC private key data extracted from PKCS#8 format This class provides access to the components of an EC private key that was extracted from a PKCS#8 structure. More...
 
class  Ed25519PrivateKeyData
 Contains Ed25519 private key data extracted from PKCS#8 format This class provides access to the components of an Ed25519 private key that was extracted from a PKCS#8 structure. More...
 
class  PrivateKeyData
 Base class for private key data in PKCS#8 format This class serves as a base for different types of private key data that can be contained within a PKCS#8 structure. More...
 
class  RSAPrivateKeyData
 Contains RSA private key data extracted from PKCS#8 format This class provides access to the components of an RSA private key that was extracted from a PKCS#8 structure. More...
 

Public Member Functions

uint8_t getVersion () const
 
CryptographicKeyAlgorithm getPrivateKeyAlgorithm () const
 
std::unique_ptr< PrivateKeyDatagetPrivateKey () const
 Gets the private key data. More...
 
template<typename PrivateKeyDataType >
std::unique_ptr< PrivateKeyDataType > getPrivateKeyAs () const
 Gets the private key data cast to a requested type. More...
 
- Public Member Functions inherited from pcpp::internal::CryptographicKey< PKCS8PrivateKey >
std::vector< uint8_t > toDER () const
 
std::string toPEM () const
 

Additional Inherited Members

- Static Public Member Functions inherited from pcpp::internal::CryptoDataReader< PKCS8PrivateKey >
static std::unique_ptr< PKCS8PrivateKeyfromDER (uint8_t *derData, size_t derDataLen, bool ownDerData=false)
 
static std::unique_ptr< PKCS8PrivateKeyfromDER (const std::string &derData)
 
static std::unique_ptr< PKCS8PrivateKeyfromDERFile (const std::string &derFileName)
 
static std::unique_ptr< PKCS8PrivateKeyfromPEM (const std::string &pemData)
 
static std::unique_ptr< PKCS8PrivateKeyfromPEMFile (const std::string &pemFileName)
 

Detailed Description

Represents a private key in PKCS#8 format This class provides methods to decode and access the components of the private key and its data.

Member Function Documentation

◆ getPrivateKey()

std::unique_ptr<PrivateKeyData> pcpp::PKCS8PrivateKey::getPrivateKey ( ) const

Gets the private key data.

Returns
A unique pointer to the PrivateKeyData containing the key material
Note
The actual type of the returned pointer depends on the key algorithm

◆ getPrivateKeyAlgorithm()

CryptographicKeyAlgorithm pcpp::PKCS8PrivateKey::getPrivateKeyAlgorithm ( ) const
Returns
The CryptographicKeyAlgorithm enum value representing the key algorithm

◆ getPrivateKeyAs()

template<typename PrivateKeyDataType >
std::unique_ptr<PrivateKeyDataType> pcpp::PKCS8PrivateKey::getPrivateKeyAs ( ) const
inline

Gets the private key data cast to a requested type.

Returns
A unique pointer of the requested type containing the key material. If the key algorithm doesn't match the requested type, nullptr is returned

◆ getVersion()

uint8_t pcpp::PKCS8PrivateKey::getVersion ( ) const
Returns
The version of the PKCS#8 private key