Ensure memsets of sensitive memory aren't optimized away

This commit is contained in:
Andrew Ayer
2014-07-23 19:32:30 -07:00
parent 23ff272f7d
commit 477983f4bc
5 changed files with 17 additions and 4 deletions

View File

@@ -30,6 +30,7 @@
#include "crypto.hpp"
#include "key.hpp"
#include "util.hpp"
#include <openssl/aes.h>
#include <openssl/sha.h>
#include <openssl/hmac.h>
@@ -61,7 +62,7 @@ Aes_ecb_encryptor::~Aes_ecb_encryptor ()
// Note: Explicit destructor necessary because class contains an auto_ptr
// which contains an incomplete type when the auto_ptr is declared.
std::memset(&impl->key, '\0', sizeof(impl->key));
explicit_memset(&impl->key, '\0', sizeof(impl->key));
}
void Aes_ecb_encryptor::encrypt(const unsigned char* plain, unsigned char* cipher)