43#include <StormByte/safe/clonable.hxx>
47#include <StormByte/safe/optional.hxx>
48#include <StormByte/safe/secure_binary.hxx>
49#include <StormByte/safe/string.hxx>
98 using PathView = std::basic_string_view<std::filesystem::path::value_type>;
229 template<
typename Compatibility =
void>
231 return Save(
PathView{directory.native()}, baseName, format);
253 template<
typename Compatibility =
void>
255 return Save(
PathView{directory.native()}, baseName, encryptPassword, format);
273 template<
typename Compatibility =
void>
293 template<
typename Compatibility =
void>
315 template<
typename Compatibility =
void>
390 template<
typename Compatibility =
void>
412 template<
typename Compatibility =
void>
430 template<
typename Compatibility =
void>
450 template<
typename Compatibility =
void>
DSA keypair.
Definition dsa.hxx:71
ECC keypair.
Definition ecc.hxx:71
ECDH keypair.
Definition ecdh.hxx:71
ECDSA keypair.
Definition ecdsa.hxx:71
Ed25519 keypair.
Definition ed25519.hxx:71
Abstract keypair.
Definition generic.hxx:113
bool SavePublic(const std::filesystem::path &filePath, StorageFormat format=StorageFormat::PEM) const noexcept
Caller-side filesystem path adapter for SavePublic.
Definition generic.hxx:274
bool SavePublic(PathView filePath, StorageFormat format=StorageFormat::PEM) const noexcept
Write only the public key.
enum Type m_type
Algorithm.
Definition generic.hxx:322
Generic(enum Type type, StormByte::Safe::String public_key, StormByte::Safe::Optional< Secure::Password > private_key=std::nullopt)
Construct with algorithm and material.
bool SavePrivate(PathView filePath, const Secure::Password &encryptPassword, StorageFormat format=StorageFormat::PEM) const noexcept
Write only the private key, encrypted (prefer PEM).
bool SavePrivate(const std::filesystem::path &filePath, StorageFormat format=StorageFormat::PEM) const noexcept
Caller-side filesystem path adapter for unencrypted SavePrivate.
Definition generic.hxx:294
bool Save(PathView directory, std::string_view baseName, const Secure::Password &encryptPassword, StorageFormat format=StorageFormat::PEM) const noexcept
Write public and private files.
StormByte::Safe::SecureBinary SavePrivate(StorageFormat format=StorageFormat::PEM) const noexcept
Encode the private key in memory, unencrypted.
Generic(Generic &&other) noexcept
Move constructor.
StormByte::Safe::Optional< Secure::Password > m_private_key
Crypto-owned optional private material.
Definition generic.hxx:324
bool Save(const std::filesystem::path &directory, std::string_view baseName, StorageFormat format=StorageFormat::PEM) const noexcept
Caller-side filesystem path adapter for unencrypted Save.
Definition generic.hxx:230
StormByte::Safe::SecureBinary SavePrivate(const Secure::Password &encryptPassword, StorageFormat format=StorageFormat::PEM) const noexcept
Encode the private key in memory as encrypted PKCS#8 (prefer PEM).
bool SavePrivate(PathView filePath, StorageFormat format=StorageFormat::PEM) const noexcept
Write only the private key, unencrypted.
const StormByte::Safe::Optional< Secure::Password > & PrivateKey() const noexcept
Private key, if any.
Definition generic.hxx:181
bool Save(PathView 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
Caller-side filesystem path adapter for encrypted Save.
Definition generic.hxx:254
bool HasPrivateKey() const noexcept
Whether a private key is stored.
Definition generic.hxx:171
const StormByte::Safe::String & PublicKey() const noexcept
Public key string.
Definition generic.hxx:163
Generic(const Generic &other)
Copy constructor.
virtual ~Generic() noexcept
Destructor.
StormByte::Safe::String m_public_key
Public material.
Definition generic.hxx:323
StormByte::Safe::SecureBinary SavePublic(StorageFormat format=StorageFormat::PEM) const noexcept
Encode the public key in memory.
bool SavePrivate(const std::filesystem::path &filePath, const Secure::Password &encryptPassword, StorageFormat format=StorageFormat::PEM) const noexcept
Caller-side filesystem path adapter for encrypted SavePrivate.
Definition generic.hxx:316
RSA keypair.
Definition rsa.hxx:71
X25519 keypair.
Definition x25519.hxx:71
Shared, wiped container for passwords and raw key material.
Definition password.hxx:108
STORMBYTE_DECLARE_MAYBE_SAFE(class StormByte::System::Device::Access)
Keypairs of the Crypto module.
StorageFormat
On-disk encoding.
Definition generic.hxx:87
@ PEM
OpenSSL PEM.
Definition generic.hxx:88
@ DER
Binary DER.
Definition generic.hxx:89
Generic::PointerType Load(const StormByte::Safe::SecureBinary &data) noexcept
Load from one in-memory key (public, private, or concatenated PEM).
Generic::PointerType Create(Type type, unsigned short bits) noexcept
Generate a keypair.
std::basic_string_view< std::filesystem::path::value_type > PathView
Borrowed native path characters for allocation-free DLL arguments.
Definition generic.hxx:98
Crypto module of the StormByte suite.
Definition aead.hxx:53
Root namespace of the StormByte suite.
#define STORMBYTE_CRYPTO_PUBLIC
Definition visibility.h:53