blob: fad85f93ce3c4869275d5219551e8f96a4f15107 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
/*
* (C) 2009 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
#include "tests.h"
#include <botan/hex.h>
#include <iostream>
#if defined(BOTAN_HAS_THRESHOLD_SECRET_SHARING)
#include <botan/tss.h>
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");
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) << std::endl;
++fails;
}
shares.resize(shares.size()-1);
back = RTSS_Share::reconstruct(shares);
if(S != back)
{
std::cout << "TSS-1: " << hex_encode(S) << " != " << hex_encode(back) << std::endl;
++fails;
}
test_report("TSS", 2, fails);
return fails;
}
#else
size_t test_tss()
{
std::cout << "Skipping TSS tests" << std::endl;
return 1;
}
#endif
|