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

Password-based symmetric crypter. More...

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

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

Public Member Functions

const Secure::Password & Password () const noexcept
 Password used by this crypter.
Construction
 Symmetric (const Symmetric &other)=default
 Copy constructor.
 Symmetric (Symmetric &&other) noexcept=default
 Move constructor.
virtual ~Symmetric () noexcept override
 Destructor.
Symmetric & operator= (const Symmetric &other)=default
 Copy assignment.
Symmetric & operator= (Symmetric &&other) noexcept=default
 Move assignment.
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

Static Public Member Functions

static Secure::Password RandomPassword (size_t length=32) noexcept
 Random password of raw bytes (not text).
Static Public Member Functions inherited from StormByte::Safe::Clonable< Generic >
static PointerType MakePointer (Args &&... args)

Protected Member Functions

 Symmetric (enum Type type, Secure::Password password)
 Construct with a cipher and a password.
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

Secure::Password m_password
 Shared password.
Protected Attributes inherited from StormByte::Crypto::Crypter::Generic
enum Type m_type
 Cipher.

Additional Inherited Members

Public Types inherited from StormByte::Safe::Clonable< Generic >
typedef SmartPointer PointerType

Detailed Description

Password-based symmetric crypter.

Copies share the same StormByte::Crypto::Secure::Password. The buffer is wiped when the last owner is destroyed.

Note
MaybeSafe inherits all requirements of StormByte::Crypto::Crypter::Generic, including ABI-compatible toolchains and keeping all provider modules loaded. The Password field is Safe and delegates ownership to exported Password/Safe operations; inline construction, copying, assignment and movement do not own local heap storage. Destruction is exported. Derived providers must preserve these guarantees for every added field and bind owning Clone/Move creator/deleter callbacks in their provider module.

Constructor & Destructor Documentation

◆ Symmetric() [1/3]

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

Copy constructor.

Parameters
otherCrypter to copy.

◆ Symmetric() [2/3]

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

Move constructor.

Parameters
otherCrypter to move.

◆ ~Symmetric()

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

Destructor.

◆ Symmetric() [3/3]

StormByte::Crypto::Crypter::Symmetric::Symmetric ( enum Type type,
Secure::Password password )
inlineprotected

Construct with a cipher and a password.

Parameters
typeCipher.
passwordPassword.

Member Function Documentation

◆ operator=() [1/2]

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

Copy assignment.

Parameters
otherCrypter to copy.
Returns
Reference to this crypter.

◆ operator=() [2/2]

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

Move assignment.

Parameters
otherCrypter to move.
Returns
Reference to this crypter.

◆ Password()

const Secure::Password & StormByte::Crypto::Crypter::Symmetric::Password ( ) const
inlinenoexcept

Password used by this crypter.

Returns
Shared password.
Note
Shares ownership of the underlying bytes.

◆ RandomPassword()

Secure::Password StormByte::Crypto::Crypter::Symmetric::RandomPassword ( size_t length = 32)
staticnoexcept

Random password of raw bytes (not text).

Parameters
lengthNumber of bytes.
Returns
Password.

Member Data Documentation

◆ m_password

Secure::Password StormByte::Crypto::Crypter::Symmetric::m_password
protected

Shared password.


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