diff options
author | lloyd <[email protected]> | 2012-11-29 18:58:54 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2012-11-29 18:58:54 +0000 |
commit | 12c128c1fbb483ae9042b47fc544adf0e55d0693 (patch) | |
tree | 46aa39dcfb055c84778fa842a2d66249f6d175c8 /src/block/des | |
parent | 2d8dff7079d4a8eabd848bd0e88b38a2112b333e (diff) |
Add new helper zap which zeros a vector, clears it, and then calls
shrink_to_fit to actually deallocate memory.
Diffstat (limited to 'src/block/des')
-rw-r--r-- | src/block/des/des.cpp | 10 | ||||
-rw-r--r-- | src/block/des/des.h | 6 | ||||
-rw-r--r-- | src/block/des/desx.cpp | 7 | ||||
-rw-r--r-- | src/block/des/desx.h | 2 |
4 files changed, 20 insertions, 5 deletions
diff --git a/src/block/des/des.cpp b/src/block/des/des.cpp index 2f0a3635d..a87b4d6bc 100644 --- a/src/block/des/des.cpp +++ b/src/block/des/des.cpp @@ -210,6 +210,11 @@ void DES::key_schedule(const byte key[], size_t) des_key_schedule(&round_key[0], key); } +void DES::clear() + { + zap(round_key); + } + /* * TripleDES Encryption */ @@ -291,4 +296,9 @@ void TripleDES::key_schedule(const byte key[], size_t length) copy_mem(&round_key[64], &round_key[0], 32); } +void TripleDES::clear() + { + zap(round_key); + } + } diff --git a/src/block/des/des.h b/src/block/des/des.h index fc42cfee5..4f3811bcf 100644 --- a/src/block/des/des.h +++ b/src/block/des/des.h @@ -21,7 +21,7 @@ class BOTAN_DLL DES : public Block_Cipher_Fixed_Params<8, 8> void encrypt_n(const byte in[], byte out[], size_t blocks) const; void decrypt_n(const byte in[], byte out[], size_t blocks) const; - void clear() { round_key.clear(); } + void clear(); std::string name() const { return "DES"; } BlockCipher* clone() const { return new DES; } private: @@ -39,11 +39,9 @@ class BOTAN_DLL TripleDES : public Block_Cipher_Fixed_Params<8, 16, 24, 8> void encrypt_n(const byte in[], byte out[], size_t blocks) const; void decrypt_n(const byte in[], byte out[], size_t blocks) const; - void clear() { round_key.clear(); } + void clear(); std::string name() const { return "TripleDES"; } BlockCipher* clone() const { return new TripleDES; } - - TripleDES() : round_key(96) {} private: void key_schedule(const byte[], size_t); diff --git a/src/block/des/desx.cpp b/src/block/des/desx.cpp index 7f68e406a..879e73ee9 100644 --- a/src/block/des/desx.cpp +++ b/src/block/des/desx.cpp @@ -52,4 +52,11 @@ void DESX::key_schedule(const byte key[], size_t) K2.assign(key + 16, key + 24); } +void DESX::clear() + { + des.clear(); + zap(K1); + zap(K2); + } + } diff --git a/src/block/des/desx.h b/src/block/des/desx.h index 4ff41328f..aeda3f3c4 100644 --- a/src/block/des/desx.h +++ b/src/block/des/desx.h @@ -21,7 +21,7 @@ class BOTAN_DLL DESX : public Block_Cipher_Fixed_Params<8, 24> void encrypt_n(const byte in[], byte out[], size_t blocks) const; void decrypt_n(const byte in[], byte out[], size_t blocks) const; - void clear() { des.clear(); K1.clear(); K2.clear(); } + void clear(); std::string name() const { return "DESX"; } BlockCipher* clone() const { return new DESX; } private: |