Botan  2.4.0
Crypto and TLS for C++11
tss.h
Go to the documentation of this file.
1 /*
2 * RTSS (threshold secret sharing)
3 * (C) 2009 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 <vector>
13 
14 namespace Botan {
15 
16 class RandomNumberGenerator;
17 
18 /**
19 * A split secret, using the format from draft-mcgrew-tss-03
20 */
21 class BOTAN_PUBLIC_API(2,0) RTSS_Share final
22  {
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>
33  split(uint8_t M, uint8_t N,
34  const uint8_t secret[], uint16_t secret_len,
35  const uint8_t identifier[16],
37 
38  /**
39  * @param shares the list of shares
40  */
42  reconstruct(const std::vector<RTSS_Share>& shares);
43 
44  RTSS_Share() = default;
45 
46  /**
47  * @param hex_input the share encoded in hexadecimal
48  */
49  explicit RTSS_Share(const std::string& hex_input);
50 
51  /**
52  * @return hex representation
53  */
54  std::string to_string() const;
55 
56  /**
57  * @return share identifier
58  */
59  uint8_t share_id() const;
60 
61  /**
62  * @return size of this share in bytes
63  */
64  size_t size() const { return m_contents.size(); }
65 
66  /**
67  * @return if this TSS share was initialized or not
68  */
69  bool initialized() const { return (m_contents.size() > 0); }
70  private:
71  secure_vector<uint8_t> m_contents;
72  };
73 
74 }
75 
76 #endif
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:27
size_t size() const
Definition: tss.h:64
bool initialized() const
Definition: tss.h:69
Definition: alg_id.cpp:13
std::string to_string(const secure_vector< uint8_t > &bytes)
Definition: stl_util.h:25
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:88