Botan  2.4.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 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  * draft-itrf-cfrg-xmss-hash-based-signatures-06
23  * Release: July 2016.
24  * https://datatracker.ietf.org/doc/
25  * draft-irtf-cfrg-xmss-hash-based-signatures/?include_text=1
26  **/
28  {
29  public:
31  {
32  WOTSP_SHA2_256_W16 = 0x01000001,
33  WOTSP_SHA2_512_W16 = 0x02000002,
34  WOTSP_SHAKE128_W16 = 0x03000003,
35  WOTSP_SHAKE256_W16 = 0x04000004
36  };
37 
38  XMSS_WOTS_Parameters(const std::string& algo_name);
40 
41  static ots_algorithm_t xmss_wots_id_from_string(const std::string& param_set);
42 
43  /**
44  * Algorithm 1: convert input string to base.
45  *
46  * @param msg Input string (referred to as X in [1]).
47  * @param out_size size of message in base w.
48  *
49  * @return Input string converted to the given base.
50  **/
51  secure_vector<uint8_t> base_w(const secure_vector<uint8_t>& msg, size_t out_size) const;
52 
53  secure_vector<uint8_t> base_w(size_t value) const;
54 
56 
57  /**
58  * @return XMSS WOTS registry name for the chosen parameter set.
59  **/
60  const std::string& name() const
61  {
62  return m_name;
63  }
64 
65  /**
66  * @return Botan name for the hash function used.
67  **/
68  const std::string& hash_function_name() const
69  {
70  return m_hash_name;
71  }
72 
73  /**
74  * Retrieves the uniform length of a message, and the size of
75  * each node. This correlates to XMSS parameter "n" defined
76  * in [1].
77  *
78  * @return element length in bytes.
79  **/
80  size_t element_size() const { return m_element_size; }
81 
82  /**
83  * The Winternitz parameter.
84  *
85  * @return numeric base used for internal representation of
86  * data.
87  **/
88  size_t wots_parameter() const { return m_w; }
89 
90  size_t len() const { return m_len; }
91 
92  size_t len_1() const { return m_len_1; }
93 
94  size_t len_2() const { return m_len_2; }
95 
96  size_t lg_w() const { return m_lg_w; }
97 
98  ots_algorithm_t oid() const { return m_oid; }
99 
100  size_t estimated_strength() const { return m_strength; }
101 
102  bool operator==(const XMSS_WOTS_Parameters& p) const
103  {
104  return m_oid == p.m_oid;
105  }
106 
107  private:
108  static const std::map<std::string, ots_algorithm_t> m_oid_name_lut;
109  ots_algorithm_t m_oid;
110  std::string m_name;
111  std::string m_hash_name;
112  size_t m_element_size;
113  size_t m_w;
114  size_t m_len_1;
115  size_t m_len_2;
116  size_t m_len;
117  size_t m_strength;
118  uint8_t m_lg_w;
119  };
120 
121 }
122 
123 #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
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:88
ots_algorithm_t oid() const