blob: 646ebe4154f62866f8f549b77bcb8466f8e8bcbd (
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
|
/*
* (C) 2009 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#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) << "\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;
}
#else
size_t test_tss()
{
std::cout << "Skipping TSS tests\n";
return 1;
}
#endif
|