Botan  2.16.0
Crypto and TLS for C++11
xmss_wots_parameters.h
Go to the documentation of this file.
1 /*
2  * XMSS WOTS Parameters
3  * (C) 2016,2018 Matthias Gierlings
4  *
5  * Botan is released under the Simplified BSD License (see license.txt)
6  **/
7 
8 #ifndef BOTAN_XMSS_WOTS_PARAMETERS_H_
9 #define BOTAN_XMSS_WOTS_PARAMETERS_H_
10 
11 #include <botan/xmss_tools.h>
12 #include <botan/secmem.h>
13 #include <map>
14 #include <string>
15 
16 namespace Botan {
17 
18 /**
19  * Descibes a signature method for XMSS Winternitz One Time Signatures,
20  * as defined in:
21  * [1] XMSS: Extended Hash-Based Signatures,
22  * Request for Comments: 8391
23  * Release: May 2018.
24  * https://datatracker.ietf.org/doc/rfc8391/
25  **/
27  {
28  public:
30  {
31  WOTSP_SHA2_256 = 0x00000001,
32  WOTSP_SHA2_512 = 0x00000002,
33  WOTSP_SHAKE_256 = 0x00000003,
34  WOTSP_SHAKE_512 = 0x00000004
35  };
36 
37  XMSS_WOTS_Parameters(const std::string& algo_name);
39 
40  static ots_algorithm_t xmss_wots_id_from_string(const std::string& param_set);
41 
42  /**
43  * Algorithm 1: convert input string to base.
44  *
45  * @param msg Input string (referred to as X in [1]).
46  * @param out_size size of message in base w.
47  *
48  * @return Input string converted to the given base.
49  **/
50  secure_vector<uint8_t> base_w(const secure_vector<uint8_t>& msg, size_t out_size) const;
51 
52  secure_vector<uint8_t> base_w(size_t value) const;
53 
55 
56  /**
57  * @return XMSS WOTS registry name for the chosen parameter set.
58  **/
59  const std::string& name() const
60  {
61  return m_name;
62  }
63 
64  /**
65  * @return Botan name for the hash function used.
66  **/
67  const std::string& hash_function_name() const
68  {
69  return m_hash_name;
70  }
71 
72  /**
73  * Retrieves the uniform length of a message, and the size of
74  * each node. This correlates to XMSS parameter "n" defined
75  * in [1].
76  *
77  * @return element length in bytes.
78  **/
79  size_t element_size() const { return m_element_size; }
80 
81  /**
82  * The Winternitz parameter.
83  *
84  * @return numeric base used for internal representation of
85  * data.
86  **/
87  size_t wots_parameter() const { return m_w; }
88 
89  size_t len() const { return m_len; }
90 
91  size_t len_1() const { return m_len_1; }
92 
93  size_t len_2() const { return m_len_2; }
94 
95  size_t lg_w() const { return m_lg_w; }
96 
97  ots_algorithm_t oid() const { return m_oid; }
98 
99  size_t estimated_strength() const { return m_strength; }
100 
101  bool operator==(const XMSS_WOTS_Parameters& p) const
102  {
103  return m_oid == p.m_oid;
104  }
105 
106  private:
107  static const std::map<std::string, ots_algorithm_t> m_oid_name_lut;
108  ots_algorithm_t m_oid;
109  std::string m_name;
110  std::string m_hash_name;
111  size_t m_element_size;
112  size_t m_w;
113  size_t m_len_1;
114  size_t m_len_2;
115  size_t m_len;
116  size_t m_strength;
117  uint8_t m_lg_w;
118  };
119 
120 }
121 
122 #endif
static ots_algorithm_t xmss_wots_id_from_string(const std::string &param_set)
const std::string & hash_function_name() const
secure_vector< uint8_t > base_w(const secure_vector< uint8_t > &msg, size_t out_size) const
int(* final)(unsigned char *, CTX *)
bool operator==(const XMSS_WOTS_Parameters &p) const
Definition: alg_id.cpp:13
const std::string & name() const
void append_checksum(secure_vector< uint8_t > &data)
XMSS_WOTS_Parameters(const std::string &algo_name)
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65
ots_algorithm_t oid() const