| Disk ARchive 2.5.10 Full featured and portable backup and archiving tool

- Main Page
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | List of all members
libdar::secu_string Class Reference
Private

class secu_string More...

`#include <secu_string.hpp>`

Inherits libdar::on_pool.

## Public Member Functions
| secu_string (U_I storage_size=0)
| secu_string (const char *ptr, U_I size)
| 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 () throw (Ebug)
| the destructor (set memory to zero before releasing it)
void | set (int fd, U_I size)
void | append_at (U_I offset, const char *ptr, U_I size)
void | append_at (U_I offset, int fd, U_I size)
| append some data to the string
void | append (const char *ptr, U_I size)
| append some data at the end of the string
void | append (int fd, U_I size)
| append some data at the end of the string
void | reduce_string_size_to (U_I pos)
void | clear ()
| clear the string (set to an empty string)
void | resize (U_I size)
void | randomize (U_I size)
const char * | c_str () const
| get access to the secure string More...
char & | operator[] (U_I index)
char | operator[] (U_I index) const
U_I | get_size () const
| get the size of the string
U_I | get_allocated_size () const
| get the size of the allocated secure space
Public Member Functions inherited from libdar::on_pool
void * | operator new (size_t n_byte)
void * | operator new (size_t n_byte, const std::nothrow_t &nothrow_value)
void * | operator new[] (size_t n_byte)
void * | operator new[] (size_t n_byte, const std::nothrow_t &nothrow_value)
void * | operator new (size_t n_byte, memory_pool *p)
void * | operator new[] (size_t n_byte, memory_pool *p)
void | operator delete (void *ptr, memory_pool *p)
| this operator is called by the compiler if an exception is throw from the constructor of the allocated object
void | operator delete[] (void *ptr, memory_pool *p)
| this operator is called by the compiler if an exception is throw from the constructor of the allocated objects
void | operator delete (void *ptr)
| this is the usual delete operator, modified to handle allocated objects allocated on a memory pool or not
void | operator delete[] (void *ptr)
| this is the usual delete[] operator, modified to handle allocated objects allocated on a memory pool or not

## Static Public Member Functions
static bool | is_string_secured ()

## Additional Inherited Members
Protected Member Functions inherited from libdar::on_pool
memory_pool * | get_pool () const
template<class T >
void | meta_new (T *&ptr, size_t num)
template<class T >
void | meta_delete (T *ptr)

## Detailed Description

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.

## Constructor & Destructor Documentation

libdar::secu_string::secu_string | ( | U_I | storage_size = `0` | ) |
| inline

constructor 1

create the allocated string in secure memory

Parameters

  [in] | storage_size | is the amount of secured memory to obtain when creating the object

Definition at line 72 of file secu_string.hpp.

libdar::secu_string::secu_string | ( | const char * | ptr,
|  | U_I | size
| ) |  |
| inline

constructor 2

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_at().

## Member Function Documentation

void libdar::secu_string::append_at | ( | U_I | offset,
|  | const char * | ptr,
|  | U_I | size
| ) |  |

append some data to the string at a given offset

Parameters

  [in] | offset | defines at which offset in the secu_string will be placed the string to append
  [in] | ptr | is the address of the string to append
  [in] | size | is the number of byte to append

Note
  this call does not change the allocation size, (unlike read()), it adds the data pointed by the arguments to the object while there is enough place to do so. resize() must be used first to define enough secure memory to append the expected amount of data in one or several call to append.

Referenced by append(), and secu_string().

const char* libdar::secu_string::c_str | ( |  | ) | const
| inline

get access to the secure string

Returns
  the address of the first byte of the string

Note
  check the "size" method to know how much bytes can be read

Definition at line 144 of file secu_string.hpp.

static bool libdar::secu_string::is_string_secured | ( |  | ) |
| 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.

char& libdar::secu_string::operator[] | ( | U_I | index | ) |

get access to the secure string by index

Note
  index must be in the range [ 0 - size() [ to avoid throwing an exception

void libdar::secu_string::randomize | ( | U_I | size | ) |

set the string to randomize string of given size

Note
  the given size must be less than allocated size

void libdar::secu_string::reduce_string_size_to | ( | U_I | pos | ) |

shorten the string (do not change the allocated size)

Parameters

  [in] | pos | is the length of the string to set, it must be smaller or equal to the current size

void libdar::secu_string::resize | ( | U_I | size | ) |
| inline

clear and resize the string to the defined allocated size

Parameters

  [in] | size | is the amount of secure memory to allocated

Definition at line 133 of file secu_string.hpp.

void libdar::secu_string::set | ( | int | fd,
|  | U_I | size
| ) |  |

fill the object with data

set at most size bytes of data directly from the filedescriptor,

Parameters

  [in] | fd | the filedescriptor to read data from
  [in] | size | is the maximum number of byte read

Note
  if current storage size is not larg enough to hold size bytes, allocated secure memory is released and larger allocation of secure memory is done.

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

- secu_string.hpp