blob: 38d9dfbfa1eb7df2d6cfbef83082bac477e99198 (
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
62
63
64
65
66
67
68
69
70
71
|
/*
* (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 <iostream>
#include <stdio.h>
#if defined(BOTAN_HAS_THRESHOLD_SECRET_SHARING)
#include <botan/tss.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;
}
#else
size_t test_tss()
{
std::cout << "Skipping TSS tests\n";
return 1;
}
#endif
|