aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2014-01-01 22:15:17 +0000
committerlloyd <[email protected]>2014-01-01 22:15:17 +0000
commit046d889fc76e96711ffacc658da3046720045caa (patch)
tree5dce7f9141fc0a1d79634f028d51dd171be8e931 /src
parent42ef886735e7f48b3713f6e40dce0cfabf18369f (diff)
Make tss example a test of sorts
Diffstat (limited to 'src')
-rw-r--r--src/tests/test_tss.cpp61
-rw-r--r--src/tests/tests.cpp1
-rw-r--r--src/tests/tests.h8
3 files changed, 65 insertions, 5 deletions
diff --git a/src/tests/test_tss.cpp b/src/tests/test_tss.cpp
new file mode 100644
index 000000000..f9caddb6f
--- /dev/null
+++ b/src/tests/test_tss.cpp
@@ -0,0 +1,61 @@
+/*
+* (C) 2009 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#include "tests.h"
+#include <botan/auto_rng.h>
+#include <botan/hex.h>
+#include <botan/tss.h>
+#include <iostream>
+#include <stdio.h>
+
+namespace {
+
+void print(const Botan::secure_vector<Botan::byte>& r)
+ {
+ for(Botan::u32bit i = 0; i != r.size(); ++i)
+ printf("%02X", r[i]);
+ printf("\n");
+ }
+
+}
+
+size_t test_tss()
+ {
+ using namespace Botan;
+
+ AutoSeeded_RNG 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");
+
+ std::vector<RTSS_Share> shares =
+ RTSS_Share::split(2, 4, &S[0], S.size(), id, rng);
+
+ auto back = RTSS_Share::reconstruct(shares);
+
+ if(S != back)
+ {
+ std::cout << "TSS-0: " << hex_encode(S) << " != " << hex_encode(back) << "\n";
+ ++fails;
+ }
+
+ shares.resize(shares.size()-1);
+
+ back = RTSS_Share::reconstruct(shares);
+
+ if(S != back)
+ {
+ std::cout << "TSS-1: " << hex_encode(S) << " != " << hex_encode(back) << "\n";
+ ++fails;
+ }
+
+ return fails;
+ }
diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp
index 49f55c165..622894803 100644
--- a/src/tests/tests.cpp
+++ b/src/tests/tests.cpp
@@ -174,6 +174,7 @@ size_t run_all_tests()
all_tests.push_back(test_passhash9);
all_tests.push_back(test_bcrypt);
all_tests.push_back(test_cryptobox);
+ all_tests.push_back(test_tss);
all_tests.push_back(test_bigint);
all_tests.push_back(test_pubkey);
diff --git a/src/tests/tests.h b/src/tests/tests.h
index cb1e0f585..dff493f5f 100644
--- a/src/tests/tests.h
+++ b/src/tests/tests.h
@@ -39,11 +39,8 @@ size_t test_block();
size_t test_stream();
size_t test_hash();
size_t test_mac();
-
size_t test_modes();
-
size_t test_rngs();
-
size_t test_hkdf();
size_t test_pbkdf();
size_t test_kdf();
@@ -57,14 +54,14 @@ size_t test_keywrap();
size_t test_bcrypt();
size_t test_passhash9();
size_t test_cryptobox();
+size_t test_tss();
+// File driven tests
size_t test_bigint();
-
size_t test_pubkey();
size_t test_pk_keygen();
size_t test_ecc();
-
size_t test_ecdsa();
size_t test_ecdh();
@@ -72,6 +69,7 @@ size_t test_x509();
size_t test_cvc();
size_t test_tls();
+
size_t test_nist_x509();
#endif