aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/block/threefish
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/block/threefish')
-rw-r--r--src/lib/block/threefish/threefish.cpp10
-rw-r--r--src/lib/block/threefish/threefish.h3
2 files changed, 8 insertions, 5 deletions
diff --git a/src/lib/block/threefish/threefish.cpp b/src/lib/block/threefish/threefish.cpp
index f6636615b..322f54881 100644
--- a/src/lib/block/threefish/threefish.cpp
+++ b/src/lib/block/threefish/threefish.cpp
@@ -5,12 +5,13 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
+#include <botan/internal/block_utils.h>
#include <botan/threefish.h>
-#include <botan/rotate.h>
-#include <botan/loadstor.h>
namespace Botan {
+BOTAN_REGISTER_BLOCK_CIPHER_NAMED_NOARGS(Threefish_512, "Threefish-512");
+
#define THREEFISH_ROUND(X0,X1,X2,X3,X4,X5,X6,X7,ROT1,ROT2,ROT3,ROT4) \
do { \
X0 += X4; \
@@ -223,6 +224,7 @@ void Threefish_512::set_tweak(const byte tweak[], size_t len)
{
if(len != 16)
throw std::runtime_error("Unsupported twofish tweak length");
+ m_T.resize(3);
m_T[0] = load_le<u64bit>(tweak, 0);
m_T[1] = load_le<u64bit>(tweak, 1);
m_T[2] = m_T[0] ^ m_T[1];
@@ -238,6 +240,10 @@ void Threefish_512::key_schedule(const byte key[], size_t)
m_K[8] = m_K[0] ^ m_K[1] ^ m_K[2] ^ m_K[3] ^
m_K[4] ^ m_K[5] ^ m_K[6] ^ m_K[7] ^ 0x1BD11BDAA9FC1A22;
+
+ // Reset tweak to all zeros on key reset
+ m_T.resize(3);
+ zeroise(m_T);
}
void Threefish_512::clear()
diff --git a/src/lib/block/threefish/threefish.h b/src/lib/block/threefish/threefish.h
index 6020b8a28..373600885 100644
--- a/src/lib/block/threefish/threefish.h
+++ b/src/lib/block/threefish/threefish.h
@@ -26,9 +26,6 @@ class BOTAN_DLL Threefish_512 : public Block_Cipher_Fixed_Params<64, 64>
void clear() override;
std::string name() const override { return "Threefish-512"; }
BlockCipher* clone() const override { return new Threefish_512; }
-
- Threefish_512() : m_T(3) {}
-
protected:
const secure_vector<u64bit>& get_T() const { return m_T; }
const secure_vector<u64bit>& get_K() const { return m_K; }