Botan::SecureVector< T, INITIAL_LEN > Class Template Reference
#include <secmem.h>
List of all members.
Detailed Description
template<typename T, u32bit INITIAL_LEN = 0>
class Botan::SecureVector< T, INITIAL_LEN >
This class represents variable length buffers using the operating systems capability to lock memory, i.e. keeping it from being swapped out to disk. In this way, a security hole allowing attackers to find swapped out secret keys is closed.
Definition at line 354 of file secmem.h.
Constructor & Destructor Documentation
template<typename T, u32bit INITIAL_LEN = 0>
Create a buffer of the specified length.
- Parameters:
-
| n | the length of the buffer to create. |
Definition at line 374 of file secmem.h.
template<typename T, u32bit INITIAL_LEN = 0>
Create a buffer with the specified contents.
- Parameters:
-
| in | the array containing the data to be initially copied into the newly created buffer |
| n | the size of the array in |
Definition at line 383 of file secmem.h.
00384 {
00385 init(true, INITIAL_LEN);
00386 if(INITIAL_LEN)
00387 copy(in, n);
00388 else
00389 set(in, n);
00390 }
template<typename T, u32bit INITIAL_LEN = 0>
Create a buffer with contents specified contents.
- Parameters:
-
| in | the buffer holding the contents that will be copied into the newly created buffer. |
Definition at line 397 of file secmem.h.
00398 {
00399 init(true, INITIAL_LEN);
00400 if(INITIAL_LEN)
00401 copy(in, in.size());
00402 else
00403 set(in);
00404 }
template<typename T, u32bit INITIAL_LEN = 0>
Create a buffer whose content is the concatenation of two other buffers.
- Parameters:
-
| in1 | the first part of the new contents |
| in2 | the contents to be appended to in1 |
Definition at line 412 of file secmem.h.
Member Function Documentation
Append data to the end of this buffer.
- Parameters:
-
| other | the buffer containing the data to append |
Definition at line 161 of file secmem.h.
00162 { append(other.begin(), other.size()); }
Append a single element.
- Parameters:
-
Definition at line 155 of file secmem.h.
Get a constant pointer to the first element in the buffer.
- Returns:
- constant pointer to the first element in the buffer
Definition at line 59 of file secmem.h.
Get a pointer to the first element in the buffer.
- Returns:
- pointer to the first element in the buffer
Definition at line 53 of file secmem.h.
Zeroise the bytes of this buffer. The length remains unchanged.
Definition at line 167 of file secmem.h.
Copy the contents of an array of objects of type T into this buffer. The former contents of *this are discarded. The length of *this must be at least n, otherwise memory errors occur.
- Parameters:
-
| off | the offset position inside this buffer to start inserting the copied bytes |
| in | the array to copy the contents from |
| n | the length of in |
Definition at line 125 of file secmem.h.
Copy the contents of an array of objects of type T into this buffer. The former contents of *this are discarded. The length of *this must be at least n, otherwise memory errors occur.
- Parameters:
-
| in | the array to copy the contents from |
| n | the length of in |
Definition at line 113 of file secmem.h.
Referenced by Botan::SecureVector< u16bit, 100 >::SecureVector().
00114 { copy(0, in, n); }
Reset this buffer to an empty buffer with size zero.
Definition at line 172 of file secmem.h.
Find out whether this buffer is empty.
- Returns:
- true if the buffer is empty, false otherwise
Definition at line 35 of file secmem.h.
00035 { return (used == 0); }
Get a constant pointer to the last element in the buffer.
- Returns:
- constant pointer to the last element in the buffer
Definition at line 71 of file secmem.h.
00071 { return (buf + size()); }
Get a pointer to the last element in the buffer.
- Returns:
- pointer to the last element in the buffer
Definition at line 65 of file secmem.h.
00065 { return (buf + size()); }
Change the size to n elements. If n is >= size(), preexisting elements remain unchanged, with later elements zero-initialized. If n < size(), then the last (size() - N) elements are removed.
- Parameters:
-
| void Botan::MemoryRegion< T >::init |
( |
bool |
locking, |
|
|
u32bit |
length = 0 | |
|
) |
| | [inline, protected, inherited] |
Get a constant pointer to the first element in the buffer.
- Returns:
- constant pointer to the first element in the buffer
Definition at line 47 of file secmem.h.
Get a pointer to the first element in the buffer.
- Returns:
- pointer to the first element in the buffer
Definition at line 41 of file secmem.h.
Check two buffers for inequality.
- Returns:
- false if the content of both buffers is byte-wise equal, true otherwise.
Definition at line 94 of file secmem.h.
00095 { return (!(*this == other)); }
Compare two buffers lexicographically.
- Returns:
- true if this buffer is lexicographically smaller than other.
template<typename T, u32bit INITIAL_LEN = 0>
Copy the contents of another buffer into this buffer.
- Parameters:
-
| in | the buffer to copy the contents from |
- Returns:
- reference to *this
Reimplemented from Botan::MemoryRegion< T >.
Definition at line 367 of file secmem.h.
00368 { if(this != &in) set(in); return (*this); }
Check two buffers for equality.
- Returns:
- true iff the content of both buffers is byte-wise equal
Definition at line 77 of file secmem.h.
00078 {
00079 return (size() == other.size() &&
00080 same_mem(buf, other.buf, size()));
00081 }
Reset this buffer to a buffer of specified length. The content will be initialized to zero bytes.
- Parameters:
-
| n | the new length of the buffer |
Set the contents of this according to the argument. The size of *this is increased if necessary.
- Parameters:
-
| in | the buffer to copy the contents from |
Definition at line 141 of file secmem.h.
00141 { set(in.begin(), in.size()); }
Set the contents of this according to the argument. The size of *this is increased if necessary.
- Parameters:
-
| in | the array of objects of type T to copy the contents from |
| n | the size of array in |
Definition at line 134 of file secmem.h.
Swap this buffer with another object.
The documentation for this class was generated from the following file: