aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_block.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2014-01-07 11:03:55 +0000
committerlloyd <[email protected]>2014-01-07 11:03:55 +0000
commitc109c7f84fcef6ba895c6293508b2deae0e803c1 (patch)
tree35ba7b55914023a77ecfbcf5dee2befcc4e275d1 /src/tests/test_block.cpp
parenta7e3abf95fd1bc3df45be6fc9cb82e28e0a727ea (diff)
Rename test sources
Diffstat (limited to 'src/tests/test_block.cpp')
-rw-r--r--src/tests/test_block.cpp75
1 files changed, 0 insertions, 75 deletions
diff --git a/src/tests/test_block.cpp b/src/tests/test_block.cpp
deleted file mode 100644
index 9da33ef0e..000000000
--- a/src/tests/test_block.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-#include "tests.h"
-
-#include <botan/libstate.h>
-#include <botan/block_cipher.h>
-#include <botan/hex.h>
-#include <iostream>
-#include <fstream>
-
-using namespace Botan;
-
-namespace {
-
-size_t block_test(const std::string& algo,
- const std::string& key_hex,
- const std::string& in_hex,
- const std::string& out_hex)
- {
- const secure_vector<byte> key = hex_decode_locked(key_hex);
- const secure_vector<byte> pt = hex_decode_locked(in_hex);
- const secure_vector<byte> ct = hex_decode_locked(out_hex);
-
- Algorithm_Factory& af = global_state().algorithm_factory();
-
- const auto providers = af.providers_of(algo);
- size_t fails = 0;
-
- for(auto provider: providers)
- {
- const BlockCipher* proto = af.prototype_block_cipher(algo, provider);
-
- if(!proto)
- {
- std::cout << "Unable to get " << algo << " from " << provider << "\n";
- ++fails;
- continue;
- }
-
- std::unique_ptr<BlockCipher> cipher(proto->clone());
- cipher->set_key(key);
- secure_vector<byte> buf = pt;
-
- cipher->encrypt(buf);
-
- if(buf != ct)
- {
- std::cout << algo << " " << provider << " enc " << hex_encode(buf) << " != " << out_hex << "\n";
- ++fails;
- }
-
- buf = ct;
-
- cipher->decrypt(buf);
-
- if(buf != pt)
- {
- std::cout << algo << " " << provider << " dec " << hex_encode(buf) << " != " << out_hex << "\n";
- ++fails;
- }
- }
-
- return fails;
- }
-
-}
-
-size_t test_block()
- {
- std::ifstream vec(TEST_DATA_DIR "/block.vec");
-
- return run_tests_bb(vec, "BlockCipher", "Out", true,
- [](std::map<std::string, std::string> m) -> size_t
- {
- return block_test(m["BlockCipher"], m["Key"], m["In"], m["Out"]);
- });
- }