StormByte-Crypto 2.0.0
C++26 cryptography module of the StormByte suite
 
Loading...
Searching...
No Matches
StormByte::Crypto::KeyPair::RSA Class Referencefinal

RSA keypair. More...

#include <StormByte/crypto/keypair/rsa.hxx>

Inheritance diagram for StormByte::Crypto::KeyPair::RSA:
Collaboration diagram for StormByte::Crypto::KeyPair::RSA:

Public Member Functions

PointerType Clone () const override
 Clone this keypair.
 
PointerType Move () override
 Move this keypair into a new instance.
 
Construction
 RSA (std::string_view publicKey, std::optional< Secure::Password > privateKey=std::nullopt)
 Construct from public material and optional private Password.
 
 RSA (const RSA &other)=default
 Copy constructor.
 
 RSA (RSA &&other) noexcept=default
 Move constructor.
 
 ~RSA () noexcept
 Destructor.
 
RSA & operator= (const RSA &other)=default
 Copy assignment.
 
RSA & operator= (RSA &&other) noexcept=default
 Move assignment.
 
- Public Member Functions inherited from StormByte::Crypto::KeyPair::Generic
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).
 
- Public Member Functions inherited from StormByte::Safe::Clonable< Generic >
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
 

Static Public Member Functions

static PointerType Generate (unsigned short bits) noexcept
 Generate an RSA keypair.
 
- Static Public Member Functions inherited from StormByte::Safe::Clonable< Generic >
static PointerType MakePointer (Args &&... args)
 

Additional Inherited Members

- Public Types inherited from StormByte::Safe::Clonable< Generic >
typedef SmartPointer PointerType
 
- Protected Member Functions inherited from StormByte::Crypto::KeyPair::Generic
 Generic (enum Type type, StormByte::Safe::String public_key, std::optional< Secure::Password > private_key=std::nullopt)
 Construct with algorithm and material.
 
- Protected Attributes inherited from StormByte::Crypto::KeyPair::Generic
enum Type m_type
 Algorithm.
 
StormByte::Safe::String m_public_key
 Public material.
 
std::optional< Secure::Password > m_private_key
 Private material, if any.
 

Detailed Description

RSA keypair.

Constructor & Destructor Documentation

◆ RSA() [1/3]

StormByte::Crypto::KeyPair::RSA::RSA ( std::string_view  publicKey,
std::optional< Secure::Password >  privateKey = std::nullopt 
)
inline

Construct from public material and optional private Password.

Parameters
publicKeyPublic key. Accepts String and std::string via string_view.
privateKeyOptional private key.

◆ RSA() [2/3]

StormByte::Crypto::KeyPair::RSA::RSA ( const RSA &  other)
default

Copy constructor.

Parameters
otherKeypair to copy.

◆ RSA() [3/3]

StormByte::Crypto::KeyPair::RSA::RSA ( RSA &&  other)
defaultnoexcept

Move constructor.

Parameters
otherKeypair to move.

◆ ~RSA()

StormByte::Crypto::KeyPair::RSA::~RSA ( )
noexcept

Destructor.

Member Function Documentation

◆ Clone()

PointerType StormByte::Crypto::KeyPair::RSA::Clone ( ) const
inlineoverridevirtual

Clone this keypair.

Returns
Shared pointer to the clone.

Implements StormByte::Safe::Clonable< Generic >.

◆ Generate()

static PointerType StormByte::Crypto::KeyPair::RSA::Generate ( unsigned short  bits)
staticnoexcept

Generate an RSA keypair.

Parameters
bitsKey size in bits.
Returns
Keypair pointer, or nullptr.

◆ Move()

PointerType StormByte::Crypto::KeyPair::RSA::Move ( )
inlineoverridevirtual

Move this keypair into a new instance.

Returns
Shared pointer to the moved keypair.

Implements StormByte::Safe::Clonable< Generic >.

◆ operator=() [1/2]

Copy assignment.

Parameters
otherKeypair to copy.
Returns
Reference to this keypair.

◆ operator=() [2/2]

RSA & StormByte::Crypto::KeyPair::RSA::operator= ( RSA &&  other)
defaultnoexcept

Move assignment.

Parameters
otherKeypair to move.
Returns
Reference to this keypair.

The documentation for this class was generated from the following file: