Disk ARchive
2.4.21
|
class secu_string More...
#include <secu_string.hpp>
Public Member Functions | |
secu_string (U_I size=0) | |
constructor More... | |
secu_string (const char *ptr, U_I size) | |
constructor More... | |
secu_string (const secu_string &ref) | |
the copy constructor | |
secu_string & | operator= (const secu_string &ref) |
the assignment operator | |
bool | operator!= (const std::string &ref) const |
bool | operator!= (const secu_string &ref) const |
bool | operator== (const std::string &ref) const |
bool | operator== (const secu_string &ref) const |
~secu_string () | |
the destructor (set memory to zero before releasing it) | |
void | read (int fd, U_I size) |
fill the object with data More... | |
void | append (const char *ptr, U_I size) |
append some data to the string More... | |
void | append (int fd, U_I size) |
append some data to the string | |
void | reduce_string_size_to (U_I pos) |
void | clear () |
clear the string (ans set its allocated string to zero) | |
void | clear_and_resize (U_I size) |
clear and resize the string to the defined allocated size More... | |
void | clear_and_not_resize () |
const char * | c_str () const |
get access to the secure string More... | |
U_I | size () const |
get the size of the string More... | |
Static Public Member Functions | |
static bool | is_string_secured () |
to know if secure memory is available More... | |
class secu_string
it manages the allocation/release of a given size block of memory and let the user feed it from a filedescriptor and access to it under with a char* pointer. if more constructor are needed (espetially toward API), tell me, but this is a non-sens to build a secure string from another data structure which is not yet secured, where from the read() method that fetches data directly from a filedescriptor (read() low-level system call) which might be a tty for example
Definition at line 57 of file secu_string.hpp.
|
inline |
constructor
create the allocated string in secure memory
[in] | size | is the amount of secured memory to obtain when creating the object |
Definition at line 72 of file secu_string.hpp.
References size().
|
inline |
constructor
create the string from a pointer to a (secure) string or from a portion of it
Definition at line 77 of file secu_string.hpp.
References append().
void libdar::secu_string::append | ( | const char * | ptr, |
U_I | size | ||
) |
append some data to the string
[in] | ptr | is the address of the string to append |
[in] | size | is the number of byte to append |
Referenced by secu_string(), and ~secu_string().
|
inline |
get access to the secure string
Definition at line 134 of file secu_string.hpp.
Referenced by libdar_4_4::user_interaction::get_secu_string().
|
inline |
clear and resize the string to the defined allocated size
[in] | size | is the amount of secure memory to allocated |
Definition at line 125 of file secu_string.hpp.
|
static |
to know if secure memory is available
it is advised that the user program of class secu_string uses this call before using objects of that class and if returned false, advise the user that the necessary support for secure memory is not present, that any sensitive data may be swapped out under heavy memory load and thus may lead secure password to be wrote to disk in clear.
void libdar::secu_string::read | ( | int | fd, |
U_I | size | ||
) |
fill the object with data
reads at most size bytes of data directly from the filedescriptor,
[in] | fd | the filedescriptor to read data from |
[in] | size | is the maximum number of byte read |
Referenced by ~secu_string().
void libdar::secu_string::reduce_string_size_to | ( | U_I | pos | ) |
shorten the string (do not change the allocated size)
[in] | pos | is the length of the string to set, it must be smaller or equal to the current size |
Referenced by ~secu_string().
|
inline |
get the size of the string
this is the amount of data read from the filedescriptor up to the first new-line character.
Definition at line 140 of file secu_string.hpp.
Referenced by secu_string(), and ~secu_string().