From 12c128c1fbb483ae9042b47fc544adf0e55d0693 Mon Sep 17 00:00:00 2001 From: lloyd Date: Thu, 29 Nov 2012 18:58:54 +0000 Subject: Add new helper zap which zeros a vector, clears it, and then calls shrink_to_fit to actually deallocate memory. --- src/block/aes_ssse3/aes_ssse3.cpp | 17 +++++++++++++++++ src/block/aes_ssse3/aes_ssse3.h | 6 +++--- 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'src/block/aes_ssse3') diff --git a/src/block/aes_ssse3/aes_ssse3.cpp b/src/block/aes_ssse3/aes_ssse3.cpp index 648f96d67..476b004bb 100644 --- a/src/block/aes_ssse3/aes_ssse3.cpp +++ b/src/block/aes_ssse3/aes_ssse3.cpp @@ -406,6 +406,12 @@ void AES_128_SSSE3::key_schedule(const byte keyb[], size_t) _mm_storeu_si128(DK_mm, aes_schedule_mangle_last_dec(key)); } +void AES_128_SSSE3::clear() + { + zap(EK); + zap(DK); + } + /* * AES-192 Encryption */ @@ -507,6 +513,11 @@ void AES_192_SSSE3::key_schedule(const byte keyb[], size_t) } } +void AES_192_SSSE3::clear() + { + zap(EK); + zap(DK); + } /* * AES-256 Encryption @@ -588,4 +599,10 @@ void AES_256_SSSE3::key_schedule(const byte keyb[], size_t) _mm_storeu_si128(DK_mm + 0, aes_schedule_mangle_last_dec(key2)); } +void AES_256_SSSE3::clear() + { + zap(EK); + zap(DK); + } + } diff --git a/src/block/aes_ssse3/aes_ssse3.h b/src/block/aes_ssse3/aes_ssse3.h index 46bae1450..938abeae3 100644 --- a/src/block/aes_ssse3/aes_ssse3.h +++ b/src/block/aes_ssse3/aes_ssse3.h @@ -21,7 +21,7 @@ class BOTAN_DLL AES_128_SSSE3 : public Block_Cipher_Fixed_Params<16, 16> 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() { zeroise(EK); zeroise(DK); } + void clear(); std::string name() const { return "AES-128"; } BlockCipher* clone() const { return new AES_128_SSSE3; } private: @@ -39,7 +39,7 @@ class BOTAN_DLL AES_192_SSSE3 : public Block_Cipher_Fixed_Params<16, 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() { zeroise(EK); zeroise(DK); } + void clear(); std::string name() const { return "AES-192"; } BlockCipher* clone() const { return new AES_192_SSSE3; } private: @@ -57,7 +57,7 @@ class BOTAN_DLL AES_256_SSSE3 : public Block_Cipher_Fixed_Params<16, 32> 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() { zeroise(EK); zeroise(DK); } + void clear(); std::string name() const { return "AES-256"; } BlockCipher* clone() const { return new AES_256_SSSE3; } private: -- cgit v1.2.3