aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorDaniel Neus <[email protected]>2016-03-06 11:33:09 +0100
committerDaniel Neus <[email protected]>2016-03-06 11:33:09 +0100
commit464e9eccbb61738582f85a81dd4b586bd3d6898e (patch)
treeb7fac2f6ef79557f55de1213016e0e576ec5ea28 /src/tests
parentc4e5802112b4000950aca376ca13cd125085a177 (diff)
parent027733a7d7ae44e8eb0c96cef371ba592f4cd386 (diff)
Merge branch 'master' into clang-analyzer
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/test_entropy.cpp7
-rw-r--r--src/tests/test_filters.cpp63
-rw-r--r--src/tests/test_rng.cpp2
-rw-r--r--src/tests/test_rng.h4
-rw-r--r--src/tests/tests.h4
-rw-r--r--src/tests/unit_ecdsa.cpp4
6 files changed, 76 insertions, 8 deletions
diff --git a/src/tests/test_entropy.cpp b/src/tests/test_entropy.cpp
index 0ffee8491..201dd02b5 100644
--- a/src/tests/test_entropy.cpp
+++ b/src/tests/test_entropy.cpp
@@ -70,6 +70,13 @@ class Entropy_Source_Tests : public Test
{
for(const std::string comp_algo : { "zlib", "bzip2", "lzma" })
{
+#if defined(BOTAN_TARGET_OS_IS_DARWIN)
+ if(comp_algo == "bzip2")
+ {
+ // Skip due to unresolved OS X specific issue GH #394
+ continue;
+ }
+#endif
std::unique_ptr<Botan::Compressor_Transform> comp(Botan::make_compressor(comp_algo, 9));
if(comp)
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/test_rng.cpp b/src/tests/test_rng.cpp
index a5dbbc8e1..6a9580345 100644
--- a/src/tests/test_rng.cpp
+++ b/src/tests/test_rng.cpp
@@ -24,7 +24,7 @@ Botan::RandomNumberGenerator* get_rng(const std::string& algo_str, const std::ve
class AllOnce_RNG : public Fixed_Output_RNG
{
public:
- AllOnce_RNG(const std::vector<byte>& in) : Fixed_Output_RNG(in) {}
+ explicit AllOnce_RNG(const std::vector<byte>& in) : Fixed_Output_RNG(in) {}
Botan::secure_vector<byte> random_vec(size_t) override
{
diff --git a/src/tests/test_rng.h b/src/tests/test_rng.h
index f168a07db..f7b0bf6fe 100644
--- a/src/tests/test_rng.h
+++ b/src/tests/test_rng.h
@@ -49,12 +49,12 @@ class Fixed_Output_RNG : public Botan::RandomNumberGenerator
void clear() throw() override {}
- Fixed_Output_RNG(const std::vector<uint8_t>& in)
+ explicit Fixed_Output_RNG(const std::vector<uint8_t>& in)
{
m_buf.insert(m_buf.end(), in.begin(), in.end());
}
- Fixed_Output_RNG(const std::string& in_str)
+ explicit Fixed_Output_RNG(const std::string& in_str)
{
std::vector<uint8_t> in = Botan::hex_decode(in_str);
m_buf.insert(m_buf.end(), in.begin(), in.end());
diff --git a/src/tests/tests.h b/src/tests/tests.h
index 0c561a7d3..0bb65778a 100644
--- a/src/tests/tests.h
+++ b/src/tests/tests.h
@@ -41,7 +41,7 @@ using Botan::BigInt;
class Test_Error : public Botan::Exception
{
public:
- Test_Error(const std::string& what) : Exception("Test error", what) {}
+ explicit Test_Error(const std::string& what) : Exception("Test error", what) {}
};
/*
@@ -61,7 +61,7 @@ class Test
class Result
{
public:
- Result(const std::string& who) : m_who(who) {}
+ explicit Result(const std::string& who) : m_who(who) {}
size_t tests_passed() const { return m_tests_passed; }
size_t tests_failed() const { return m_fail_log.size(); }
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)");