diff options
author | lloyd <[email protected]> | 2011-02-14 20:37:25 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2011-02-14 20:37:25 +0000 |
commit | 6302ebff9765c572264f4b58a36154c1ce7fee4a (patch) | |
tree | 3c1a69faef3ee6808fe5acf48fcd86cd1a2b9470 /checks | |
parent | 833d6802b30c86ad48c14edae6850706cd63030d (diff) |
Remove dead code
Diffstat (limited to 'checks')
-rw-r--r-- | checks/block.cpp | 115 | ||||
-rw-r--r-- | checks/common.h | 12 |
2 files changed, 0 insertions, 127 deletions
diff --git a/checks/block.cpp b/checks/block.cpp deleted file mode 100644 index 5d275615e..000000000 --- a/checks/block.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* -* (C) 2009 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - - -/* - We don't use the standard issue ECB filter, because we also want to check - that the encryption and decryption operations are inverses (ie, it works). - - This class only works with NoPadding mode, unlike the regular ECB filters -*/ - -#include <iostream> -#include <string> -#include <cstdlib> -#include <botan/filter.h> -#include <botan/lookup.h> -using namespace Botan; - -#include "common.h" - -class ECB_Encryption_ErrorCheck : public Filter - { - public: - std::string name() const - { return "ECB_ErrCheck(" + cipher->name() + ")"; } - - void write(const byte[], size_t); - - void end_msg(); - - ECB_Encryption_ErrorCheck(const std::string& cipher_name, - const std::string&, - const SymmetricKey& key) : - BLOCKSIZE(block_size_of(cipher_name)) - { - const std::string HASH = "CRC32"; - - cipher = get_block_cipher(cipher_name); - input_hash = get_hash(HASH); - decrypt_hash = get_hash(HASH); - buffer.resize(BLOCKSIZE); - cipher->set_key(key); - position = 0; - } - - ~ECB_Encryption_ErrorCheck() - { - delete cipher; - delete input_hash; - delete decrypt_hash; - } - - private: - const size_t BLOCKSIZE; - BlockCipher* cipher; - SecureVector<byte> buffer; - size_t position; - HashFunction* input_hash, *decrypt_hash; - }; - -void ECB_Encryption_ErrorCheck::write(const byte input[], size_t length) - { - input_hash->update(input, length); - buffer.copy(position, input, length); - if(position + length >= BLOCKSIZE) - { - cipher->encrypt(buffer); - send(buffer, BLOCKSIZE); - cipher->decrypt(buffer); - decrypt_hash->update(&buffer[0], BLOCKSIZE); - input += (BLOCKSIZE - position); - length -= (BLOCKSIZE - position); - while(length >= BLOCKSIZE) - { - cipher->encrypt(input, &buffer[0]); - send(buffer, BLOCKSIZE); - cipher->decrypt(buffer); - decrypt_hash->update(&buffer[0], BLOCKSIZE); - input += BLOCKSIZE; - length -= BLOCKSIZE; - } - buffer.copy(input, length); - position = 0; - } - position += length; - } - -void ECB_Encryption_ErrorCheck::end_msg() - { - SecureVector<byte> hash1 = input_hash->final(); - SecureVector<byte> hash2 = decrypt_hash->final(); - - if(hash1 != hash2) - { - std::cout << "In " << cipher->name() - << " decryption check failed." << std::endl; - } - - if(position) - throw Encoding_Error("ECB: input was not in full blocks"); - } - -Filter* lookup_block(const std::string& algname, const std::string& key) - { - Filter* cipher = 0; - try { - cipher = new ECB_Encryption_ErrorCheck(algname, "NoPadding", key); - } - catch(Algorithm_Not_Found) {} - - return cipher; - } diff --git a/checks/common.h b/checks/common.h index 148b89d93..33499a99d 100644 --- a/checks/common.h +++ b/checks/common.h @@ -25,18 +25,6 @@ std::vector<std::string> parse(const std::string& line); Botan::Filter* lookup(const std::string& algname, const std::vector<std::string>& params); -Botan::Filter* lookup_block(const std::string&, const std::string&); -Botan::Filter* lookup_cipher(const std::string&, const std::string&, - const std::string&, bool); -Botan::Filter* lookup_hash(const std::string&); -Botan::Filter* lookup_mac(const std::string&, const std::string&); -Botan::Filter* lookup_rng(const std::string&, const std::string&); -Botan::Filter* lookup_encoder(const std::string&); -Botan::Filter* lookup_pbkdf(const std::string&, - const std::vector<std::string>&); -Botan::Filter* lookup_kdf(const std::string&, const std::string&, - const std::string&); - class Fixed_Output_RNG : public Botan::RandomNumberGenerator { public: |