Browse Source

make CBase58Data class use zero_after_free_allocator

- this way there is no need for an explicit destructor, who does the same
  thing anyway
0.8
Philip Kaufmann 12 years ago
parent
commit
d0b0925be9
  1. 14
      src/base58.h

14
src/base58.h

@ -17,11 +17,11 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <openssl/crypto.h> // for OPENSSL_cleanse()
#include "bignum.h" #include "bignum.h"
#include "key.h" #include "key.h"
#include "script.h" #include "script.h"
#include "allocators.h"
static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
@ -180,7 +180,8 @@ protected:
unsigned char nVersion; unsigned char nVersion;
// the actually encoded data // the actually encoded data
std::vector<unsigned char> vchData; typedef std::vector<unsigned char, zero_after_free_allocator<unsigned char> > vector_uchar;
vector_uchar vchData;
CBase58Data() CBase58Data()
{ {
@ -188,13 +189,6 @@ protected:
vchData.clear(); vchData.clear();
} }
~CBase58Data()
{
// zero the memory, as it may contain sensitive data
if (!vchData.empty())
OPENSSL_cleanse(&vchData[0], vchData.size());
}
void SetData(int nVersionIn, const void* pdata, size_t nSize) void SetData(int nVersionIn, const void* pdata, size_t nSize)
{ {
nVersion = nVersionIn; nVersion = nVersionIn;
@ -459,4 +453,4 @@ public:
} }
}; };
#endif #endif // BITCOIN_BASE58_H

Loading…
Cancel
Save