158 return m_private_key.has_value();
165 inline const std::optional<Secure::Password>&
PrivateKey() const noexcept {
166 return m_private_key;
180 bool Save(
const std::filesystem::path& directory, std::string_view baseName,
StorageFormat format = StorageFormat::PEM)
const noexcept;
190 bool Save(
const std::filesystem::path& directory, std::string_view baseName,
const Secure::Password& encryptPassword,
StorageFormat format = StorageFormat::PEM)
const noexcept;
231 m_public_key(
std::move(public_key)),
232 m_private_key(
std::move(private_key)) {}
DSA keypair.
Definition dsa.hxx:69
ECC keypair.
Definition ecc.hxx:69
ECDH keypair.
Definition ecdh.hxx:69
ECDSA keypair.
Definition ecdsa.hxx:69
Ed25519 keypair.
Definition ed25519.hxx:69
Abstract keypair.
Definition generic.hxx:99
bool SavePrivate(const std::filesystem::path &filePath, StorageFormat format=StorageFormat::PEM) const noexcept
Write only the private key, unencrypted.
enum Type m_type
Algorithm.
Definition generic.hxx:219
const std::optional< Secure::Password > & PrivateKey() const noexcept
Private key, if any.
Definition generic.hxx:165
Generic(Generic &&other) noexcept=default
Move constructor.
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.
Generic(enum Type type, StormByte::Safe::String public_key, std::optional< Secure::Password > private_key=std::nullopt)
Construct with algorithm and material.
Definition generic.hxx:229
std::optional< Secure::Password > m_private_key
Private material, if any.
Definition generic.hxx:221
bool HasPrivateKey() const noexcept
Whether a private key is stored.
Definition generic.hxx:157
const StormByte::Safe::String & PublicKey() const noexcept
Public key string.
Definition generic.hxx:149
Generic(const Generic &other)=default
Copy constructor.
virtual ~Generic() noexcept
Destructor.
StormByte::Safe::String m_public_key
Public material.
Definition generic.hxx:220
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).
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.
RSA keypair.
Definition rsa.hxx:69
X25519 keypair.
Definition x25519.hxx:69
Shared, wiped container for passwords and raw key material.
Definition password.hxx:104
StorageFormat
On-disk encoding.
Definition generic.hxx:86
Generic::PointerType Create(Type type, unsigned short bits) noexcept
Generate a keypair.
Generic::PointerType Load(const std::filesystem::path &publicKeyPath, const std::filesystem::path &privateKeyPath) noexcept
Load from separate public and private files.
Root namespace of the StormByte suite.
#define STORMBYTE_CRYPTO_PUBLIC
Definition visibility.h:53