aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc/secmem.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/alloc/secmem.h')
-rw-r--r--src/alloc/secmem.h46
1 files changed, 26 insertions, 20 deletions
diff --git a/src/alloc/secmem.h b/src/alloc/secmem.h
index aae1634d3..37930b963 100644
--- a/src/alloc/secmem.h
+++ b/src/alloc/secmem.h
@@ -126,21 +126,6 @@ class MemoryRegion
{ copy_mem(buf + off, in, (n > size() - off) ? (size() - off) : n); }
/**
- * Set the contents of this according to the argument. The size of
- * *this is increased if necessary.
- * @param in the array of objects of type T to copy the contents from
- * @param n the size of array in
- */
- void set(const T in[], u32bit n) { resize(n); copy(in, n); }
-
- /**
- * Set the contents of this according to the argument. The size of
- * *this is increased if necessary.
- * @param in the buffer to copy the contents from
- */
- void set(const MemoryRegion<T>& in) { set(in.begin(), in.size()); }
-
- /**
* Append data to the end of this buffer.
* @param data the array containing the data to append
* @param n the size of the array data
@@ -162,11 +147,6 @@ class MemoryRegion
{ append(other.begin(), other.size()); }
/**
- * Zeroise the bytes of this buffer. The length remains unchanged.
- */
- void clear() { clear_mem(buf, allocated); }
-
- /**
* Reset this buffer to an empty buffer with size zero.
*/
void destroy() { resize(0); }
@@ -206,6 +186,22 @@ class MemoryRegion
*/
void init(bool locking, u32bit length = 0)
{ alloc = Allocator::get(locking); resize(length); }
+
+ /**
+ * Set the contents of this according to the argument. The size of
+ * *this is increased if necessary.
+ * @param in the array of objects of type T to copy the contents from
+ * @param n the size of array in
+ */
+ void set(const T in[], u32bit n) { resize(n); copy(in, n); }
+
+ /**
+ * Set the contents of this according to the argument. The size of
+ * *this is increased if necessary.
+ * @param in the buffer to copy the contents from
+ */
+ void set(const MemoryRegion<T>& in) { set(in.begin(), in.size()); }
+
private:
T* allocate(u32bit n)
{
@@ -393,6 +389,16 @@ class SecureVector : public MemoryRegion<T>
{ init(true); set(in1); append(in2); }
};
+/**
+* Zeroise the values; length remains unchanged
+* @param vec the vector to zeroise
+*/
+template<typename T>
+void zeroise(MemoryRegion<T>& vec)
+ {
+ clear_mem(&vec[0], vec.size());
+ }
+
}
#endif