diff options
author | lloyd <[email protected]> | 2010-09-07 23:40:31 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-09-07 23:40:31 +0000 |
commit | 197f7cd4f744ae8246832343dc514296632554b2 (patch) | |
tree | 63963dfab01e29ce32be4c1d43e62506d9f0246d /src/block | |
parent | 5f83d344e49a6d62cd8989d9fb8f8ca80ed48fc1 (diff) |
Big, invasive but mostly automated change, with a further attempt at
harmonising MemoryRegion with std::vector:
The MemoryRegion::clear() function would zeroise the buffer, but keep
the memory allocated and the size unchanged. This is very different
from STL's clear(), which is basically the equivalent to what is
called destroy() in MemoryRegion. So to be able to replace MemoryRegion
with a std::vector, we have to rename destroy() to clear() and we have
to expose the current functionality of clear() in some other way, since
vector doesn't support this operation. Do so by adding a global function
named zeroise() which takes a MemoryRegion which is zeroed. Remove clear()
to ensure all callers are updated.
Diffstat (limited to 'src/block')
-rw-r--r-- | src/block/aes/aes.cpp | 8 | ||||
-rw-r--r-- | src/block/aes_intel/aes_intel.cpp | 12 | ||||
-rw-r--r-- | src/block/aes_ssse3/aes_ssse3.h | 6 | ||||
-rw-r--r-- | src/block/cast/cast128.h | 2 | ||||
-rw-r--r-- | src/block/cast/cast256.h | 2 | ||||
-rw-r--r-- | src/block/des/des.h | 4 | ||||
-rw-r--r-- | src/block/des/desx.h | 2 | ||||
-rw-r--r-- | src/block/gost_28147/gost_28147.h | 2 | ||||
-rw-r--r-- | src/block/idea/idea.h | 2 | ||||
-rw-r--r-- | src/block/kasumi/kasumi.h | 2 | ||||
-rw-r--r-- | src/block/lion/lion.cpp | 4 | ||||
-rw-r--r-- | src/block/lubyrack/lubyrack.cpp | 4 | ||||
-rw-r--r-- | src/block/mars/mars.h | 2 | ||||
-rw-r--r-- | src/block/misty1/misty1.h | 2 | ||||
-rw-r--r-- | src/block/noekeon/noekeon.cpp | 4 | ||||
-rw-r--r-- | src/block/rc2/rc2.h | 2 | ||||
-rw-r--r-- | src/block/rc5/rc5.h | 2 | ||||
-rw-r--r-- | src/block/rc6/rc6.h | 2 | ||||
-rw-r--r-- | src/block/safer/safer_sk.h | 2 | ||||
-rw-r--r-- | src/block/seed/seed.h | 2 | ||||
-rw-r--r-- | src/block/serpent/serpent.h | 2 | ||||
-rw-r--r-- | src/block/skipjack/skipjack.cpp | 2 | ||||
-rw-r--r-- | src/block/square/square.cpp | 8 | ||||
-rw-r--r-- | src/block/tea/tea.h | 2 | ||||
-rw-r--r-- | src/block/twofish/twofish.cpp | 10 | ||||
-rw-r--r-- | src/block/xtea/xtea.h | 2 |
26 files changed, 47 insertions, 47 deletions
diff --git a/src/block/aes/aes.cpp b/src/block/aes/aes.cpp index 8783f13a0..2485fc1a1 100644 --- a/src/block/aes/aes.cpp +++ b/src/block/aes/aes.cpp @@ -693,10 +693,10 @@ AES::AES(u32bit key_size) : BlockCipher(16, key_size) */ void AES::clear() { - EK.clear(); - DK.clear(); - ME.clear(); - MD.clear(); + zeroise(EK); + zeroise(DK); + zeroise(ME); + zeroise(MD); } } diff --git a/src/block/aes_intel/aes_intel.cpp b/src/block/aes_intel/aes_intel.cpp index 211bb3b47..c52f3fcd3 100644 --- a/src/block/aes_intel/aes_intel.cpp +++ b/src/block/aes_intel/aes_intel.cpp @@ -306,8 +306,8 @@ void AES_128_Intel::key_schedule(const byte key[], u32bit) */ void AES_128_Intel::clear() { - EK.clear(); - DK.clear(); + zeroise(EK); + zeroise(DK); } /* @@ -522,8 +522,8 @@ void AES_192_Intel::key_schedule(const byte key[], u32bit) */ void AES_192_Intel::clear() { - EK.clear(); - DK.clear(); + zeroise(EK); + zeroise(DK); } /* @@ -772,8 +772,8 @@ void AES_256_Intel::key_schedule(const byte key[], u32bit) */ void AES_256_Intel::clear() { - EK.clear(); - DK.clear(); + zeroise(EK); + zeroise(DK); } } diff --git a/src/block/aes_ssse3/aes_ssse3.h b/src/block/aes_ssse3/aes_ssse3.h index 8087b58a0..babd30509 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 BlockCipher void encrypt_n(const byte in[], byte out[], u32bit blocks) const; void decrypt_n(const byte in[], byte out[], u32bit blocks) const; - void clear() { EK.clear(); DK.clear(); } + void clear() { zeroise(EK); zeroise(DK); } std::string name() const { return "AES-128"; } BlockCipher* clone() const { return new AES_128_SSSE3; } @@ -41,7 +41,7 @@ class BOTAN_DLL AES_192_SSSE3 : public BlockCipher void encrypt_n(const byte in[], byte out[], u32bit blocks) const; void decrypt_n(const byte in[], byte out[], u32bit blocks) const; - void clear() { EK.clear(); DK.clear(); } + void clear() { zeroise(EK); zeroise(DK); } std::string name() const { return "AES-192"; } BlockCipher* clone() const { return new AES_192_SSSE3; } @@ -61,7 +61,7 @@ class BOTAN_DLL AES_256_SSSE3 : public BlockCipher void encrypt_n(const byte in[], byte out[], u32bit blocks) const; void decrypt_n(const byte in[], byte out[], u32bit blocks) const; - void clear() { EK.clear(); DK.clear(); } + void clear() { zeroise(EK); zeroise(DK); } std::string name() const { return "AES-256"; } BlockCipher* clone() const { return new AES_256_SSSE3; } diff --git a/src/block/cast/cast128.h b/src/block/cast/cast128.h index 967e91938..e5d4a884b 100644 --- a/src/block/cast/cast128.h +++ b/src/block/cast/cast128.h @@ -21,7 +21,7 @@ class BOTAN_DLL CAST_128 : public BlockCipher void encrypt_n(const byte in[], byte out[], u32bit blocks) const; void decrypt_n(const byte in[], byte out[], u32bit blocks) const; - void clear() { MK.clear(); RK.clear(); } + void clear() { zeroise(MK); zeroise(RK); } std::string name() const { return "CAST-128"; } BlockCipher* clone() const { return new CAST_128; } diff --git a/src/block/cast/cast256.h b/src/block/cast/cast256.h index c4a305671..c9820c1ab 100644 --- a/src/block/cast/cast256.h +++ b/src/block/cast/cast256.h @@ -21,7 +21,7 @@ class BOTAN_DLL CAST_256 : public BlockCipher void encrypt_n(const byte in[], byte out[], u32bit blocks) const; void decrypt_n(const byte in[], byte out[], u32bit blocks) const; - void clear() { MK.clear(); RK.clear(); } + void clear() { zeroise(MK); zeroise(RK); } std::string name() const { return "CAST-256"; } BlockCipher* clone() const { return new CAST_256; } diff --git a/src/block/des/des.h b/src/block/des/des.h index 1ae806850..f631986f0 100644 --- a/src/block/des/des.h +++ b/src/block/des/des.h @@ -21,7 +21,7 @@ class BOTAN_DLL DES : public BlockCipher void encrypt_n(const byte in[], byte out[], u32bit blocks) const; void decrypt_n(const byte in[], byte out[], u32bit blocks) const; - void clear() { round_key.clear(); } + void clear() { zeroise(round_key); } std::string name() const { return "DES"; } BlockCipher* clone() const { return new DES; } @@ -41,7 +41,7 @@ class BOTAN_DLL TripleDES : public BlockCipher void encrypt_n(const byte in[], byte out[], u32bit blocks) const; void decrypt_n(const byte in[], byte out[], u32bit blocks) const; - void clear() { round_key.clear(); } + void clear() { zeroise(round_key); } std::string name() const { return "TripleDES"; } BlockCipher* clone() const { return new TripleDES; } diff --git a/src/block/des/desx.h b/src/block/des/desx.h index 45a9d8479..007948ba7 100644 --- a/src/block/des/desx.h +++ b/src/block/des/desx.h @@ -21,7 +21,7 @@ class BOTAN_DLL DESX : public BlockCipher void encrypt_n(const byte in[], byte out[], u32bit blocks) const; void decrypt_n(const byte in[], byte out[], u32bit blocks) const; - void clear() { des.clear(); K1.clear(); K2.clear(); } + void clear() { des.clear(); zeroise(K1); zeroise(K2); } std::string name() const { return "DESX"; } BlockCipher* clone() const { return new DESX; } diff --git a/src/block/gost_28147/gost_28147.h b/src/block/gost_28147/gost_28147.h index ec23466f4..9d845ae72 100644 --- a/src/block/gost_28147/gost_28147.h +++ b/src/block/gost_28147/gost_28147.h @@ -55,7 +55,7 @@ class BOTAN_DLL GOST_28147_89 : public BlockCipher void encrypt_n(const byte in[], byte out[], u32bit blocks) const; void decrypt_n(const byte in[], byte out[], u32bit blocks) const; - void clear() { EK.clear(); } + void clear() { zeroise(EK); } std::string name() const { return "GOST-28147-89"; } BlockCipher* clone() const { return new GOST_28147_89(SBOX); } diff --git a/src/block/idea/idea.h b/src/block/idea/idea.h index aed3be3ea..737970b29 100644 --- a/src/block/idea/idea.h +++ b/src/block/idea/idea.h @@ -21,7 +21,7 @@ class BOTAN_DLL IDEA : public BlockCipher void encrypt_n(const byte in[], byte out[], u32bit blocks) const; void decrypt_n(const byte in[], byte out[], u32bit blocks) const; - void clear() { EK.clear(); DK.clear(); } + void clear() { zeroise(EK); zeroise(DK); } std::string name() const { return "IDEA"; } BlockCipher* clone() const { return new IDEA; } diff --git a/src/block/kasumi/kasumi.h b/src/block/kasumi/kasumi.h index fda348ef3..f8575c2d2 100644 --- a/src/block/kasumi/kasumi.h +++ b/src/block/kasumi/kasumi.h @@ -21,7 +21,7 @@ class BOTAN_DLL KASUMI : public BlockCipher void encrypt_n(const byte in[], byte out[], u32bit blocks) const; void decrypt_n(const byte in[], byte out[], u32bit blocks) const; - void clear() { EK.clear(); } + void clear() { zeroise(EK); } std::string name() const { return "KASUMI"; } BlockCipher* clone() const { return new KASUMI; } diff --git a/src/block/lion/lion.cpp b/src/block/lion/lion.cpp index d8dfd1fcb..45e051ada 100644 --- a/src/block/lion/lion.cpp +++ b/src/block/lion/lion.cpp @@ -99,8 +99,8 @@ void Lion::clear() { hash->clear(); cipher->clear(); - key1.clear(); - key2.clear(); + zeroise(key1); + zeroise(key2); } /* diff --git a/src/block/lubyrack/lubyrack.cpp b/src/block/lubyrack/lubyrack.cpp index bdb26837e..4dd0d5c8a 100644 --- a/src/block/lubyrack/lubyrack.cpp +++ b/src/block/lubyrack/lubyrack.cpp @@ -94,8 +94,8 @@ void LubyRackoff::key_schedule(const byte key[], u32bit length) */ void LubyRackoff::clear() { - K1.clear(); - K2.clear(); + zeroise(K1); + zeroise(K2); hash->clear(); } diff --git a/src/block/mars/mars.h b/src/block/mars/mars.h index f455ec5ca..37501fff1 100644 --- a/src/block/mars/mars.h +++ b/src/block/mars/mars.h @@ -21,7 +21,7 @@ class BOTAN_DLL MARS : public BlockCipher void encrypt_n(const byte in[], byte out[], u32bit blocks) const; void decrypt_n(const byte in[], byte out[], u32bit blocks) const; - void clear() { EK.clear(); } + void clear() { zeroise(EK); } std::string name() const { return "MARS"; } BlockCipher* clone() const { return new MARS; } diff --git a/src/block/misty1/misty1.h b/src/block/misty1/misty1.h index a9bc12c7b..dbb8e2c45 100644 --- a/src/block/misty1/misty1.h +++ b/src/block/misty1/misty1.h @@ -21,7 +21,7 @@ class BOTAN_DLL MISTY1 : public BlockCipher void encrypt_n(const byte in[], byte out[], u32bit blocks) const; void decrypt_n(const byte in[], byte out[], u32bit blocks) const; - void clear() { EK.clear(); DK.clear(); } + void clear() { zeroise(EK); zeroise(DK); } std::string name() const { return "MISTY1"; } BlockCipher* clone() const { return new MISTY1; } diff --git a/src/block/noekeon/noekeon.cpp b/src/block/noekeon/noekeon.cpp index 0bfce1882..95178a62b 100644 --- a/src/block/noekeon/noekeon.cpp +++ b/src/block/noekeon/noekeon.cpp @@ -203,8 +203,8 @@ void Noekeon::key_schedule(const byte key[], u32bit) */ void Noekeon::clear() { - EK.clear(); - DK.clear(); + zeroise(EK); + zeroise(DK); } } diff --git a/src/block/rc2/rc2.h b/src/block/rc2/rc2.h index c16680347..e6c900056 100644 --- a/src/block/rc2/rc2.h +++ b/src/block/rc2/rc2.h @@ -28,7 +28,7 @@ class BOTAN_DLL RC2 : public BlockCipher */ static byte EKB_code(u32bit bits); - void clear() { K.clear(); } + void clear() { zeroise(K); } std::string name() const { return "RC2"; } BlockCipher* clone() const { return new RC2; } diff --git a/src/block/rc5/rc5.h b/src/block/rc5/rc5.h index 385c6b2b1..9a794d248 100644 --- a/src/block/rc5/rc5.h +++ b/src/block/rc5/rc5.h @@ -21,7 +21,7 @@ class BOTAN_DLL RC5 : public BlockCipher void encrypt_n(const byte in[], byte out[], u32bit blocks) const; void decrypt_n(const byte in[], byte out[], u32bit blocks) const; - void clear() { S.clear(); } + void clear() { zeroise(S); } std::string name() const; BlockCipher* clone() const { return new RC5(ROUNDS); } diff --git a/src/block/rc6/rc6.h b/src/block/rc6/rc6.h index 9b2d587fa..02c464c5c 100644 --- a/src/block/rc6/rc6.h +++ b/src/block/rc6/rc6.h @@ -21,7 +21,7 @@ class BOTAN_DLL RC6 : public BlockCipher void encrypt_n(const byte in[], byte out[], u32bit blocks) const; void decrypt_n(const byte in[], byte out[], u32bit blocks) const; - void clear() { S.clear(); } + void clear() { zeroise(S); } std::string name() const { return "RC6"; } BlockCipher* clone() const { return new RC6; } diff --git a/src/block/safer/safer_sk.h b/src/block/safer/safer_sk.h index c93797602..26875c97b 100644 --- a/src/block/safer/safer_sk.h +++ b/src/block/safer/safer_sk.h @@ -21,7 +21,7 @@ class BOTAN_DLL SAFER_SK : public BlockCipher void encrypt_n(const byte in[], byte out[], u32bit blocks) const; void decrypt_n(const byte in[], byte out[], u32bit blocks) const; - void clear() { EK.clear(); } + void clear() { zeroise(EK); } std::string name() const; BlockCipher* clone() const; diff --git a/src/block/seed/seed.h b/src/block/seed/seed.h index 0c80199ad..bfc9c7fa1 100644 --- a/src/block/seed/seed.h +++ b/src/block/seed/seed.h @@ -21,7 +21,7 @@ class BOTAN_DLL SEED : public BlockCipher void encrypt_n(const byte in[], byte out[], u32bit blocks) const; void decrypt_n(const byte in[], byte out[], u32bit blocks) const; - void clear() { K.clear(); } + void clear() { zeroise(K); } std::string name() const { return "SEED"; } BlockCipher* clone() const { return new SEED; } diff --git a/src/block/serpent/serpent.h b/src/block/serpent/serpent.h index dc81d4178..56afd3330 100644 --- a/src/block/serpent/serpent.h +++ b/src/block/serpent/serpent.h @@ -21,7 +21,7 @@ class BOTAN_DLL Serpent : public BlockCipher void encrypt_n(const byte in[], byte out[], u32bit blocks) const; void decrypt_n(const byte in[], byte out[], u32bit blocks) const; - void clear() { round_key.clear(); } + void clear() { zeroise(round_key); } std::string name() const { return "Serpent"; } BlockCipher* clone() const { return new Serpent; } Serpent() : BlockCipher(16, 16, 32, 8) {} diff --git a/src/block/skipjack/skipjack.cpp b/src/block/skipjack/skipjack.cpp index b23d1e160..dda984e4c 100644 --- a/src/block/skipjack/skipjack.cpp +++ b/src/block/skipjack/skipjack.cpp @@ -189,7 +189,7 @@ void Skipjack::key_schedule(const byte key[], u32bit) */ void Skipjack::clear() { - FTAB.clear(); + zeroise(FTAB); } } diff --git a/src/block/square/square.cpp b/src/block/square/square.cpp index adcf18611..f96162c37 100644 --- a/src/block/square/square.cpp +++ b/src/block/square/square.cpp @@ -206,10 +206,10 @@ void Square::transform(u32bit round_key[4]) */ void Square::clear() { - EK.clear(); - DK.clear(); - ME.clear(); - MD.clear(); + zeroise(EK); + zeroise(DK); + zeroise(ME); + zeroise(MD); } } diff --git a/src/block/tea/tea.h b/src/block/tea/tea.h index 128f42080..6e1c4fafb 100644 --- a/src/block/tea/tea.h +++ b/src/block/tea/tea.h @@ -21,7 +21,7 @@ class BOTAN_DLL TEA : public BlockCipher void encrypt_n(const byte in[], byte out[], u32bit blocks) const; void decrypt_n(const byte in[], byte out[], u32bit blocks) const; - void clear() { K.clear(); } + void clear() { zeroise(K); } std::string name() const { return "TEA"; } BlockCipher* clone() const { return new TEA; } diff --git a/src/block/twofish/twofish.cpp b/src/block/twofish/twofish.cpp index a183821b2..375590af1 100644 --- a/src/block/twofish/twofish.cpp +++ b/src/block/twofish/twofish.cpp @@ -220,11 +220,11 @@ void Twofish::rs_mul(byte S[4], byte key, u32bit offset) */ void Twofish::clear() { - SBox0.clear(); - SBox1.clear(); - SBox2.clear(); - SBox3.clear(); - round_key.clear(); + zeroise(SBox0); + zeroise(SBox1); + zeroise(SBox2); + zeroise(SBox3); + zeroise(round_key); } } diff --git a/src/block/xtea/xtea.h b/src/block/xtea/xtea.h index d15108939..d328bf2f0 100644 --- a/src/block/xtea/xtea.h +++ b/src/block/xtea/xtea.h @@ -21,7 +21,7 @@ class BOTAN_DLL XTEA : public BlockCipher void encrypt_n(const byte in[], byte out[], u32bit blocks) const; void decrypt_n(const byte in[], byte out[], u32bit blocks) const; - void clear() { EK.clear(); } + void clear() { zeroise(EK); } std::string name() const { return "XTEA"; } BlockCipher* clone() const { return new XTEA; } |