StormByte-Crypto 3.1.0
C++26 cryptography module of the StormByte suite
Loading...
Searching...
No Matches
StormByte::Crypto::Crypter::Asymmetric Class Reference

Keypair-based asymmetric crypter. More...

#include <StormByte/crypto/crypter/asymmetric/generic.hxx>

Inheritance diagram for StormByte::Crypto::Crypter::Asymmetric:
Collaboration diagram for StormByte::Crypto::Crypter::Asymmetric:

Public Types

enum class  Strategy { Hybrid , Native }
 How payload bytes are sealed. More...
Public Types inherited from StormByte::Safe::Clonable< Generic >
typedef SmartPointer PointerType

Public Member Functions

KeyPair::Generic::PointerType KeyPair () const noexcept
 Keypair used by this crypter.
Construction
 Asymmetric (const Asymmetric &other)=default
 Copy constructor.
 Asymmetric (Asymmetric &&other) noexcept=default
 Move constructor.
virtual ~Asymmetric () noexcept override
 Destructor.
Asymmetric & operator= (const Asymmetric &other)=default
 Copy assignment.
Asymmetric & operator= (Asymmetric &&other) noexcept=default
 Move assignment.
Encrypt
bool Encrypt (std::span< const std::byte > input, Buffer::WriteOnly &output, Strategy strategy=Strategy::Native) const noexcept
 Encrypt a byte span.
bool Encrypt (const Buffer::ReadOnly &input, Buffer::WriteOnly &output, Strategy strategy=Strategy::Native) const noexcept
 Encrypt a read-only buffer (copy).
bool Encrypt (Buffer::ReadOnly &input, Buffer::WriteOnly &output, Strategy strategy=Strategy::Native) const noexcept
 Encrypt a buffer, consuming it.
Buffer::Consumer Encrypt (Buffer::Consumer consumer, Strategy strategy=Strategy::Native, ReadMode mode=ReadMode::Move) const noexcept
 Encrypt a Consumer.
Decrypt
bool Decrypt (std::span< const std::byte > input, Buffer::WriteOnly &output) const noexcept
 Decrypt a byte span.
bool Decrypt (const Buffer::ReadOnly &input, Buffer::WriteOnly &output) const noexcept
 Decrypt a read-only buffer (copy).
bool Decrypt (Buffer::ReadOnly &input, Buffer::WriteOnly &output) const noexcept
 Decrypt a buffer, consuming it.
Buffer::Consumer Decrypt (Buffer::Consumer consumer, ReadMode mode=ReadMode::Move) const noexcept
 Decrypt a Consumer.
Public Member Functions inherited from StormByte::Crypto::Crypter::Generic
enum Type Type () const noexcept
 Cipher of this crypter.
 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 Encrypt (std::span< const std::byte > input, Buffer::WriteOnly &output) const noexcept
 Encrypt a byte span.
template<StormByte::Type::ByteInputRange Range>
bool Encrypt (const Range &input, Buffer::WriteOnly &output) const
 Encrypt an input range of byte-convertible values.
bool Encrypt (const Buffer::ReadOnly &input, Buffer::WriteOnly &output) const noexcept
 Encrypt a read-only buffer (copy).
bool Encrypt (Buffer::ReadOnly &input, Buffer::WriteOnly &output) const noexcept
 Encrypt a buffer, consuming it.
Buffer::Consumer Encrypt (Buffer::Consumer consumer, ReadMode mode=ReadMode::Move) const noexcept
 Encrypt a Consumer into another Consumer.
bool Decrypt (std::span< const std::byte > input, Buffer::WriteOnly &output) const noexcept
 Decrypt a byte span.
template<StormByte::Type::ByteInputRange Range>
bool Decrypt (const Range &input, Buffer::WriteOnly &output) const
 Decrypt an input range of byte-convertible values.
bool Decrypt (const Buffer::ReadOnly &input, Buffer::WriteOnly &output) const noexcept
 Decrypt a read-only buffer (copy).
bool Decrypt (Buffer::ReadOnly &input, Buffer::WriteOnly &output) const noexcept
 Decrypt a buffer, consuming it.
Buffer::Consumer Decrypt (Buffer::Consumer consumer, ReadMode mode=ReadMode::Move) const noexcept
 Decrypt a Consumer into another Consumer.
Public Member Functions inherited from StormByte::Safe::Clonable< Generic >
constexpr Clonable ()=default
constexpr Clonable & operator= (const Clonable &)=default
virtual constexpr ~Clonable () noexcept=default
virtual PointerType Clone () const =0
virtual PointerType Move ()=0

Protected Member Functions

 Asymmetric (enum Type type, KeyPair::Generic::PointerType keypair)
 Construct from a keypair pointer.
 Asymmetric (enum Type type, const KeyPair::Generic &keypair)
 Construct by cloning a keypair.
 Asymmetric (enum Type type, KeyPair::Generic &&keypair)
 Construct by moving a keypair.
Protected Member Functions inherited from StormByte::Crypto::Crypter::Generic
 Generic (enum Type type)
 Construct with a cipher.
virtual bool DoEncrypt (std::span< const std::byte > input, Buffer::WriteOnly &output) const noexcept=0
 Encrypt a byte span.
virtual Buffer::Consumer DoEncrypt (Buffer::Consumer consumer, ReadMode mode) const noexcept=0
 Encrypt a Consumer.
virtual bool DoDecrypt (std::span< const std::byte > input, Buffer::WriteOnly &output) const noexcept=0
 Decrypt a byte span.
virtual Buffer::Consumer DoDecrypt (Buffer::Consumer consumer, ReadMode mode) const noexcept=0
 Decrypt a Consumer.

Protected Attributes

KeyPair::Generic::PointerType m_keypair
 Shared keypair.
Protected Attributes inherited from StormByte::Crypto::Crypter::Generic
enum Type m_type
 Cipher.

Additional Inherited Members

Static Public Member Functions inherited from StormByte::Safe::Clonable< Generic >
static PointerType MakePointer (Args &&... args)

Detailed Description

Keypair-based asymmetric crypter.

Note
MaybeSafe inherits all requirements of StormByte::Crypto::Crypter::Generic, including ABI-compatible toolchains and keeping all provider modules loaded. The keypair uses Safe shared ownership and must satisfy its provider's MaybeSafe contract. Inline construction, copying, assignment and movement delegate to Safe ownership or exported keypair operations; destruction is exported. Derived providers must preserve these guarantees for every added field and bind owning Clone/Move callbacks in their module.

Member Enumeration Documentation

◆ Strategy

How payload bytes are sealed.

Enumerator
Hybrid 

Encapsulate a random AES-GCM key with the public key.

Native 

Pure asymmetric encryption.

Constructor & Destructor Documentation

◆ Asymmetric() [1/5]

StormByte::Crypto::Crypter::Asymmetric::Asymmetric ( const Asymmetric & other)
default

Copy constructor.

Parameters
otherCrypter to copy.

◆ Asymmetric() [2/5]

StormByte::Crypto::Crypter::Asymmetric::Asymmetric ( Asymmetric && other)
defaultnoexcept

Move constructor.

Parameters
otherCrypter to move.

◆ ~Asymmetric()

virtual StormByte::Crypto::Crypter::Asymmetric::~Asymmetric ( )
overridevirtualnoexcept

Destructor.

◆ Asymmetric() [3/5]

StormByte::Crypto::Crypter::Asymmetric::Asymmetric ( enum Type type,
KeyPair::Generic::PointerType keypair )
inlineprotected

Construct from a keypair pointer.

Parameters
typeCipher.
keypairKeypair.

◆ Asymmetric() [4/5]

StormByte::Crypto::Crypter::Asymmetric::Asymmetric ( enum Type type,
const KeyPair::Generic & keypair )
inlineprotected

Construct by cloning a keypair.

Parameters
typeCipher.
keypairKeypair.

◆ Asymmetric() [5/5]

StormByte::Crypto::Crypter::Asymmetric::Asymmetric ( enum Type type,
KeyPair::Generic && keypair )
inlineprotected

Construct by moving a keypair.

Parameters
typeCipher.
keypairKeypair.

Member Function Documentation

◆ Decrypt() [1/4]

Buffer::Consumer StormByte::Crypto::Crypter::Asymmetric::Decrypt ( Buffer::Consumer consumer,
ReadMode mode = ReadMode::Move ) const
noexcept

Decrypt a Consumer.

Detects Native vs Hybrid.

Parameters
consumerInput consumer.
modeCopy or move.
Returns
Consumer with plaintext.

◆ Decrypt() [2/4]

bool StormByte::Crypto::Crypter::Asymmetric::Decrypt ( Buffer::ReadOnly & input,
Buffer::WriteOnly & output ) const
noexcept

Decrypt a buffer, consuming it.

Detects Native vs Hybrid.

Parameters
inputInput buffer.
outputDestination buffer.
Returns
true on success.

◆ Decrypt() [3/4]

bool StormByte::Crypto::Crypter::Asymmetric::Decrypt ( const Buffer::ReadOnly & input,
Buffer::WriteOnly & output ) const
noexcept

Decrypt a read-only buffer (copy).

Detects Native vs Hybrid.

Parameters
inputInput buffer.
outputDestination buffer.
Returns
true on success.

◆ Decrypt() [4/4]

bool StormByte::Crypto::Crypter::Asymmetric::Decrypt ( std::span< const std::byte > input,
Buffer::WriteOnly & output ) const
noexcept

Decrypt a byte span.

Detects Native vs Hybrid.

Parameters
inputInput bytes.
outputDestination buffer.
Returns
true on success.

◆ Encrypt() [1/4]

Buffer::Consumer StormByte::Crypto::Crypter::Asymmetric::Encrypt ( Buffer::Consumer consumer,
Strategy strategy = Strategy::Native,
ReadMode mode = ReadMode::Move ) const
noexcept

Encrypt a Consumer.

Parameters
consumerInput consumer.
strategyNative or Hybrid. Default Native.
modeCopy or move.
Returns
Consumer with ciphertext.

◆ Encrypt() [2/4]

bool StormByte::Crypto::Crypter::Asymmetric::Encrypt ( Buffer::ReadOnly & input,
Buffer::WriteOnly & output,
Strategy strategy = Strategy::Native ) const
noexcept

Encrypt a buffer, consuming it.

Parameters
inputInput buffer.
outputDestination buffer.
strategyNative or Hybrid. Default Native.
Returns
true on success.

◆ Encrypt() [3/4]

bool StormByte::Crypto::Crypter::Asymmetric::Encrypt ( const Buffer::ReadOnly & input,
Buffer::WriteOnly & output,
Strategy strategy = Strategy::Native ) const
noexcept

Encrypt a read-only buffer (copy).

Parameters
inputInput buffer.
outputDestination buffer.
strategyNative or Hybrid. Default Native.
Returns
true on success.

◆ Encrypt() [4/4]

bool StormByte::Crypto::Crypter::Asymmetric::Encrypt ( std::span< const std::byte > input,
Buffer::WriteOnly & output,
Strategy strategy = Strategy::Native ) const
noexcept

Encrypt a byte span.

Parameters
inputInput bytes.
outputDestination buffer.
strategyNative or Hybrid. Default Native.
Returns
true on success.

◆ KeyPair()

KeyPair::Generic::PointerType StormByte::Crypto::Crypter::Asymmetric::KeyPair ( ) const
inlinenoexcept

Keypair used by this crypter.

Returns
Shared keypair.

◆ operator=() [1/2]

Asymmetric & StormByte::Crypto::Crypter::Asymmetric::operator= ( Asymmetric && other)
defaultnoexcept

Move assignment.

Parameters
otherCrypter to move.
Returns
Reference to this crypter.

◆ operator=() [2/2]

Asymmetric & StormByte::Crypto::Crypter::Asymmetric::operator= ( const Asymmetric & other)
default

Copy assignment.

Parameters
otherCrypter to copy.
Returns
Reference to this crypter.

Member Data Documentation

◆ m_keypair

KeyPair::Generic::PointerType StormByte::Crypto::Crypter::Asymmetric::m_keypair
protected

Shared keypair.


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