aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_tss.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2015-11-11 05:43:01 -0500
committerJack Lloyd <[email protected]>2015-11-11 05:43:01 -0500
commitcf05aea092fad448c2f4a8e8b66159237096ba8e (patch)
tree00631bcc84809a1eeac5dd32dd92c62143ef831b /src/tests/test_tss.cpp
parent6bb38ae2fa0e1be46b3a3256ac03f435b16a57ea (diff)
Update and consolidate the test framework.
The tests previously had used 4 to 6 different schemes internally (the vec file reader framework, Catch, the old InSiTo Boost.Test tests, the PK/BigInt tests which escaped the rewrite in 1.11.7, plus a number of one-offs). Converge on a design that works everywhere, and update all the things. Fix also a few bugs found by the test changes: SHA-512-256 name incorrect, OpenSSL RC4 name incorrect, signature of FFI function botan_pubkey_destroy was wrong.
Diffstat (limited to 'src/tests/test_tss.cpp')
-rw-r--r--src/tests/test_tss.cpp67
1 files changed, 30 insertions, 37 deletions
diff --git a/src/tests/test_tss.cpp b/src/tests/test_tss.cpp
index c5440634b..96e3fa9ee 100644
--- a/src/tests/test_tss.cpp
+++ b/src/tests/test_tss.cpp
@@ -7,53 +7,46 @@
#include "tests.h"
#if defined(BOTAN_HAS_THRESHOLD_SECRET_SHARING)
+ #include <botan/tss.h>
+ #include <botan/hex.h>
+#endif
-#include <iostream>
-#include <botan/hex.h>
-#include <botan/tss.h>
+namespace Botan_Tests {
-size_t test_tss()
- {
- using namespace Botan;
-
- auto& rng = test_rng();
-
- size_t fails = 0;
-
- byte id[16];
- for(int i = 0; i != 16; ++i)
- id[i] = i;
-
- const secure_vector<byte> S = hex_decode_locked("7465737400");
+namespace {
- std::vector<RTSS_Share> shares =
- RTSS_Share::split(2, 4, S.data(), S.size(), id, rng);
+#if defined(BOTAN_HAS_THRESHOLD_SECRET_SHARING)
- auto back = RTSS_Share::reconstruct(shares);
+class TSS_Tests : public Test
+ {
+ public:
+ std::vector<Test::Result> run() override
+ {
+ std::vector<Test::Result> results;
- if(S != back)
- {
- std::cout << "TSS-0: " << hex_encode(S) << " != " << hex_encode(back) << std::endl;
- ++fails;
- }
+ Test::Result result("TSS");
+ byte id[16];
+ for(int i = 0; i != 16; ++i)
+ id[i] = i;
- shares.resize(shares.size()-1);
+ const std::vector<byte> S = Botan::hex_decode("7465737400");
- back = RTSS_Share::reconstruct(shares);
+ std::vector<Botan::RTSS_Share> shares =
+ Botan::RTSS_Share::split(2, 4, S.data(), S.size(), id, Test::rng());
- if(S != back)
- {
- std::cout << "TSS-1: " << hex_encode(S) << " != " << hex_encode(back) << std::endl;
- ++fails;
- }
+ result.test_eq("reconstruction", Botan::RTSS_Share::reconstruct(shares), S);
+ shares.resize(shares.size()-1);
+ result.test_eq("reconstruction after removal", Botan::RTSS_Share::reconstruct(shares), S);
- test_report("TSS", 2, fails);
+ results.push_back(result);
+ return results;
+ }
+ };
- return fails;
- }
+BOTAN_REGISTER_TEST("tss", TSS_Tests);
-#else
+#endif // BOTAN_HAS_THRESHOLD_SECRET_SHARING
-SKIP_TEST(tss);
+}
-#endif // BOTAN_HAS_THRESHOLD_SECRET_SHARING
+}