fourdst_plugin 0.0.1a
C++ Plugin Manager
|
Represents a public key for cryptographic operations. More...
#include <public_key.h>
Public Member Functions | |
PublicKey ()=default | |
Constructs an uninitialized PublicKey object. | |
PublicKey (const std::string &filepath) | |
Constructs a PublicKey by loading from a file. | |
PublicKey (const std::filesystem::path &filepath) | |
Constructs a PublicKey by loading from a file. | |
PublicKey (const char *filepath) | |
Constructs a PublicKey by loading from a file. | |
PublicKey (const std::vector< unsigned char > &data) | |
Constructs a PublicKey from binary data in memory. | |
~PublicKey ()=default | |
PublicKey (const PublicKey &)=delete | |
PublicKey & | operator= (const PublicKey &)=delete |
PublicKey (PublicKey &&)=default | |
PublicKey & | operator= (PublicKey &&) noexcept=default |
std::string | type () const |
Gets the type of the public key. | |
size_t | size () const |
Gets the size of the public key in bits. | |
EVP_PKEY * | get () const |
Gets the underlying OpenSSL EVP_PKEY object. | |
std::string | get_fingerprint () const |
Gets a fingerprint of the public key. | |
bool | is_initialized () const |
Checks if the PublicKey is initialized with a valid key. | |
bool | operator== (const PublicKey &other) const |
Compares two PublicKey objects for equality. | |
bool | operator!= (const PublicKey &other) const |
Compares two PublicKey objects for inequality. | |
bool | operator== (const std::vector< unsigned char > &data) const |
Compares the PublicKey with raw key data for equality. | |
bool | operator!= (const std::vector< unsigned char > &data) const |
Compares the PublicKey with raw key data for inequality. | |
Private Attributes | |
Unique_EVP_PKEY | m_pkey |
The underlying OpenSSL key object. | |
bool | m_initialized = false |
Flag indicating if the key is initialized. | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const PublicKey &key) |
Outputs a string representation of the PublicKey to a stream. | |
Represents a public key for cryptographic operations.
This class provides an interface for loading and working with public keys in various formats (PEM, DER) and performing key-related operations.
|
default |
Constructs an uninitialized PublicKey object.
|
explicit |
Constructs a PublicKey by loading from a file.
[in] | filepath | Path to the file containing the public key in PEM format. |
std::runtime_error | If the file cannot be opened or the key cannot be loaded. |
|
explicit |
Constructs a PublicKey by loading from a file.
[in] | filepath | Filesystem path to the file containing the public key in PEM format. |
std::runtime_error | If the file cannot be opened or the key cannot be loaded. |
|
explicit |
Constructs a PublicKey by loading from a file.
[in] | filepath | C-style string path to the file containing the public key in PEM format. |
std::runtime_error | If the file cannot be opened or the key cannot be loaded. |
|
explicit |
Constructs a PublicKey from binary data in memory.
The data can be in either PEM or DER format. The format is automatically detected.
[in] | data | Binary data containing the public key. |
std::runtime_error | If the key cannot be loaded from the provided data. |
std::runtime_error | If the key format is not recognized. |
|
default |
|
delete |
|
default |
|
nodiscard |
Gets the underlying OpenSSL EVP_PKEY object.
|
nodiscard |
Gets a fingerprint of the public key.
The fingerprint is a SHA-256 hash of the key's DER-encoded SubjectPublicKeyInfo.
std::runtime_error | If the key is not initialized or an error occurs. |
|
nodiscard |
Checks if the PublicKey is initialized with a valid key.
bool fourdst::crypt::PublicKey::operator!= | ( | const PublicKey & | other | ) | const |
bool fourdst::crypt::PublicKey::operator!= | ( | const std::vector< unsigned char > & | data | ) | const |
Compares the PublicKey with raw key data for inequality.
[in] | data | The raw key data to compare with. |
bool fourdst::crypt::PublicKey::operator== | ( | const PublicKey & | other | ) | const |
bool fourdst::crypt::PublicKey::operator== | ( | const std::vector< unsigned char > & | data | ) | const |
Compares the PublicKey with raw key data for equality.
[in] | data | The raw key data to compare with. |
|
nodiscard |
Gets the size of the public key in bits.
|
nodiscard |
Gets the type of the public key.
|
friend |
|
private |
Flag indicating if the key is initialized.
|
private |
The underlying OpenSSL key object.