diff options
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/test_filters.cpp | 63 | ||||
-rw-r--r-- | src/tests/unit_ecdsa.cpp | 4 | ||||
-rw-r--r-- | src/tests/unit_tls.cpp | 4 |
3 files changed, 66 insertions, 5 deletions
diff --git a/src/tests/test_filters.cpp b/src/tests/test_filters.cpp new file mode 100644 index 000000000..35d578789 --- /dev/null +++ b/src/tests/test_filters.cpp @@ -0,0 +1,63 @@ +/* +* (C) 2016 Daniel Neus +* +* Botan is released under the Simplified BSD License (see license.txt) +*/ + +#include "tests.h" + +#if defined(BOTAN_HAS_FILTERS) + #include <botan/secqueue.h> +#endif + +namespace Botan_Tests { + +#if defined(BOTAN_HAS_FILTERS) + +class Filter_Tests : public Test + { + public: + std::vector<Test::Result> run() override + { + std::vector<Test::Result> results; + Test::Result secqueue_result("SecureQueue"); + + try + { + using Botan::SecureQueue; + SecureQueue queue_a; + std::vector<uint8_t> test_data = {0x24, 0xB2, 0xBF, 0xC2, 0xE6, 0xD4, 0x7E, 0x04, 0x67, 0xB3}; + queue_a.write(test_data.data(), test_data.size()); + + secqueue_result.test_eq("size of SecureQueue is correct", queue_a.size(), test_data.size()); + secqueue_result.test_eq("0 bytes read so far from SecureQueue", queue_a.get_bytes_read(), 0); + + uint8_t byte; + size_t bytes_read = queue_a.read_byte(byte); + secqueue_result.test_eq("1 byte read", bytes_read, 1); + + Botan::secure_vector<uint8_t> produced(byte); + Botan::secure_vector<uint8_t> expected(test_data.at(0)); + secqueue_result.test_eq("byte read is correct", produced, expected); + + secqueue_result.test_eq("1 bytes read so far from SecureQueue", queue_a.get_bytes_read(), 1); + + SecureQueue queue_b; + queue_a = queue_b; + secqueue_result.test_eq("bytes_read is set correctly", queue_a.get_bytes_read(), 0); + } + catch (std::exception& e) + { + secqueue_result.test_failure("SecureQueue", e.what()); + } + + results.push_back(secqueue_result); + return results; + } + }; + + BOTAN_REGISTER_TEST("filter", Filter_Tests); + +#endif + +} diff --git a/src/tests/unit_ecdsa.cpp b/src/tests/unit_ecdsa.cpp index 5b750e7fb..ecafb3c7f 100644 --- a/src/tests/unit_ecdsa.cpp +++ b/src/tests/unit_ecdsa.cpp @@ -61,7 +61,7 @@ Test::Result test_hash_larger_than_n() try { - std::vector<byte> signature_224 = pk_signer_224.sign_message(message, Test::rng()); + pk_signer_224.sign_message(message, Test::rng()); result.test_failure("bad key/hash combination not rejected"); } catch(Botan::Encoding_Error) @@ -152,8 +152,6 @@ Test::Result test_ec_sign() { Botan::EC_Group dom_pars(Botan::OID("1.3.132.0.8")); Botan::ECDSA_PrivateKey priv_key(Test::rng(), dom_pars); - std::string pem_encoded_key = Botan::PKCS8::PEM_encode(priv_key); - Botan::PK_Signer signer(priv_key, "EMSA1(SHA-224)"); Botan::PK_Verifier verifier(priv_key, "EMSA1(SHA-224)"); diff --git a/src/tests/unit_tls.cpp b/src/tests/unit_tls.cpp index 0fa208858..f125bfcb5 100644 --- a/src/tests/unit_tls.cpp +++ b/src/tests/unit_tls.cpp @@ -527,7 +527,7 @@ Test::Result test_dtls_handshake(Botan::TLS::Protocol_Version offer_version, { input.resize(needed); Test::rng().randomize(input.data(), input.size()); - needed = client.received_data(input.data(), input.size()); + client.received_data(input.data(), input.size()); } } catch(std::exception&) @@ -567,7 +567,7 @@ Test::Result test_dtls_handshake(Botan::TLS::Protocol_Version offer_version, { input.resize(needed); Test::rng().randomize(input.data(), input.size()); - needed = client.received_data(input.data(), input.size()); + client.received_data(input.data(), input.size()); } } catch(std::exception&) |