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