diff options
author | lloyd <[email protected]> | 2014-01-07 11:03:55 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2014-01-07 11:03:55 +0000 |
commit | c109c7f84fcef6ba895c6293508b2deae0e803c1 (patch) | |
tree | 35ba7b55914023a77ecfbcf5dee2befcc4e275d1 /src/tests/test_aead.cpp | |
parent | a7e3abf95fd1bc3df45be6fc9cb82e28e0a727ea (diff) |
Rename test sources
Diffstat (limited to 'src/tests/test_aead.cpp')
-rw-r--r-- | src/tests/test_aead.cpp | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/src/tests/test_aead.cpp b/src/tests/test_aead.cpp deleted file mode 100644 index 0bc4a47c5..000000000 --- a/src/tests/test_aead.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include "tests.h" - -#include <botan/hex.h> -#include <botan/aead.h> -#include <iostream> -#include <fstream> -#include <memory> - -using namespace Botan; - -namespace { - -secure_vector<byte> aead(const std::string& algo, - Cipher_Dir dir, - const secure_vector<byte>& pt, - const secure_vector<byte>& nonce, - const secure_vector<byte>& ad, - const secure_vector<byte>& key) - { - std::unique_ptr<AEAD_Mode> aead(get_aead(algo, dir)); - - aead->set_key(key); - aead->set_associated_data_vec(ad); - aead->start_vec(nonce); - - secure_vector<byte> ct = pt; - aead->finish(ct); - - return ct; - } - -size_t aead_test(const std::string& algo, - const std::string& pt, - const std::string& ct, - const std::string& nonce_hex, - const std::string& ad_hex, - const std::string& key_hex) - { - auto nonce = hex_decode_locked(nonce_hex); - auto ad = hex_decode_locked(ad_hex); - auto key = hex_decode_locked(key_hex); - - size_t fail = 0; - - //std::cout << algo << " pt=" << pt << " ct=" << ct << " key=" << key_hex << " nonce=" << nonce_hex << " ad=" << ad_hex << "\n"; - - const std::string ct2 = hex_encode(aead(algo, - ENCRYPTION, - hex_decode_locked(pt), - nonce, - ad, - key)); - - if(ct != ct2) - { - std::cout << algo << " got ct " << ct2 << " expected " << ct << "\n"; - ++fail; - } - - const std::string pt2 = hex_encode(aead(algo, - DECRYPTION, - hex_decode_locked(ct2), - nonce, - ad, - key)); - - if(pt != pt2) - { - std::cout << algo << " got pt " << pt2 << " expected " << pt << "\n"; - ++fail; - } - - return fail; - } - -} - -size_t test_aead() - { - std::ifstream vec(TEST_DATA_DIR "/aead.vec"); - - return run_tests_bb(vec, "AEAD", "Out", true, - [](std::map<std::string, std::string> m) - { - return aead_test(m["AEAD"], m["In"], m["Out"], - m["Nonce"], m["AD"], m["Key"]); - }); - } |