Botan  2.4.0
Crypto and TLS for C++11
xmss_parameters.cpp
Go to the documentation of this file.
1 /*
2  * XMSS Parameters
3  * Descibes a signature method for XMSS, as defined in:
4  * [1] XMSS: Extended Hash-Based Signatures,
5  * draft-itrf-cfrg-xmss-hash-based-signatures-06
6  * Release: July 2016.
7  * https://datatracker.ietf.org/doc/
8  * draft-irtf-cfrg-xmss-hash-based-signatures/?include_text=1
9  *
10  * (C) 2016,2017 Matthias Gierlings
11  *
12  * Botan is released under the Simplified BSD License (see license.txt)
13  **/
14 
15 #include <botan/xmss_parameters.h>
16 #include <botan/exceptn.h>
17 
18 namespace Botan {
19 
21  {
22  if(param_set == "XMSS_SHA2-256_W16_H10")
23  { return XMSS_SHA2_256_W16_H10; }
24  if(param_set == "XMSS_SHA2-256_W16_H16")
25  { return XMSS_SHA2_256_W16_H16; }
26  if(param_set == "XMSS_SHA2-256_W16_H20")
27  { return XMSS_SHA2_256_W16_H20; }
28  if(param_set == "XMSS_SHA2-512_W16_H10")
29  { return XMSS_SHA2_512_W16_H10; }
30  if(param_set == "XMSS_SHA2-512_W16_H16")
31  { return XMSS_SHA2_512_W16_H16; }
32  if(param_set == "XMSS_SHA2-512_W16_H20")
33  { return XMSS_SHA2_512_W16_H20; }
34  if(param_set == "XMSS_SHAKE128_W16_H10")
35  { return XMSS_SHAKE128_W16_H10; }
36  if(param_set == "XMSS_SHAKE128_W16_H16")
37  { return XMSS_SHAKE128_W16_H16; }
38  if(param_set == "XMSS_SHAKE128_W16_H20")
39  { return XMSS_SHAKE128_W16_H20; }
40  if(param_set == "XMSS_SHAKE256_W16_H10")
41  { return XMSS_SHAKE256_W16_H10; }
42  if(param_set == "XMSS_SHAKE256_W16_H16")
43  { return XMSS_SHAKE256_W16_H16; }
44  if(param_set == "XMSS_SHAKE256_W16_H20")
45  { return XMSS_SHAKE256_W16_H20; }
46  throw Lookup_Error("Unknown XMSS algorithm param '" + param_set + "'");
47  }
48 
49 XMSS_Parameters::XMSS_Parameters(const std::string& param_set)
51  {
52  }
53 
55  : m_oid(oid)
56  {
57  switch(oid)
58  {
60  m_element_size = 32;
61  m_w = 16;
62  m_len = 67;
63  m_tree_height = 10;
64  m_name = "XMSS_SHA2-256_W16_H10";
65  m_hash_name = "SHA-256";
66  m_strength = 256;
67  m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHA2_256_W16;
68  break;
70  m_element_size = 32;
71  m_w = 16;
72  m_len = 67;
73  m_tree_height = 16;
74  m_name = "XMSS_SHA2-256_W16_H16";
75  m_hash_name = "SHA-256";
76  m_strength = 256;
77  m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHA2_256_W16;
78  break;
80  m_element_size = 32;
81  m_w = 16;
82  m_len = 67;
83  m_tree_height = 20;
84  m_name = "XMSS_SHA2-256_W16_H20";
85  m_hash_name = "SHA-256";
86  m_strength = 256;
87  m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHA2_256_W16;
88  break;
90  m_element_size = 64;
91  m_w = 16;
92  m_len = 131;
93  m_tree_height = 10;
94  m_name = "XMSS_SHA2-512_W16_H10";
95  m_hash_name = "SHA-512";
96  m_strength = 512;
97  m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHA2_512_W16;
98  break;
100  m_element_size = 64;
101  m_w = 16;
102  m_len = 131;
103  m_tree_height = 16;
104  m_name = "XMSS_SHA2-512_W16_H16";
105  m_hash_name = "SHA-512";
106  m_strength = 512;
107  m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHA2_512_W16;
108  break;
110  m_element_size = 64;
111  m_w = 16;
112  m_len = 131;
113  m_tree_height = 20;
114  m_name = "XMSS_SHA2-512_W16_H20";
115  m_hash_name = "SHA-512";
116  m_strength = 512;
117  m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHA2_512_W16;
118  break;
120  m_element_size = 32;
121  m_w = 16;
122  m_len = 67;
123  m_tree_height = 10;
124  m_name = "XMSS_SHAKE128_W16_H10";
125  m_hash_name = "SHAKE-128(256)";
126  m_strength = 256;
127  m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHAKE128_W16;
128  break;
130  m_element_size = 32;
131  m_w = 16;
132  m_len = 67;
133  m_tree_height = 16;
134  m_name = "XMSS_SHAKE128_W16_H16";
135  m_hash_name = "SHAKE-128(256)";
136  m_strength = 256;
137  m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHAKE128_W16;
138  break;
140  m_element_size = 32;
141  m_w = 16;
142  m_len = 67;
143  m_tree_height = 20;
144  m_name = "XMSS_SHAKE128_W16_H20";
145  m_hash_name = "SHAKE-128(256)";
146  m_strength = 256;
147  m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHAKE128_W16;
148  break;
150  m_element_size = 64;
151  m_w = 16;
152  m_len = 131;
153  m_tree_height = 10;
154  m_name = "XMSS_SHAKE256_W16_H10";
155  m_hash_name = "SHAKE-256(512)";
156  m_strength = 512;
157  m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHAKE256_W16;
158  break;
160  m_element_size = 64;
161  m_w = 16;
162  m_len = 131;
163  m_tree_height = 16;
164  m_name = "XMSS_SHAKE256_W16_H16";
165  m_hash_name = "SHAKE-256(512)";
166  m_strength = 512;
167  m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHAKE256_W16;
168  break;
170  m_element_size = 64;
171  m_w = 16;
172  m_len = 131;
173  m_tree_height = 20;
174  m_name = "XMSS_SHAKE256_W16_H20";
175  m_hash_name = "SHAKE-256(512)";
176  m_strength = 512;
177  m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHAKE256_W16;
178  break;
179  default:
180  throw Unsupported_Argument(
181  "Algorithm id does not match any XMSS algorithm id.");
182  break;
183  }
184  }
185 
186 }
XMSS_Parameters(const std::string &algo_name)
Definition: alg_id.cpp:13
static xmss_algorithm_t xmss_id_from_string(const std::string &algo_name)
xmss_algorithm_t oid() const