46#include <initializer_list>
137 Wipe(std::span<std::byte>(bytes.data(), bytes.capacity()));
139 bytes.shrink_to_fit();
147 template<Type::ByteInputRange R>
155 template<Type::ByteInputRange R>
199 explicit operator
std::vector<
std::
byte>() const& = delete;
204 explicit operator
std::vector<
std::
byte>() && = delete;
243 template<
Type::ByteInputRange R>
245 if constexpr (
requires { std::size(range); })
247 for (
auto&&
byte : range)
251 template<Type::ByteInputRange R>
253 using U = std::remove_cvref_t<R>;
257 if constexpr (
requires { std::size(range); })
259 for (
auto&&
byte : range)
Count of octets (uint64_t storage).
Definition byte_size.hxx:105
std::byte * data() noexcept
Mutable pointer to the first byte, or null when empty.
static void Wipe(std::span< std::byte > bytes) noexcept
Zero bytes.
void reserve(const ByteSize &new_cap)
Request capacity of at least new_cap bytes.
STORMBYTE_FORCE_INLINE std::span< std::byte > span() noexcept
Mutable view of the occupied bytes.
Definition binary.hxx:458
void push_back(std::byte value)
Append one byte.
ByteSize size() const noexcept
Occupied length in bytes.
Binary & operator=(const Binary &other)
Copy assign.
Binary() noexcept
Construct an empty sequence.
Binary for secrets: every byte it drops or releases is zeroed first.
Definition secure_binary.hxx:74
SecureBinary() noexcept
Construct an empty sequence.
bool ConstantTimeCompare() const noexcept override
Equality with this object never stops at the first difference.
void Discard(std::span< std::byte > bytes) noexcept override
Zero bytes.
SecureBinary(SecureBinary &&other) noexcept
Move construct.
void Release(std::span< std::byte > block) noexcept override
Unlock the pages of block once no other block on the same pages is locked.
STORMBYTE_FORCE_INLINE SecureBinary(std::vector< std::byte > &&bytes)
Copy bytes from a caller-owned vector, then zero and release it.
Definition secure_binary.hxx:136
void Acquire(std::span< std::byte > block) noexcept override
Best effort: lock the pages of block in memory so they are not written to swap.
~SecureBinary() noexcept override
Zero the whole block, then release it.
SecureBinary(const SecureBinary &other)
Copy construct.
String HexDump() const =delete
Not available: the dump would hold the secret in memory that is never wiped.
Owned UTF-8 text.
Definition string.hxx:113
Count of abstract units (uint64_t storage).
Definition size.hxx:107
Derived derives from Base (std::is_base_of).
Definition relations.hxx:156
Lvalue reference type (std::is_lvalue_reference).
Definition categories.hxx:97
Owned values that cross a DLL without the caller's CRT.
Root namespace of the StormByte suite.
Octet count. Defined in byte_size.hxx. Forwarded so Type::Numeral can name it.
#define STORMBYTE_PUBLIC
Definition visibility.h:52