3#include <StormByte/clonable.hxx>
4#include <StormByte/crypto/typedefs.hxx>
5#include <StormByte/crypto/visibility.h>
15namespace StormByte::Crypto::KeyPair {
34 class STORMBYTE_CRYPTO_PUBLIC
Generic:
public StormByte::Clonable<Generic> {
71 inline const std::
string& PublicKey() const noexcept {
79 inline const std::optional<std::string>&
PrivateKey() const noexcept {
87 inline enum Type
Type() const noexcept {
97 bool Save(
const std::filesystem::path& path,
const std::string& name)
const noexcept;
108 inline Generic(
enum Type type,
const std::string& public_key, std::optional<std::string> private_key = std::nullopt):
109 m_type(type), m_public_key(public_key), m_private_key(private_key) {}
121 STORMBYTE_CRYPTO_PUBLIC Generic::PointerType Generate(Type type,
unsigned short bits)
noexcept;
123 STORMBYTE_CRYPTO_PUBLIC Generic::PointerType Load(
const std::filesystem::path& publicKeyPath,
const std::filesystem::path& privateKeyPath)
noexcept;
A generic class.
Definition generic.hxx:34
std::string m_public_key
The public key.
Definition generic.hxx:101
enum Type m_type
The type of keypair.
Definition generic.hxx:100
bool Save(const std::filesystem::path &path, const std::string &name) const noexcept
Saves the keypair to the specified file paths.
virtual ~Generic() noexcept=default
Virtual destructor.
Generic(Generic &&other) noexcept=default
Move constructor.
const std::optional< std::string > & PrivateKey() const noexcept
Gets the private key of the keypair.
Definition generic.hxx:79
Generic(enum Type type, const std::string &public_key, std::optional< std::string > private_key=std::nullopt)
Constructor.
Definition generic.hxx:108
std::optional< std::string > m_private_key
The private key.
Definition generic.hxx:102
Generic(const Generic &other)=default
Copy constructor.
enum Type Type() const noexcept
Gets the type of keypair.
Definition generic.hxx:87