aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc/secmem.h
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-09-14 01:16:32 +0000
committerlloyd <[email protected]>2010-09-14 01:16:32 +0000
commitae59295ea945fdcc482df2233409a5f878fa20c7 (patch)
tree768c30635a17847dccb6db6f36fa3b033adc37bf /src/alloc/secmem.h
parent548f48611760346fa2e47efd5c0865eff831946a (diff)
Completely remove the second parameter to SecureVector which specifies
the initial/default length of the array, update all users to instead pass the value to the constructor. This is a old vestigal thing from a class (SecureBuffer) that used this compile-time constant in order to store the values in an array. However this was changed way back in 2002 to use the same allocator hooks as the rest of the containers, so the only advantage to using the length field was that the initial length was set and didn't have to be set in the constructor which was midly convenient. However this directly conflicts with the desire to be able to (eventually) use std::vector with a custom allocator, since of course vector doesn't support this. Fortunately almost all of the uses are in classes which have only a single constructor, so there is little to no duplication by instead initializing the size in the constructor.
Diffstat (limited to 'src/alloc/secmem.h')
-rw-r--r--src/alloc/secmem.h19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/alloc/secmem.h b/src/alloc/secmem.h
index 9b533eac0..e92efe9a0 100644
--- a/src/alloc/secmem.h
+++ b/src/alloc/secmem.h
@@ -333,7 +333,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, u32bit INITIAL_LEN = 0>
+template<typename T>
class SecureVector : public MemoryRegion<T>
{
public:
@@ -349,8 +349,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 = INITIAL_LEN)
- { this->init(true, n); }
+ SecureVector(u32bit n = 0) { this->init(true, n); }
/**
* Create a buffer with the specified contents.
@@ -360,11 +359,8 @@ class SecureVector : public MemoryRegion<T>
*/
SecureVector(const T in[], u32bit n)
{
- this->init(true, INITIAL_LEN);
- if(INITIAL_LEN)
- this->copy(&in[0], n);
- else
- this->set(&in[0], n);
+ this->init(true);
+ this->set(&in[0], n);
}
/**
@@ -374,11 +370,8 @@ class SecureVector : public MemoryRegion<T>
*/
SecureVector(const MemoryRegion<T>& in)
{
- this->init(true, INITIAL_LEN);
- if(INITIAL_LEN)
- this->copy(&in[0], in.size());
- else
- this->set(&in[0], in.size());
+ this->init(true);
+ this->set(&in[0], in.size());
}
};