Abstract keypair.
More...
#include <StormByte/crypto/keypair/generic.hxx>
|
| enum Type | Type () const noexcept |
| | Algorithm of this keypair.
|
| |
| const StormByte::Safe::String & | PublicKey () const noexcept |
| | Public key string.
|
| |
| bool | HasPrivateKey () const noexcept |
| | Whether a private key is stored.
|
| |
| const std::optional< Secure::Password > & | PrivateKey () const noexcept |
| | Private key, if any.
|
| |
|
| | Generic (const Generic &other)=default |
| | Copy constructor.
|
| |
| | Generic (Generic &&other) noexcept=default |
| | Move constructor.
|
| |
| virtual | ~Generic () noexcept |
| | Destructor.
|
| |
| Generic & | operator= (const Generic &other)=default |
| | Copy assignment.
|
| |
| Generic & | operator= (Generic &&other) noexcept=default |
| | Move assignment.
|
| |
|
| bool | Save (const std::filesystem::path &directory, std::string_view baseName, StorageFormat format=StorageFormat::PEM) const noexcept |
| | Write public and private files under a directory.
|
| |
| bool | Save (const std::filesystem::path &directory, std::string_view baseName, const Secure::Password &encryptPassword, StorageFormat format=StorageFormat::PEM) const noexcept |
| | Write public and private files.
|
| |
| bool | SavePublic (const std::filesystem::path &filePath, StorageFormat format=StorageFormat::PEM) const noexcept |
| | Write only the public key.
|
| |
| bool | SavePrivate (const std::filesystem::path &filePath, StorageFormat format=StorageFormat::PEM) const noexcept |
| | Write only the private key, unencrypted.
|
| |
| bool | SavePrivate (const std::filesystem::path &filePath, const Secure::Password &encryptPassword, StorageFormat format=StorageFormat::PEM) const noexcept |
| | Write only the private key, encrypted (prefer PEM).
|
| |
| constexpr | Clonable ()=default |
| |
| constexpr | Clonable (const Clonable &)=default |
| |
| constexpr | Clonable (Clonable &&) noexcept=default |
| |
| constexpr Clonable & | operator= (const Clonable &)=default |
| |
| constexpr Clonable & | operator= (Clonable &&) noexcept=default |
| |
| virtual constexpr | ~Clonable () noexcept=default |
| |
| virtual PointerType | Clone () const =0 |
| |
| virtual PointerType | Move ()=0 |
| |
Abstract keypair.
Concrete algorithms derive from this.
Public key is a non-secret StormByte::Safe::String (typically Base64 SPKI DER). Private key, when present, is a StormByte::Crypto::Secure::Password holding PKCS#8 or native DER and is wiped with the last owner.
◆ Generic() [1/3]
| StormByte::Crypto::KeyPair::Generic::Generic |
( |
const Generic & |
other | ) |
|
|
default |
Copy constructor.
- Parameters
-
◆ Generic() [2/3]
| StormByte::Crypto::KeyPair::Generic::Generic |
( |
Generic && |
other | ) |
|
|
defaultnoexcept |
Move constructor.
- Parameters
-
◆ ~Generic()
| virtual StormByte::Crypto::KeyPair::Generic::~Generic |
( |
| ) |
|
|
virtualnoexcept |
Destructor.
Drops the private-key handle.
◆ Generic() [3/3]
Construct with algorithm and material.
- Parameters
-
| type | Algorithm. |
| public_key | Public material. |
| private_key | Optional private Password. |
◆ HasPrivateKey()
| bool StormByte::Crypto::KeyPair::Generic::HasPrivateKey |
( |
| ) |
const |
|
inlinenoexcept |
Whether a private key is stored.
- Returns
- true if present.
◆ operator=() [1/2]
Copy assignment.
- Parameters
-
- Returns
- Reference to this keypair.
◆ operator=() [2/2]
Move assignment.
- Parameters
-
- Returns
- Reference to this keypair.
◆ PrivateKey()
Private key, if any.
- Returns
- Shared Password, or empty.
◆ PublicKey()
Public key string.
- Returns
- Public material owned by this keypair.
◆ Save() [1/2]
Write public and private files.
Private key encrypted (prefer PEM).
- Parameters
-
| directory | Existing directory. |
| baseName | File stem. |
| encryptPassword | Password for the private file. |
| format | Prefer PEM when encrypting. |
- Returns
- true on success.
◆ Save() [2/2]
Write public and private files under a directory.
Private key unencrypted.
- Parameters
-
| directory | Existing directory. |
| baseName | File stem. |
| format | PEM or DER. |
- Returns
- true on success.
◆ SavePrivate() [1/2]
Write only the private key, encrypted (prefer PEM).
- Parameters
-
| filePath | Destination. |
| encryptPassword | Password. |
| format | Prefer PEM. |
- Returns
- true on success.
◆ SavePrivate() [2/2]
Write only the private key, unencrypted.
- Parameters
-
| filePath | Destination. |
| format | PEM or DER. |
- Returns
- true on success.
◆ SavePublic()
Write only the public key.
- Parameters
-
| filePath | Destination. |
| format | PEM or DER. |
- Returns
- true on success.
◆ Type()
| enum Type StormByte::Crypto::KeyPair::Generic::Type |
( |
| ) |
const |
|
inlinenoexcept |
Algorithm of this keypair.
- Returns
- Keypair type.
◆ m_private_key
| std::optional<Secure::Password> StormByte::Crypto::KeyPair::Generic::m_private_key |
|
protected |
Private material, if any.
◆ m_public_key
◆ m_type
| enum Type StormByte::Crypto::KeyPair::Generic::m_type |
|
protected |
The documentation for this class was generated from the following file: