diff options
author | lloyd <[email protected]> | 2012-05-25 22:52:00 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2012-05-25 22:52:00 +0000 |
commit | 12090a7148d9ee73572cc1a7268fc489504a8173 (patch) | |
tree | 51e50ce0852c56231e9e6dc13f168b10edd45d01 /src/stream/turing | |
parent | 9594979caf775dc4062850044715b804d1fda60c (diff) | |
parent | 65cc04445f8d40497f02a14bd8cb97081790e54b (diff) |
propagate from branch 'net.randombit.botan.x509-path-validation' (head 63b5a20eab129ca13287fda33d2d02eec329708f)
to branch 'net.randombit.botan' (head 8b8150f09c55184f028f2929c4e7f7cd0d46d96e)
Diffstat (limited to 'src/stream/turing')
-rw-r--r-- | src/stream/turing/turing.cpp | 26 | ||||
-rw-r--r-- | src/stream/turing/turing.h | 10 |
2 files changed, 20 insertions, 16 deletions
diff --git a/src/stream/turing/turing.cpp b/src/stream/turing/turing.cpp index 697c660ed..bdc53cff1 100644 --- a/src/stream/turing/turing.cpp +++ b/src/stream/turing/turing.cpp @@ -17,7 +17,7 @@ namespace { /* * Perform an N-way PHT */ -inline void PHT(MemoryRegion<u32bit>& B) +inline void PHT(secure_vector<u32bit>& B) { u32bit sum = 0; for(size_t i = 0; i < B.size() - 1; ++i) @@ -247,6 +247,13 @@ void Turing::key_schedule(const byte key[], size_t length) PHT(K); + R.resize(17); + S0.resize(256); + S1.resize(256); + S2.resize(256); + S3.resize(256); + buffer.resize(17*20); + for(u32bit i = 0; i != 256; ++i) { u32bit W0 = 0, C0 = i; @@ -273,7 +280,7 @@ void Turing::key_schedule(const byte key[], size_t length) S3[i] = (W3 & 0xFFFFFF00) | C3; } - set_iv(0, 0); + set_iv(nullptr, 0); } /* @@ -284,7 +291,7 @@ void Turing::set_iv(const byte iv[], size_t length) if(!valid_iv_length(length)) throw Invalid_IV_Length(name(), length); - SecureVector<u32bit> IV(length / 4); + secure_vector<u32bit> IV(length / 4); for(size_t i = 0; i != length; ++i) IV[i/4] = (IV[i/4] << 8) + iv[i]; @@ -313,12 +320,13 @@ void Turing::set_iv(const byte iv[], size_t length) */ void Turing::clear() { - zeroise(S0); - zeroise(S1); - zeroise(S2); - zeroise(S3); - - zeroise(buffer); + S0.clear(); + S1.clear(); + S2.clear(); + S3.clear(); + R.clear(); + K.clear(); + buffer.clear(); position = 0; } diff --git a/src/stream/turing/turing.h b/src/stream/turing/turing.h index aff314080..f2453127a 100644 --- a/src/stream/turing/turing.h +++ b/src/stream/turing/turing.h @@ -33,9 +33,6 @@ class BOTAN_DLL Turing : public StreamCipher std::string name() const { return "Turing"; } StreamCipher* clone() const { return new Turing; } - Turing() : S0(256), S1(256), S2(256), S3(256), - R(17), buffer(340), position(0) {} - private: void key_schedule(const byte[], size_t); void generate(); @@ -45,10 +42,9 @@ class BOTAN_DLL Turing : public StreamCipher static const u32bit Q_BOX[256]; static const byte SBOX[256]; - SecureVector<u32bit> S0, S1, S2, S3; - SecureVector<u32bit> R; - SecureVector<u32bit> K; - SecureVector<byte> buffer; + secure_vector<u32bit> S0, S1, S2, S3; + secure_vector<u32bit> R, K; + secure_vector<byte> buffer; size_t position; }; |