Botan 3.6.1
Crypto and TLS for C&
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
15namespace Botan {
16
17class RandomNumberGenerator;
18
19/**
20* A split secret, using the format from draft-mcgrew-tss-03
21*/
23 public:
24 /**
25 * @param M the number of shares needed to reconstruct
26 * @param N the number of shares generated
27 * @param secret the secret to split
28 * @param secret_len the length of the secret
29 * @param identifier the 16 byte share identifier
30 * @param rng the random number generator to use
31 */
32 static std::vector<RTSS_Share> split(uint8_t M,
33 uint8_t N,
34 const uint8_t secret[],
35 uint16_t secret_len,
36 const uint8_t identifier[16],
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> split(uint8_t M,
49 uint8_t N,
50 const uint8_t secret[],
51 uint16_t secret_len,
52 const std::vector<uint8_t>& identifier,
53 std::string_view hash_fn,
55
56 /**
57 * @param shares the list of shares
58 */
59 static secure_vector<uint8_t> 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(std::string_view 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.empty()); }
98
99 private:
100 secure_vector<uint8_t> m_contents;
101};
102
103} // namespace Botan
104
105#endif
const secure_vector< uint8_t > & data() const
Definition tss.h:77
size_t size() const
Definition tss.h:92
RTSS_Share()=default
bool initialized() const
Definition tss.h:97
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition compiler.h:31
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:61