Botan 2.13.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

tss.h
Go to the documentation of this file.
1 /*
2 * RTSS (threshold secret sharing)
3 * (C) 2009,2018 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7
8 #ifndef BOTAN_RTSS_H_
9 #define BOTAN_RTSS_H_
10
11 #include <botan/secmem.h>
12 #include <string>
13 #include <vector>
14
15 namespace Botan {
16
17 class RandomNumberGenerator;
18
19 /**
20 * A split secret, using the format from draft-mcgrew-tss-03
21 */
22 class BOTAN_PUBLIC_API(2,0) RTSS_Share final
23 {
24 public:
25 /**
26 * @param M the number of shares needed to reconstruct
27 * @param N the number of shares generated
28 * @param secret the secret to split
29 * @param secret_len the length of the secret
30 * @param identifier the 16 byte share identifier
31 * @param rng the random number generator to use
32 */
33 static std::vector<RTSS_Share>
34 split(uint8_t M, uint8_t N,
35 const uint8_t secret[], uint16_t secret_len,
36 const uint8_t identifier[16],
37 RandomNumberGenerator& rng);
38
39 /**
40 * @param M the number of shares needed to reconstruct
41 * @param N the number of shares generated
42 * @param secret the secret to split
43 * @param secret_len the length of the secret
44 * @param identifier the share identifier
45 * @param hash_fn the hash function to use for a checksum ("None", "SHA-1", "SHA-256")
46 * @param rng the random number generator to use
47 */
48 static std::vector<RTSS_Share>
49 split(uint8_t M, uint8_t N,
50 const uint8_t secret[], uint16_t secret_len,
51 const std::vector<uint8_t>& identifier,
52 const std::string& hash_fn,
53 RandomNumberGenerator& rng);
54
55 /**
56 * @param shares the list of shares
57 */
58 static secure_vector<uint8_t>
59 reconstruct(const std::vector<RTSS_Share>& shares);
60
61 RTSS_Share() = default;
62
63 /**
64 * @param hex_input the share encoded in hexadecimal
65 */
66 explicit RTSS_Share(const std::string& hex_input);
67
68 /**
69 * @param data the shared data
70 * @param len the length of data
71 */
72 RTSS_Share(const uint8_t data[], size_t len);
73
74 /**
75 * @return binary representation
76 */
77 const secure_vector<uint8_t>& data() const { return m_contents; }
78
79 /**
80 * @return hex representation
81 */
82 std::string to_string() const;
83
84 /**
85 * @return share identifier
86 */
87 uint8_t share_id() const;
88
89 /**
90 * @return size of this share in bytes
91 */
92 size_t size() const { return m_contents.size(); }
93
94 /**
95 * @return if this TSS share was initialized or not
96 */
97 bool initialized() const { return (m_contents.size() > 0); }
98 private:
99 secure_vector<uint8_t> m_contents;
100 };
101
102 }
103
104 #endif
Botan::RTSS_Share::size
size_t size() const
Definition: tss.h:92
Botan::RandomNumberGenerator
Definition: rng.h:24
Botan::RTSS_Share::initialized
bool initialized() const
Definition: tss.h:97
final
int(* final)(unsigned char *, CTX *)
Definition: commoncrypto_hash.cpp:28
BOTAN_PUBLIC_API
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
Botan::to_string
std::string to_string(ErrorType type)
Convert an ErrorType to string.
Definition: exceptn.cpp:11
Botan::secure_vector
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:65
Botan
Definition: alg_id.cpp:13
Botan::RTSS_Share
Definition: tss.h:22
Botan::RTSS_Share::data
const secure_vector< uint8_t > & data() const
Definition: tss.h:77