blob: 01e0da92fb54bf5f6316bc1282d8d190794eb449 (
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
|
/*
* (C) 2009 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
#include "tests.h"
#if defined(BOTAN_HAS_THRESHOLD_SECRET_SHARING)
#include <botan/tss.h>
#include <botan/hex.h>
#endif
#include <numeric>
namespace Botan_Tests {
namespace {
#if defined(BOTAN_HAS_THRESHOLD_SECRET_SHARING)
class TSS_Tests : public Test
{
public:
std::vector<Test::Result> run() override
{
std::vector<Test::Result> results;
Test::Result result("TSS");
uint8_t id[16];
std::iota(id, id + sizeof(id), 0);
const std::vector<uint8_t> S = Botan::hex_decode("7465737400");
std::vector<Botan::RTSS_Share> shares =
Botan::RTSS_Share::split(2, 4, S.data(), S.size(), id, Test::rng());
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);
results.push_back(result);
return results;
}
};
BOTAN_REGISTER_TEST("tss", TSS_Tests);
#endif // BOTAN_HAS_THRESHOLD_SECRET_SHARING
}
}
|