Botan 3.6.1
Crypto and TLS for C&
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 * Request for Comments: 8391
6 * Release: May 2018.
7 * https://datatracker.ietf.org/doc/rfc8391/
8 *
9 * (C) 2016,2017,2018 Matthias Gierlings
10 *
11 * Botan is released under the Simplified BSD License (see license.txt)
12 **/
13
14#include <botan/xmss_parameters.h>
15
16#include <botan/exceptn.h>
17#include <botan/internal/fmt.h>
18
19namespace Botan {
20
22 if(param_set == "XMSS-SHA2_10_256") {
23 return XMSS_SHA2_10_256;
24 }
25 if(param_set == "XMSS-SHA2_16_256") {
26 return XMSS_SHA2_16_256;
27 }
28 if(param_set == "XMSS-SHA2_20_256") {
29 return XMSS_SHA2_20_256;
30 }
31 if(param_set == "XMSS-SHA2_10_512") {
32 return XMSS_SHA2_10_512;
33 }
34 if(param_set == "XMSS-SHA2_16_512") {
35 return XMSS_SHA2_16_512;
36 }
37 if(param_set == "XMSS-SHA2_20_512") {
38 return XMSS_SHA2_20_512;
39 }
40 if(param_set == "XMSS-SHAKE_10_256") {
41 return XMSS_SHAKE_10_256;
42 }
43 if(param_set == "XMSS-SHAKE_16_256") {
44 return XMSS_SHAKE_16_256;
45 }
46 if(param_set == "XMSS-SHAKE_20_256") {
47 return XMSS_SHAKE_20_256;
48 }
49 if(param_set == "XMSS-SHAKE_10_512") {
50 return XMSS_SHAKE_10_512;
51 }
52 if(param_set == "XMSS-SHAKE_16_512") {
53 return XMSS_SHAKE_16_512;
54 }
55 if(param_set == "XMSS-SHAKE_20_512") {
56 return XMSS_SHAKE_20_512;
57 }
58 if(param_set == "XMSS-SHA2_10_192") {
59 return XMSS_SHA2_10_192;
60 }
61 if(param_set == "XMSS-SHA2_16_192") {
62 return XMSS_SHA2_16_192;
63 }
64 if(param_set == "XMSS-SHA2_20_192") {
65 return XMSS_SHA2_20_192;
66 }
67 if(param_set == "XMSS-SHAKE256_10_256") {
69 }
70 if(param_set == "XMSS-SHAKE256_16_256") {
72 }
73 if(param_set == "XMSS-SHAKE256_20_256") {
75 }
76 if(param_set == "XMSS-SHAKE256_10_192") {
78 }
79 if(param_set == "XMSS-SHAKE256_16_192") {
81 }
82 if(param_set == "XMSS-SHAKE256_20_192") {
84 }
85
86 throw Lookup_Error(fmt("Unknown XMSS algorithm param '{}'", param_set));
87}
88
89XMSS_Parameters::XMSS_Parameters(std::string_view param_set) :
90 XMSS_Parameters(XMSS_Parameters::xmss_id_from_string(param_set)) {}
91
93 switch(oid) {
95 m_element_size = 32;
96 m_hash_id_size = 32;
97 m_w = 16;
98 m_len = 67;
99 m_tree_height = 10;
100 m_name = "XMSS-SHA2_10_256";
101 m_hash_name = "SHA-256";
102 m_strength = 256;
104 break;
105 case XMSS_SHA2_16_256:
106 m_element_size = 32;
107 m_hash_id_size = 32;
108 m_w = 16;
109 m_len = 67;
110 m_tree_height = 16;
111 m_name = "XMSS-SHA2_16_256";
112 m_hash_name = "SHA-256";
113 m_strength = 256;
115 break;
116 case XMSS_SHA2_20_256:
117 m_element_size = 32;
118 m_hash_id_size = 32;
119 m_w = 16;
120 m_len = 67;
121 m_tree_height = 20;
122 m_name = "XMSS-SHA2_20_256";
123 m_hash_name = "SHA-256";
124 m_strength = 256;
126 break;
127 case XMSS_SHA2_10_512:
128 m_element_size = 64;
129 m_hash_id_size = 64;
130 m_w = 16;
131 m_len = 131;
132 m_tree_height = 10;
133 m_name = "XMSS-SHA2_10_512";
134 m_hash_name = "SHA-512";
135 m_strength = 512;
137 break;
138 case XMSS_SHA2_16_512:
139 m_element_size = 64;
140 m_hash_id_size = 64;
141 m_w = 16;
142 m_len = 131;
143 m_tree_height = 16;
144 m_name = "XMSS-SHA2_16_512";
145 m_hash_name = "SHA-512";
146 m_strength = 512;
148 break;
149 case XMSS_SHA2_20_512:
150 m_element_size = 64;
151 m_hash_id_size = 64;
152 m_w = 16;
153 m_len = 131;
154 m_tree_height = 20;
155 m_name = "XMSS-SHA2_20_512";
156 m_hash_name = "SHA-512";
157 m_strength = 512;
159 break;
161 m_element_size = 32;
162 m_hash_id_size = 32;
163 m_w = 16;
164 m_len = 67;
165 m_tree_height = 10;
166 m_name = "XMSS-SHAKE_10_256";
167 m_hash_name = "SHAKE-128(256)";
168 m_strength = 256;
170 break;
172 m_element_size = 32;
173 m_hash_id_size = 32;
174 m_w = 16;
175 m_len = 67;
176 m_tree_height = 16;
177 m_name = "XMSS-SHAKE_16_256";
178 m_hash_name = "SHAKE-128(256)";
179 m_strength = 256;
181 break;
183 m_element_size = 32;
184 m_hash_id_size = 32;
185 m_w = 16;
186 m_len = 67;
187 m_tree_height = 20;
188 m_name = "XMSS-SHAKE_20_256";
189 m_hash_name = "SHAKE-128(256)";
190 m_strength = 256;
192 break;
194 m_element_size = 64;
195 m_hash_id_size = 64;
196 m_w = 16;
197 m_len = 131;
198 m_tree_height = 10;
199 m_name = "XMSS-SHAKE_10_512";
200 m_hash_name = "SHAKE-256(512)";
201 m_strength = 512;
203 break;
205 m_element_size = 64;
206 m_hash_id_size = 64;
207 m_w = 16;
208 m_len = 131;
209 m_tree_height = 16;
210 m_name = "XMSS-SHAKE_16_512";
211 m_hash_name = "SHAKE-256(512)";
212 m_strength = 512;
214 break;
216 m_element_size = 64;
217 m_hash_id_size = 64;
218 m_w = 16;
219 m_len = 131;
220 m_tree_height = 20;
221 m_name = "XMSS-SHAKE_20_512";
222 m_hash_name = "SHAKE-256(512)";
223 m_strength = 512;
225 break;
226 case XMSS_SHA2_10_192:
227 m_element_size = 24;
228 m_hash_id_size = 4;
229 m_w = 16;
230 m_len = 51;
231 m_tree_height = 10;
232 m_name = "XMSS-SHA2_10_192";
233 m_hash_name = "Truncated(SHA-256,192)";
234 m_strength = 192;
236 break;
237 case XMSS_SHA2_16_192:
238 m_element_size = 24;
239 m_hash_id_size = 4;
240 m_w = 16;
241 m_len = 51;
242 m_tree_height = 16;
243 m_name = "XMSS-SHA2_16_192";
244 m_hash_name = "Truncated(SHA-256,192)";
245 m_strength = 192;
247 break;
248 case XMSS_SHA2_20_192:
249 m_element_size = 24;
250 m_hash_id_size = 4;
251 m_w = 16;
252 m_len = 51;
253 m_tree_height = 20;
254 m_name = "XMSS-SHA2_20_192";
255 m_hash_name = "Truncated(SHA-256,192)";
256 m_strength = 192;
258 break;
260 m_element_size = 32;
261 m_hash_id_size = 32;
262 m_w = 16;
263 m_len = 67;
264 m_tree_height = 10;
265 m_name = "XMSS-SHAKE256_10_256";
266 m_hash_name = "SHAKE-256(256)";
267 m_strength = 256;
269 break;
271 m_element_size = 32;
272 m_hash_id_size = 32;
273 m_w = 16;
274 m_len = 67;
275 m_tree_height = 16;
276 m_name = "XMSS-SHAKE256_16_256";
277 m_hash_name = "SHAKE-256(256)";
278 m_strength = 256;
280 break;
282 m_element_size = 32;
283 m_hash_id_size = 32;
284 m_w = 16;
285 m_len = 67;
286 m_tree_height = 20;
287 m_name = "XMSS-SHAKE256_20_256";
288 m_hash_name = "SHAKE-256(256)";
289 m_strength = 256;
291 break;
293 m_element_size = 24;
294 m_hash_id_size = 4;
295 m_w = 16;
296 m_len = 51;
297 m_tree_height = 10;
298 m_name = "XMSS-SHAKE256_10_192";
299 m_hash_name = "SHAKE-256(192)";
300 m_strength = 192;
302 break;
304 m_element_size = 24;
305 m_hash_id_size = 4;
306 m_w = 16;
307 m_len = 51;
308 m_tree_height = 16;
309 m_name = "XMSS-SHAKE256_16_192";
310 m_hash_name = "SHAKE-256(192)";
311 m_strength = 192;
313 break;
315 m_element_size = 24;
316 m_hash_id_size = 4;
317 m_w = 16;
318 m_len = 51;
319 m_tree_height = 20;
320 m_name = "XMSS-SHAKE256_20_192";
321 m_hash_name = "SHAKE-256(192)";
322 m_strength = 192;
324 break;
325
326 default:
327 throw Not_Implemented("Algorithm id does not match any known XMSS algorithm id:" + std::to_string(oid));
328 }
329}
330
331} // namespace Botan
static xmss_algorithm_t xmss_id_from_string(std::string_view algo_name)
XMSS_Parameters(std::string_view algo_name)
xmss_algorithm_t oid() const
std::string fmt(std::string_view format, const T &... args)
Definition fmt.h:53