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

ECDH keypair. More...

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

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

Public Member Functions

PointerType Clone () const override
 Clone this keypair.
PointerType Move () override
 Move this keypair into a new instance.
Construction
 ECDH (std::string_view publicKey, StormByte::Safe::Optional< Secure::Password > privateKey=std::nullopt)
 Construct from public material and optional private Password.
 ECDH (const ECDH &other)=default
 Copy constructor.
 ECDH (ECDH &&other) noexcept=default
 Move constructor.
 ~ECDH () noexcept
 Destructor.
ECDH & operator= (const ECDH &other)=default
 Copy assignment.
ECDH & operator= (ECDH &&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 StormByte::Safe::Optional< Secure::Password > & PrivateKey () const noexcept
 Private key, if any.
 Generic (const Generic &other)
 Copy constructor.
 Generic (Generic &&other) noexcept
 Move constructor.
virtual ~Generic () noexcept
 Destructor.
Generic & operator= (const Generic &other)
 Copy assignment.
Generic & operator= (Generic &&other) noexcept
 Move assignment.
StormByte::Safe::SecureBinary SavePublic (StorageFormat format=StorageFormat::PEM) const noexcept
 Encode the public key in memory.
StormByte::Safe::SecureBinary SavePrivate (StorageFormat format=StorageFormat::PEM) const noexcept
 Encode the private key in memory, unencrypted.
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 Save (PathView directory, std::string_view baseName, StorageFormat format=StorageFormat::PEM) const noexcept
 Write public and private files under a directory.
template<typename Compatibility = void>
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.
bool Save (PathView directory, std::string_view baseName, const Secure::Password &encryptPassword, StorageFormat format=StorageFormat::PEM) const noexcept
 Write public and private files.
template<typename Compatibility = void>
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.
bool SavePublic (PathView filePath, StorageFormat format=StorageFormat::PEM) const noexcept
 Write only the public key.
template<typename Compatibility = void>
bool SavePublic (const std::filesystem::path &filePath, StorageFormat format=StorageFormat::PEM) const noexcept
 Caller-side filesystem path adapter for SavePublic.
bool SavePrivate (PathView filePath, StorageFormat format=StorageFormat::PEM) const noexcept
 Write only the private key, unencrypted.
template<typename Compatibility = void>
bool SavePrivate (const std::filesystem::path &filePath, StorageFormat format=StorageFormat::PEM) const noexcept
 Caller-side filesystem path adapter for unencrypted SavePrivate.
bool SavePrivate (PathView filePath, const Secure::Password &encryptPassword, StorageFormat format=StorageFormat::PEM) const noexcept
 Write only the private key, encrypted (prefer PEM).
template<typename Compatibility = void>
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.
Public Member Functions inherited from StormByte::Safe::Clonable< Generic >
constexpr Clonable ()=default
constexpr Clonable & operator= (const Clonable &)=default
virtual constexpr ~Clonable () noexcept=default

Static Public Member Functions

static PointerType Generate (unsigned short bits) noexcept
 Generate an ECDH 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, StormByte::Safe::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.
StormByte::Safe::Optional< Secure::Password > m_private_key
 Crypto-owned optional private material.

Detailed Description

ECDH keypair.

Note
Conditional DLL safety follows Generic's provider requirements. Material construction, Clone/Move and destruction are provided by Crypto; defaulted value operations delegate to exported Generic operations.

Constructor & Destructor Documentation

◆ ECDH() [1/3]

StormByte::Crypto::KeyPair::ECDH::ECDH ( std::string_view publicKey,
StormByte::Safe::Optional< Secure::Password > privateKey = std::nullopt )

Construct from public material and optional private Password.

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

◆ ECDH() [2/3]

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

Copy constructor.

Parameters
otherKeypair to copy.

◆ ECDH() [3/3]

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

Move constructor.

Parameters
otherKeypair to move.

◆ ~ECDH()

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

Destructor.

Member Function Documentation

◆ Clone()

PointerType StormByte::Crypto::KeyPair::ECDH::Clone ( ) const
overridevirtual

Clone this keypair.

Returns
Shared pointer to the clone.

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

◆ Generate()

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

Generate an ECDH keypair.

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

◆ Move()

PointerType StormByte::Crypto::KeyPair::ECDH::Move ( )
overridevirtual

Move this keypair into a new instance.

Returns
Shared pointer to the moved keypair.

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

◆ operator=() [1/2]

ECDH & StormByte::Crypto::KeyPair::ECDH::operator= ( const ECDH & other)
default

Copy assignment.

Parameters
otherKeypair to copy.
Returns
Reference to this keypair.

◆ operator=() [2/2]

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

Move assignment.

Parameters
otherKeypair to move.
Returns
Reference to this keypair.

The documentation for this class was generated from the following file:
  • lib/public/StormByte/crypto/keypair/ecdh.hxx