qca
QCA::MemoryRegion Class Reference
[QCA user API]
Array of bytes that may be optionally secured. More...
#include <QtCrypto>

Public Member Functions | |
| MemoryRegion (const MemoryRegion &from) | |
| MemoryRegion (const QByteArray &from) | |
| MemoryRegion (const char *str) | |
| MemoryRegion () | |
| ~MemoryRegion () | |
| const char & | at (int index) const |
| const char * | constData () const |
| const char * | data () const |
| bool | isEmpty () const |
| bool | isNull () const |
| bool | isSecure () const |
| MemoryRegion & | operator= (const QByteArray &from) |
| MemoryRegion & | operator= (const MemoryRegion &from) |
| int | size () const |
| QByteArray | toByteArray () const |
Protected Member Functions | |
| MemoryRegion (const QByteArray &from, bool secure) | |
| MemoryRegion (int size, bool secure) | |
| MemoryRegion (bool secure) | |
| char & | at (int index) |
| char * | data () |
| bool | resize (int size) |
| void | set (const QByteArray &from, bool secure) |
| void | setSecure (bool secure) |
Detailed Description
Array of bytes that may be optionally secured.
This class is mostly unusable on its own. Either use it as a SecureArray subclass or call toByteArray() to convert to QByteArray.
Note that this class is implicitly shared (that is, copy on write).
Definition at line 90 of file qca_tools.h.
Constructor & Destructor Documentation
| QCA::MemoryRegion::MemoryRegion | ( | ) |
Definition at line 434 of file qca_tools.cpp.
| QCA::MemoryRegion::MemoryRegion | ( | const char * | str | ) |
Constructs a new Memory Region from a null terminated character array.
- Parameters:
-
str pointer to the array of data to copy
Definition at line 439 of file qca_tools.cpp.
| QCA::MemoryRegion::MemoryRegion | ( | const QByteArray & | from | ) |
Constructs a new MemoryRegion from the data in a byte array.
- Parameters:
-
from the QByteArray to copy from
Definition at line 444 of file qca_tools.cpp.
| QCA::MemoryRegion::MemoryRegion | ( | const MemoryRegion & | from | ) |
Standard copy constructor.
- Parameters:
-
from the MemoryRegion to copy from
Definition at line 449 of file qca_tools.cpp.
| QCA::MemoryRegion::~MemoryRegion | ( | ) |
Definition at line 454 of file qca_tools.cpp.
| QCA::MemoryRegion::MemoryRegion | ( | bool | secure | ) | [protected] |
Create a memory region, optionally using secure storage.
- Parameters:
-
secure if this is true, the memory region will use secure storage.
- Note:
- This will create a memory region without any content (i.e. both isNull() and isEmpty() will return true.
Definition at line 501 of file qca_tools.cpp.
| QCA::MemoryRegion::MemoryRegion | ( | int | size, | |
| bool | secure | |||
| ) | [protected] |
Create a memory region, optionally using secure storage.
- Parameters:
-
size the number of bytes in the memory region. secure if this is true, the memory region will use secure storage.
Definition at line 506 of file qca_tools.cpp.
| QCA::MemoryRegion::MemoryRegion | ( | const QByteArray & | from, | |
| bool | secure | |||
| ) | [protected] |
Create a memory region, optionally using secure storage.
This constructor variant allows you to initialize the memory region from an existing array.
- Parameters:
-
from the byte array to copy from. secure if this is true, the memory region will use secure storage.
Definition at line 511 of file qca_tools.cpp.
Member Function Documentation
| char & QCA::MemoryRegion::at | ( | int | index | ) | [protected] |
Obtain the value of the memory location at the specified position.
- Parameters:
-
index the offset into the memory region.
- Note:
- The contents of a memory region are between 0 and size()-1. The content at position size() is always a null terminator.
Reimplemented in QCA::SecureArray.
Definition at line 537 of file qca_tools.cpp.
| const char & QCA::MemoryRegion::at | ( | int | index | ) | const |
Obtain the value of the memory location at the specified position.
- Parameters:
-
index the offset into the memory region.
- Note:
- The contents of a memory region are between 0 and size()-1. The content at position size() is always a null terminator.
Reimplemented in QCA::SecureArray.
Definition at line 542 of file qca_tools.cpp.
| const char * QCA::MemoryRegion::constData | ( | ) | const |
Convert the contents of the memory region to a C-compatible character array.
This consists of size() bytes, followed by a null terminator.
- See also:
- toByteArray for an alternative approach.
- data which is equivalent to this method
Reimplemented in QCA::SecureArray.
Definition at line 530 of file qca_tools.cpp.
| char * QCA::MemoryRegion::data | ( | ) | [protected] |
Convert the contents of the memory region to a C-compatible character array.
This consists of size() bytes, followed by a null terminator.
Reimplemented in QCA::SecureArray.
Definition at line 516 of file qca_tools.cpp.
| const char * QCA::MemoryRegion::data | ( | ) | const |
Convert the contents of the memory region to a C-compatible character array.
This consists of size() bytes, followed by a null terminator.
- See also:
- toByteArray for an alternative approach.
- constData, which is equivalent to this method, but avoids the possibility that the compiler picks the wrong version.
Reimplemented in QCA::SecureArray.
Definition at line 523 of file qca_tools.cpp.
| bool QCA::MemoryRegion::isEmpty | ( | ) | const |
Returns true if the size of the memory region is zero.
Reimplemented in QCA::SecureArray.
Definition at line 554 of file qca_tools.cpp.
| bool QCA::MemoryRegion::isNull | ( | ) | const |
Test if the MemoryRegion is null (i.e.
was created as a null array, and hasn't been resized).
This is probably not what you are trying to do. If you are trying to determine whether there are any bytes in the array, use isEmpty() instead.
Definition at line 471 of file qca_tools.cpp.
| bool QCA::MemoryRegion::isSecure | ( | ) | const |
Test if the MemoryRegion is using secure memory, or not.
In this context, memory is secure if it will not be paged out to disk.
- Returns:
- true if the memory region is secure
Definition at line 476 of file qca_tools.cpp.
| MemoryRegion & QCA::MemoryRegion::operator= | ( | const QByteArray & | from | ) |
Standard assignment operator.
- Parameters:
-
from the QByteArray to copy from
Reimplemented in QCA::SecureArray.
Definition at line 465 of file qca_tools.cpp.
| MemoryRegion & QCA::MemoryRegion::operator= | ( | const MemoryRegion & | from | ) |
Standard assignment operator.
- Parameters:
-
from the MemoryRegion to copy from
Reimplemented in QCA::SecureArray.
Definition at line 458 of file qca_tools.cpp.
| bool QCA::MemoryRegion::resize | ( | int | size | ) | [protected] |
Resize the memory region to the specified size.
- Parameters:
-
size the new size of the region.
Reimplemented in QCA::SecureArray.
Definition at line 561 of file qca_tools.cpp.
| void QCA::MemoryRegion::set | ( | const QByteArray & | from, | |
| bool | secure | |||
| ) | [protected] |
Modify the memory region to match a specified byte array.
This resizes the memory region as required to match the byte array size.
- Parameters:
-
from the byte array to copy from. secure if this is true, the memory region will use secure storage.
Definition at line 575 of file qca_tools.cpp.
| void QCA::MemoryRegion::setSecure | ( | bool | secure | ) | [protected] |
Convert the memory region to use the specified memory type.
This may involve copying data from secure to insecure storage, or from insecure to secure storage.
- Parameters:
-
secure if true, use secure memory; otherwise use insecure memory.
Definition at line 585 of file qca_tools.cpp.
| int QCA::MemoryRegion::size | ( | ) | const |
Returns the number of bytes in the memory region.
Reimplemented in QCA::SecureArray.
Definition at line 547 of file qca_tools.cpp.
| QByteArray QCA::MemoryRegion::toByteArray | ( | ) | const |
Convert this memory region to a byte array.
- Note:
- For secure data, this will make it insecure
- See also:
- data() and constData() for other ways to convert to an "accessible" format.
Reimplemented in QCA::SecureArray.
Definition at line 481 of file qca_tools.cpp.
The documentation for this class was generated from the following files:
KDE 4.4 API Reference