Shared, wiped container for passwords and raw key material. More...
#include <StormByte/crypto/secure/password.hxx>
Public Member Functions | |
| StormByte::ByteSize | Size () const noexcept |
| Stored size in bytes. | |
| bool | Empty () const noexcept |
| Whether Size() is 0. | |
| operator bool () const noexcept | |
| true if the password is not empty. | |
| bool | operator== (const Password &other) const noexcept |
| Constant-time equality. | |
| bool | operator!= (const Password &other) const noexcept |
| Inequality. | |
Construction | |
| Password () noexcept | |
| Empty password, suitable for Safe collections. | |
| Password (std::string_view value) | |
| Copy borrowed text into secure storage without wiping its source. | |
| Password (StormByte::Safe::String &value) | |
| From DLL-safe text. | |
| Password (const char *value) | |
| From a C string up to the terminator. | |
| Password (const void *data, StormByte::ByteSize size) | |
| From raw bytes. | |
| Password (const Password &other) | |
| Copy constructor. | |
| Password (Password &&other) noexcept | |
| Move constructor. | |
| ~Password () | |
| Destructor. | |
| Password & | operator= (const Password &other) |
| Copy assignment. | |
| Password & | operator= (Password &&other) noexcept |
| Move assignment. | |
Friends | |
| struct | Helpers::PasswordAccess |
Shared, wiped container for passwords and raw key material.
Bytes live in Crypto-owned secure storage behind a Safe::Shared owner and are wiped when the last owner is destroyed. Copies share the same buffer. There is no public view of the raw bytes. Borrowed input is copied without wiping its source; mutable Safe text is copied and then wiped.
A borrowed std::string_view preserves its full length, including NUL bytes. The caller remains responsible for wiping that source and any other copies. A mutable Safe::String is ceded instead: construction copies its full length, then overwrites and clears the source. No caller allocation is adopted.
String literals (Password("secret")) use const char*. They are copied and the source is not wiped: a literal lives in read-only storage. That form is for tests and non-secret placeholders, not for production secrets typed in source.
Raw bytes (const void* + StormByte::ByteSize) are copied and not wiped; the caller is responsible for the source buffer.
|
noexcept |
Empty password, suitable for Safe collections.
|
explicit |
Copy borrowed text into secure storage without wiping its source.
| value | Password bytes, including embedded NUL bytes. |
|
explicit |
From DLL-safe text.
Copies into secure storage and wipes value.
| value | Password characters. Emptied and zeroed on return. |
|
explicit |
From a C string up to the terminator.
The source is not wiped.
| value | Null-terminated password (including literals). |
| StormByte::Crypto::Secure::Password::Password | ( | const void * | data, |
| StormByte::ByteSize | size ) |
From raw bytes.
Exact size; no terminator is added. The source is not wiped.
| data | Bytes, or nullptr if size is 0. |
| size | Number of bytes. |
| StormByte::Crypto::Secure::Password::Password | ( | const Password & | other | ) |
|
noexcept |
Move constructor.
| other | Password to move. |
| StormByte::Crypto::Secure::Password::~Password | ( | ) |
Destructor.
Wipes the buffer if this is the last owner.
|
noexcept |
Whether Size() is 0.
|
explicitnoexcept |
true if the password is not empty.
|
noexcept |
Inequality.
| other | Other password. |
|
noexcept |
Constant-time equality.
| other | Other password. |
|
noexcept |
Stored size in bytes.
|
friend |