|
libkeepass 0.2.0
KeePass key database importer/exporter library
|
String that is stored in wiped and best-effort locked memory. More...
#include <secure.hh>
Public Member Functions | |
| secure_string () | |
| Constructs an empty string. | |
| secure_string (const char *str) | |
| Constructs a string from a NUL-terminated C string. | |
| secure_string (const std::string &str) | |
| Constructs a string from a std::string. | |
| secure_string (const secure_string &other) | |
| Copy-constructs by allocating a fresh wiped buffer. | |
| secure_string (secure_string &&other) noexcept | |
| Move-constructs, wiping the moved-from string. | |
| secure_string & | operator= (const secure_string &other) |
| Copy-assigns by allocating a fresh wiped buffer. | |
| secure_string & | operator= (secure_string &&other) noexcept |
| Move-assigns, wiping the previous content and the moved-from string. | |
| secure_string & | operator= (const char *str) |
| Assigns from a NUL-terminated C string. | |
| secure_string & | operator= (const std::string &str) |
| Assigns from a std::string. | |
| ~secure_string () | |
| Zeroizes and releases the stored memory. | |
| const char * | data () const noexcept |
| Returns a pointer to the (NUL-terminated) character data. | |
| char * | data () noexcept |
| Returns a pointer to the character data for in-place modification. | |
| char * | begin () noexcept |
| Returns an iterator to the first character. | |
| const char * | begin () const noexcept |
| Returns an iterator to the first character. | |
| char * | end () noexcept |
| Returns an iterator past the last character. | |
| const char * | end () const noexcept |
| Returns an iterator past the last character. | |
| std::size_t | size () const noexcept |
| Returns the number of characters (excluding the trailing NUL). | |
| std::size_t | length () const noexcept |
| Returns the number of characters. | |
| bool | empty () const noexcept |
| Returns whether the string is empty. | |
| const char * | c_str () const noexcept |
| Returns a NUL-terminated pointer to the character data. | |
| std::string | str () const |
| Returns an explicit std::string copy of the value. | |
| void | clear () |
| Erases the content, wiping the memory. | |
| void | assign (const char *str) |
| Replaces the value with a NUL-terminated C string. | |
| void | assign (const std::string &str) |
| Replaces the value with a std::string. | |
| void | assign (const char *data, std::size_t size) |
| Replaces the value with a byte range of explicitly known length. | |
String that is stored in wiped and best-effort locked memory.
Unlike std::string, the value is never held in inline (SSO) storage; it is always kept in a separately allocated, zeroized buffer. The memory is erased when the string is destroyed, cleared or overwritten.
The string does not implicitly convert to std::string in order to avoid silently producing unsecured copies of sensitive data. Use str() when an explicit std::string copy is required.