aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc/secmem.h
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-03-23 01:17:41 +0000
committerlloyd <[email protected]>2010-03-23 01:17:41 +0000
commitd66be84b420fbb0afb6a22610cfd5b46b76a5150 (patch)
tree2a13c36cf1a0e51dc945fbc27da373bbed7123c1 /src/alloc/secmem.h
parentd695d7832a86c0c7f165ab8b052c59525d210966 (diff)
Remove SecureBuffer, which is the fixed-size variant of SecureVector.
Add a second template param to SecureVector which specifies the initial length. Change all callers to be SecureVector instead of SecureBuffer. This can go away in C++0x, once compilers implement N2712 ("Non-static data member initializers"), and we can just write code as SecureVector<byte> P{18}; instead
Diffstat (limited to 'src/alloc/secmem.h')
-rw-r--r--src/alloc/secmem.h40
1 files changed, 2 insertions, 38 deletions
diff --git a/src/alloc/secmem.h b/src/alloc/secmem.h
index 4f2a06683..4073167cb 100644
--- a/src/alloc/secmem.h
+++ b/src/alloc/secmem.h
@@ -337,7 +337,7 @@ class MemoryVector : public MemoryRegion<T>
* swapped out to disk. In this way, a security hole allowing attackers
* to find swapped out secret keys is closed.
*/
-template<typename T>
+template<typename T, u32bit L = 0>
class SecureVector : public MemoryRegion<T>
{
public:
@@ -353,7 +353,7 @@ class SecureVector : public MemoryRegion<T>
* Create a buffer of the specified length.
* @param n the length of the buffer to create.
*/
- SecureVector(u32bit n = 0) { MemoryRegion<T>::init(true, n); }
+ SecureVector(u32bit n = L) { MemoryRegion<T>::init(true, n); }
/**
* Create a buffer with the specified contents.
@@ -382,42 +382,6 @@ class SecureVector : public MemoryRegion<T>
{ MemoryRegion<T>::init(true); set(in1); append(in2); }
};
-/**
-* This class represents fixed 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.
-*/
-template<typename T, u32bit L>
-class SecureBuffer : public MemoryRegion<T>
- {
- public:
- /**
- * Copy the contents of another buffer into this buffer.
- * @param in the buffer to copy the contents from
- * @return a reference to *this
- */
- SecureBuffer<T,L>& operator=(const SecureBuffer<T,L>& in)
- { if(this != &in) set(in); return (*this); }
-
- /**
- * Create a buffer of the length L.
- */
- SecureBuffer() { MemoryRegion<T>::init(true, L); }
-
- /**
- * Create a buffer of size L with the specified contents.
- * @param in the array containing the data to be initially copied
- * into the newly created buffer
- * @param n the size of the array in
- */
- SecureBuffer(const T in[], u32bit n)
- { MemoryRegion<T>::init(true, L); copy(in, n); }
- private:
- SecureBuffer<T, L>& operator=(const MemoryRegion<T>& in)
- { if(this != &in) set(in); return (*this); }
- };
-
}
#endif