diff options
Diffstat (limited to 'src/lib/block/tea')
-rw-r--r-- | src/lib/block/tea/info.txt | 1 | ||||
-rw-r--r-- | src/lib/block/tea/tea.cpp | 78 | ||||
-rw-r--r-- | src/lib/block/tea/tea.h | 34 |
3 files changed, 0 insertions, 113 deletions
diff --git a/src/lib/block/tea/info.txt b/src/lib/block/tea/info.txt deleted file mode 100644 index 14edfdb03..000000000 --- a/src/lib/block/tea/info.txt +++ /dev/null @@ -1 +0,0 @@ -define TEA 20131128 diff --git a/src/lib/block/tea/tea.cpp b/src/lib/block/tea/tea.cpp deleted file mode 100644 index 457171e1d..000000000 --- a/src/lib/block/tea/tea.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* -* TEA -* (C) 1999-2007 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#include <botan/tea.h> -#include <botan/loadstor.h> - -namespace Botan { - -/* -* TEA Encryption -*/ -void TEA::encrypt_n(const byte in[], byte out[], size_t blocks) const - { - for(size_t i = 0; i != blocks; ++i) - { - u32bit L = load_be<u32bit>(in, 0); - u32bit R = load_be<u32bit>(in, 1); - - u32bit S = 0; - for(size_t j = 0; j != 32; ++j) - { - S += 0x9E3779B9; - L += ((R << 4) + m_K[0]) ^ (R + S) ^ ((R >> 5) + m_K[1]); - R += ((L << 4) + m_K[2]) ^ (L + S) ^ ((L >> 5) + m_K[3]); - } - - store_be(out, L, R); - - in += BLOCK_SIZE; - out += BLOCK_SIZE; - } - } - -/* -* TEA Decryption -*/ -void TEA::decrypt_n(const byte in[], byte out[], size_t blocks) const - { - for(size_t i = 0; i != blocks; ++i) - { - u32bit L = load_be<u32bit>(in, 0); - u32bit R = load_be<u32bit>(in, 1); - - u32bit S = 0xC6EF3720; - for(size_t j = 0; j != 32; ++j) - { - R -= ((L << 4) + m_K[2]) ^ (L + S) ^ ((L >> 5) + m_K[3]); - L -= ((R << 4) + m_K[0]) ^ (R + S) ^ ((R >> 5) + m_K[1]); - S -= 0x9E3779B9; - } - - store_be(out, L, R); - - in += BLOCK_SIZE; - out += BLOCK_SIZE; - } - } - -/* -* TEA Key Schedule -*/ -void TEA::key_schedule(const byte key[], size_t) - { - m_K.resize(4); - for(size_t i = 0; i != 4; ++i) - m_K[i] = load_be<u32bit>(key, i); - } - -void TEA::clear() - { - zap(m_K); - } - -} diff --git a/src/lib/block/tea/tea.h b/src/lib/block/tea/tea.h deleted file mode 100644 index 6b6308381..000000000 --- a/src/lib/block/tea/tea.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -* TEA -* (C) 1999-2007 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#ifndef BOTAN_TEA_H__ -#define BOTAN_TEA_H__ - -#include <botan/block_cipher.h> - -namespace Botan { - -/** -* TEA -*/ -class BOTAN_DLL TEA final : public Block_Cipher_Fixed_Params<8, 16> - { - public: - void encrypt_n(const byte in[], byte out[], size_t blocks) const override; - void decrypt_n(const byte in[], byte out[], size_t blocks) const override; - - void clear() override; - std::string name() const override { return "TEA"; } - BlockCipher* clone() const override { return new TEA; } - private: - void key_schedule(const byte[], size_t) override; - secure_vector<u32bit> m_K; - }; - -} - -#endif |