blob: 297c659716723dcec4a9be9765847510c67d17c3 (
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
72
73
74
75
76
|
/*
* RTSS (threshold secret sharing)
* (C) 2009 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_RTSS_H__
#define BOTAN_RTSS_H__
#include <botan/secmem.h>
#include <botan/hash.h>
#include <botan/rng.h>
#include <vector>
namespace Botan {
/**
* A split secret, using the format from draft-mcgrew-tss-03
*/
class BOTAN_DLL RTSS_Share
{
public:
/**
* @param M the number of shares needed to reconstruct
* @param N the number of shares generated
* @param secret the secret to split
* @param secret_len the length of the secret
* @param identifier the 16 byte share identifier
* @param rng the random number generator to use
*/
static std::vector<RTSS_Share>
split(byte M, byte N,
const byte secret[], u16bit secret_len,
const byte identifier[16],
RandomNumberGenerator& rng);
/**
* @param shares the list of shares
*/
static SecureVector<byte>
reconstruct(const std::vector<RTSS_Share>& shares);
RTSS_Share() {}
/**
* @param hex_input the share encoded in hexadecimal
*/
RTSS_Share(const std::string& hex_input);
/**
* @return hex representation
*/
std::string to_string() const;
/**
* @return share identifier
*/
byte share_id() const;
/**
* @return size of this share in bytes
*/
size_t size() const { return contents.size(); }
/**
* @return if this TSS share was initialized or not
*/
bool initialized() const { return (contents.size() > 0); }
private:
SecureVector<byte> contents;
};
}
#endif
|