StormByte C++ Library: Crypto module 0.0.9999
StormByte-Crypto is a StormByte library module for handling cryptographic operations
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
StormByte::Crypto::Password Class Reference

Secure, reference-counted container for passwords and binary key material. More...

#include <password.hxx>

Public Member Functions

 Password (std::string value) noexcept
 Construct from a std::string (copied byte-for-byte, then wiped).
 
 Password (const char *value) noexcept
 Construct from a C string (copied byte-for-byte up to the terminator).
 
 Password (const void *data, std::size_t size) noexcept
 Construct from raw bytes (exact size, no null terminator added).
 
 Password (const Password &other)=default
 Copy constructor.
 
 Password (Password &&other) noexcept=default
 Move constructor.
 
 ~Password ()=default
 Destructor. Wipes the underlying buffer when this is the last owner.
 
Passwordoperator= (const Password &other)=default
 Copy assignment operator.
 
Passwordoperator= (Password &&other) noexcept=default
 Move assignment operator.
 
std::size_t Size () const noexcept
 Length of the stored material in bytes.
 
bool Empty () const noexcept
 Check whether the password is empty.
 
 operator bool () const noexcept
 Contextual conversion to bool.
 
bool operator== (const Password &other) const noexcept
 Constant-time equality comparison.
 
bool operator!= (const Password &other) const noexcept
 Inequality comparison.
 

Friends

struct Helpers::PasswordAccess
 

Detailed Description

Secure, reference-counted container for passwords and binary key material.

Stores sensitive bytes inside a shared Helpers::SecureContent with automatic wipe when the last owner is destroyed.

Creating unmanaged std::string copies of the content is strongly discouraged and would bypass the secure lifecycle of this class.

Constructor & Destructor Documentation

◆ Password() [1/5]

StormByte::Crypto::Password::Password ( std::string  value)
explicitnoexcept

Construct from a std::string (copied byte-for-byte, then wiped).

Parameters
valuePassword characters. The parameter is securely wiped before return.

◆ Password() [2/5]

StormByte::Crypto::Password::Password ( const char *  value)
explicitnoexcept

Construct from a C string (copied byte-for-byte up to the terminator).

Parameters
valueNull-terminated password. The pointed memory is not wiped.

◆ Password() [3/5]

StormByte::Crypto::Password::Password ( const void *  data,
std::size_t  size 
)
noexcept

Construct from raw bytes (exact size, no null terminator added).

Parameters
dataPointer to the bytes (may be nullptr if size is 0).
sizeNumber of bytes to store.

◆ Password() [4/5]

StormByte::Crypto::Password::Password ( const Password other)
default

Copy constructor.

Parameters
otherThe other Password to copy from (shares ownership).

◆ Password() [5/5]

StormByte::Crypto::Password::Password ( Password &&  other)
defaultnoexcept

Move constructor.

Parameters
otherThe other Password to move from.

Member Function Documentation

◆ Empty()

bool StormByte::Crypto::Password::Empty ( ) const
noexcept

Check whether the password is empty.

Returns
true if Size() is 0, false otherwise.

◆ operator bool()

StormByte::Crypto::Password::operator bool ( ) const
explicitnoexcept

Contextual conversion to bool.

Returns
true if the password is not empty, false otherwise.

◆ operator!=()

bool StormByte::Crypto::Password::operator!= ( const Password other) const
noexcept

Inequality comparison.

Parameters
otherThe other Password to compare with.
Returns
true if not equal, false otherwise.

◆ operator=() [1/2]

Password & StormByte::Crypto::Password::operator= ( const Password other)
default

Copy assignment operator.

Parameters
otherThe other Password to copy from.
Returns
Reference to this Password.

◆ operator=() [2/2]

Password & StormByte::Crypto::Password::operator= ( Password &&  other)
defaultnoexcept

Move assignment operator.

Parameters
otherThe other Password to move from.
Returns
Reference to this Password.

◆ operator==()

bool StormByte::Crypto::Password::operator== ( const Password other) const
noexcept

Constant-time equality comparison.

Parameters
otherThe other Password to compare with.
Returns
true if both have the same length and content, false otherwise.

◆ Size()

std::size_t StormByte::Crypto::Password::Size ( ) const
noexcept

Length of the stored material in bytes.

Returns
Exact byte count (no implied null terminator).

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