diff options
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/test_modes.cpp | 20 | ||||
-rw-r--r-- | src/tests/test_pubkey.cpp | 11 | ||||
-rw-r--r-- | src/tests/unit_x509.cpp | 23 |
3 files changed, 13 insertions, 41 deletions
diff --git a/src/tests/test_modes.cpp b/src/tests/test_modes.cpp index 81a15445e..f443ddabf 100644 --- a/src/tests/test_modes.cpp +++ b/src/tests/test_modes.cpp @@ -8,11 +8,8 @@ #if defined(BOTAN_HAS_MODES) -#if defined(BOTAN_HAS_FILTERS) - #include <botan/hex.h> #include <botan/cipher_mode.h> -#include <botan/filters.h> #include <iostream> #include <fstream> #include <memory> @@ -27,21 +24,16 @@ secure_vector<byte> run_mode(const std::string& algo, const secure_vector<byte>& nonce, const secure_vector<byte>& key) { -#if 0 std::unique_ptr<Cipher_Mode> cipher(get_cipher_mode(algo, dir)); + if(!cipher) + throw std::runtime_error("No cipher " + algo + " enabled in build"); cipher->set_key(key); cipher->start(nonce); secure_vector<byte> ct = pt; cipher->finish(ct); -#else - Pipe pipe(get_cipher(algo, SymmetricKey(key), InitializationVector(nonce), dir)); - - pipe.process_msg(pt); - - return pipe.read_all(); -#endif + return ct; } size_t mode_test(const std::string& algo, @@ -102,12 +94,6 @@ size_t test_modes() #else -UNTESTED_WARNING(modes); - -#endif // BOTAN_HAS_FILTERS - -#else - SKIP_TEST(modes); #endif // BOTAN_HAS_MODES diff --git a/src/tests/test_pubkey.cpp b/src/tests/test_pubkey.cpp index f5528af12..09f3843bb 100644 --- a/src/tests/test_pubkey.cpp +++ b/src/tests/test_pubkey.cpp @@ -22,6 +22,7 @@ #include <botan/x509_key.h> #include <botan/pkcs8.h> #include <botan/pubkey.h> +#include <botan/hex.h> #if defined(BOTAN_HAS_RSA) #include <botan/rsa.h> @@ -64,8 +65,8 @@ #include <botan/kdf.h> #endif -#include <botan/filters.h> #include <botan/numthry.h> + using namespace Botan; namespace { @@ -73,12 +74,8 @@ namespace { void dump_data(const std::vector<byte>& out, const std::vector<byte>& expected) { - Pipe pipe(new Hex_Encoder); - - pipe.process_msg(out); - pipe.process_msg(expected); - std::cout << "Got: " << pipe.read_all_as_string(0) << std::endl; - std::cout << "Exp: " << pipe.read_all_as_string(1) << std::endl; + std::cout << "Got: " << hex_encode(out) << std::endl; + std::cout << "Exp: " << hex_encode(expected) << std::endl; } size_t validate_save_and_load(const Private_Key* priv_key, diff --git a/src/tests/unit_x509.cpp b/src/tests/unit_x509.cpp index f77be1992..2040e4bbf 100644 --- a/src/tests/unit_x509.cpp +++ b/src/tests/unit_x509.cpp @@ -11,7 +11,6 @@ #if defined(BOTAN_HAS_RSA) && defined(BOTAN_HAS_DSA) #include <botan/calendar.h> -#include <botan/filters.h> #include <botan/pkcs8.h> #include <botan/pkcs10.h> #include <botan/x509self.h> @@ -45,22 +44,12 @@ X509_Time from_date(const int y, const int m, const int d) u64bit key_id(const Public_Key* key) { - Pipe pipe(new Hash_Filter("SHA-1", 8)); - pipe.start_msg(); - pipe.write(key->algo_name()); - pipe.write(key->algorithm_identifier().parameters); - pipe.write(key->x509_subject_public_key()); - pipe.end_msg(); - - secure_vector<byte> output = pipe.read_all(); - - if(output.size() != 8) - throw Internal_Error("Public_Key::key_id: Incorrect output size"); - - u64bit id = 0; - for(u32bit j = 0; j != 8; ++j) - id = (id << 8) | output[j]; - return id; + std::unique_ptr<HashFunction> hash(HashFunction::create("SHA-1")); + hash->update(key->algo_name()); + hash->update(key->algorithm_identifier().parameters); + hash->update(key->x509_subject_public_key()); + secure_vector<byte> output = hash->final(); + return load_be<u64bit>(output.data()); } |