• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDE Support
  • Sitemap
  • Contact Us
 

qca

QCA::SecureArray

QCA::SecureArray Class Reference
[QCA user API]

Secure array of bytes. More...

#include <QtCrypto>

Inheritance diagram for QCA::SecureArray:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 SecureArray (const SecureArray &from)
 SecureArray (const MemoryRegion &a)
 SecureArray (const QByteArray &a)
 SecureArray (const char *str)
 SecureArray (int size, char ch=0)
 SecureArray ()
 ~SecureArray ()
SecureArray & append (const SecureArray &a)
const char & at (int index) const
char & at (int index)
void clear ()
const char * constData () const
const char * data () const
char * data ()
void fill (char fillChar, int fillToPosition=-1)
bool isEmpty () const
bool operator!= (const MemoryRegion &other) const
SecureArray & operator+= (const SecureArray &a)
SecureArray & operator= (const QByteArray &a)
SecureArray & operator= (const SecureArray &from)
bool operator== (const MemoryRegion &other) const
const char & operator[] (int index) const
char & operator[] (int index)
bool resize (int size)
int size () const
QByteArray toByteArray () const

Protected Member Functions

void set (const QByteArray &from)
void set (const SecureArray &from)

Detailed Description

Secure array of bytes.

The SecureArray provides an array of memory from a pool that is, at least partly, secure. In this sense, secure means that the contents of the memory should not be made available to other applications. By comparison, a QByteArray or QString may be held in pages that might be swapped to disk or free'd without being cleared first.

Note that this class is implicitly shared (that is, copy on write).

Definition at line 316 of file qca_tools.h.


Constructor & Destructor Documentation

QCA::SecureArray::SecureArray (  ) 

Construct a secure byte array, zero length.

Definition at line 601 of file qca_tools.cpp.

QCA::SecureArray::SecureArray ( int  size,
char  ch = 0 
) [explicit]

Construct a secure byte array of the specified length.

Parameters:
size the number of bytes in the array
ch the value every byte should be set to

Definition at line 606 of file qca_tools.cpp.

QCA::SecureArray::SecureArray ( const char *  str  ) 

Construct a secure byte array from a string.

Note that this copies, rather than references the source array.

Parameters:
str the source of the data (as a null terminated string).

Definition at line 614 of file qca_tools.cpp.

QCA::SecureArray::SecureArray ( const QByteArray &  a  ) 

Construct a secure byte array from a QByteArray.

Note that this copies, rather than references the source array.

Parameters:
a the source of the data.
See also:
operator=()

Definition at line 619 of file qca_tools.cpp.

QCA::SecureArray::SecureArray ( const MemoryRegion &  a  ) 

Construct a secure byte array from a MemoryRegion.

Note that this copies, rather than references the source array

Parameters:
a the source of the data.
See also:
operator=()

Definition at line 624 of file qca_tools.cpp.

QCA::SecureArray::SecureArray ( const SecureArray &  from  ) 

Construct a (shallow) copy of another secure byte array.

Parameters:
from the source of the data and length.

Definition at line 630 of file qca_tools.cpp.

QCA::SecureArray::~SecureArray (  ) 

Definition at line 635 of file qca_tools.cpp.


Member Function Documentation

SecureArray & QCA::SecureArray::append ( const SecureArray &  a  ) 

Append a secure byte array to the end of this array.

Parameters:
a the array to append to this array

Definition at line 711 of file qca_tools.cpp.

const char & QCA::SecureArray::at ( int  index  )  const

Returns a reference to the byte at the index position.

Parameters:
index the zero-based offset to obtain

Reimplemented from QCA::MemoryRegion.

Definition at line 676 of file qca_tools.cpp.

char & QCA::SecureArray::at ( int  index  ) 

Returns a reference to the byte at the index position.

Parameters:
index the zero-based offset to obtain

Reimplemented from QCA::MemoryRegion.

Definition at line 671 of file qca_tools.cpp.

void QCA::SecureArray::clear (  ) 

Clears the contents of the array and makes it empty.

Definition at line 651 of file qca_tools.cpp.

const char * QCA::SecureArray::constData (  )  const

Pointer to the data in the secure array.

You can use this for memcpy and similar functions. If you are trying to obtain data at a particular offset, you might be better off using at() or operator[]

Reimplemented from QCA::MemoryRegion.

Definition at line 691 of file qca_tools.cpp.

const char * QCA::SecureArray::data (  )  const

Pointer to the data in the secure array.

You can use this for memcpy and similar functions. If you are trying to obtain data at a particular offset, you might be better off using at() or operator[]

Reimplemented from QCA::MemoryRegion.

Definition at line 686 of file qca_tools.cpp.

char * QCA::SecureArray::data (  ) 

Pointer to the data in the secure array.

You can use this for memcpy and similar functions. If you are trying to obtain data at a particular offset, you might be better off using at() or operator[]

Reimplemented from QCA::MemoryRegion.

Definition at line 681 of file qca_tools.cpp.

void QCA::SecureArray::fill ( char  fillChar,
int  fillToPosition = -1 
)

Fill the data array with a specified character.

Parameters:
fillChar the character to use as the fill
fillToPosition the number of characters to fill to. If not specified (or -1), fills array to current length.
Note:
This function does not extend the array - if you ask for fill beyond the current length, only the current length will be used.
The number of characters is 1 based, so if you ask for fill('x', 10), it will fill from

Definition at line 733 of file qca_tools.cpp.

bool QCA::SecureArray::isEmpty (  )  const

Test if the array contains any bytes.

This is equivalent to testing (size() != 0). Note that if the array is allocated, isEmpty() is false (even if no data has been added)

Returns:
true if the array has zero length, otherwise false

Reimplemented from QCA::MemoryRegion.

Definition at line 701 of file qca_tools.cpp.

bool QCA::SecureArray::operator!= ( const MemoryRegion &  other  )  const [inline]

Inequality operator.

Returns true if both arrays have different length, or the same length but different data.

Parameters:
other the MemoryRegion to compare to

Definition at line 516 of file qca_tools.h.

SecureArray & QCA::SecureArray::operator+= ( const SecureArray &  a  ) 

Append a secure byte array to the end of this array.

Parameters:
a the array to append to this array

Definition at line 728 of file qca_tools.cpp.

SecureArray & QCA::SecureArray::operator= ( const QByteArray &  a  ) 

Creates a copy, rather than references.

Parameters:
a the array to copy from

Reimplemented from QCA::MemoryRegion.

Definition at line 645 of file qca_tools.cpp.

SecureArray & QCA::SecureArray::operator= ( const SecureArray &  from  ) 

Creates a reference, rather than a deep copy.

Parameters:
from the array to reference

Reimplemented from QCA::MemoryRegion.

Definition at line 639 of file qca_tools.cpp.

bool QCA::SecureArray::operator== ( const MemoryRegion &  other  )  const

Equality operator.

Returns true if both arrays have the same data (and the same length, of course).

Parameters:
other the MemoryRegion to compare to

Definition at line 719 of file qca_tools.cpp.

const char & QCA::SecureArray::operator[] ( int  index  )  const

Returns a reference to the byte at the index position.

Parameters:
index the zero-based offset to obtain

Definition at line 666 of file qca_tools.cpp.

char & QCA::SecureArray::operator[] ( int  index  ) 

Returns a reference to the byte at the index position.

Parameters:
index the zero-based offset to obtain

Definition at line 661 of file qca_tools.cpp.

bool QCA::SecureArray::resize ( int  size  ) 

Change the length of this array If the new length is less than the old length, the extra information is (safely) discarded.

If the new length is equal to or greater than the old length, the existing data is copied into the array.

Parameters:
size the new length

Reimplemented from QCA::MemoryRegion.

Definition at line 656 of file qca_tools.cpp.

void QCA::SecureArray::set ( const QByteArray &  from  )  [protected]

Assign the contents of a provided byte array to this object.

Parameters:
from the byte array to copy

Definition at line 745 of file qca_tools.cpp.

void QCA::SecureArray::set ( const SecureArray &  from  )  [protected]

Assign the contents of a provided byte array to this object.

Parameters:
from the byte array to copy

Definition at line 740 of file qca_tools.cpp.

int QCA::SecureArray::size (  )  const

Returns the number of bytes in the array.

Reimplemented from QCA::MemoryRegion.

Definition at line 696 of file qca_tools.cpp.

QByteArray QCA::SecureArray::toByteArray (  )  const

Copy the contents of the secure array out to a standard QByteArray.

Note that this performs a deep copy of the data.

Reimplemented from QCA::MemoryRegion.

Definition at line 706 of file qca_tools.cpp.


The documentation for this class was generated from the following files:
  • qca_tools.h
  • qca_tools.cpp

qca

Skip menu "qca"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDE Support

Skip menu "KDE Support"
  • akonadi
  • Decibel
  • grantlee
  • kdewin
  • phonon
  •     Backend
  • polkit-qt
  • qca
  • qimageblitz
  • soprano
  • strigi
  •     searchclient
  •     streamanalyzer
  •     streams
Generated for KDE Support by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal