Botan 2.19.5 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#include <botan/exceptn.h>
16
17 namespace Botan {
18
19 XMSS_Parameters::xmss_algorithm_t XMSS_Parameters::xmss_id_from_string(const std::string& param_set)
20 {
21 if(param_set == "XMSS-SHA2_10_256")
22 { return XMSS_SHA2_10_256; }
23 if(param_set == "XMSS-SHA2_16_256")
24 { return XMSS_SHA2_16_256; }
25 if(param_set == "XMSS-SHA2_20_256")
26 { return XMSS_SHA2_20_256; }
27 if(param_set == "XMSS-SHA2_10_512")
28 { return XMSS_SHA2_10_512; }
29 if(param_set == "XMSS-SHA2_16_512")
30 { return XMSS_SHA2_16_512; }
31 if(param_set == "XMSS-SHA2_20_512")
32 { return XMSS_SHA2_20_512; }
33 if(param_set == "XMSS-SHAKE_10_256")
34 { return XMSS_SHAKE_10_256; }
35 if(param_set == "XMSS-SHAKE_16_256")
36 { return XMSS_SHAKE_16_256; }
37 if(param_set == "XMSS-SHAKE_20_256")
38 { return XMSS_SHAKE_20_256; }
39 if(param_set == "XMSS-SHAKE_10_512")
40 { return XMSS_SHAKE_10_512; }
41 if(param_set == "XMSS-SHAKE_16_512")
42 { return XMSS_SHAKE_16_512; }
43 if(param_set == "XMSS-SHAKE_20_512")
44 { return XMSS_SHAKE_20_512; }
45 throw Lookup_Error("Unknown XMSS algorithm param '" + param_set + "'");
46 }
47
48 XMSS_Parameters::XMSS_Parameters(const std::string& param_set)
49 : XMSS_Parameters(XMSS_Parameters::xmss_id_from_string(param_set))
50 {
51 }
52
53 XMSS_Parameters::XMSS_Parameters(xmss_algorithm_t oid)
54 : m_oid(oid)
55 {
56 switch(oid)
57 {
58 case XMSS_SHA2_10_256:
59 m_element_size = 32;
60 m_w = 16;
61 m_len = 67;
62 m_tree_height = 10;
63 m_name = "XMSS-SHA2_10_256";
64 m_hash_name = "SHA-256";
65 m_strength = 256;
66 m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHA2_256;
67 break;
68 case XMSS_SHA2_16_256:
69 m_element_size = 32;
70 m_w = 16;
71 m_len = 67;
72 m_tree_height = 16;
73 m_name = "XMSS-SHA2_16_256";
74 m_hash_name = "SHA-256";
75 m_strength = 256;
76 m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHA2_256;
77 break;
78 case XMSS_SHA2_20_256:
79 m_element_size = 32;
80 m_w = 16;
81 m_len = 67;
82 m_tree_height = 20;
83 m_name = "XMSS-SHA2_20_256";
84 m_hash_name = "SHA-256";
85 m_strength = 256;
86 m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHA2_256;
87 break;
88 case XMSS_SHA2_10_512:
89 m_element_size = 64;
90 m_w = 16;
91 m_len = 131;
92 m_tree_height = 10;
93 m_name = "XMSS-SHA2_10_512";
94 m_hash_name = "SHA-512";
95 m_strength = 512;
96 m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHA2_512;
97 break;
98 case XMSS_SHA2_16_512:
99 m_element_size = 64;
100 m_w = 16;
101 m_len = 131;
102 m_tree_height = 16;
103 m_name = "XMSS-SHA2_16_512";
104 m_hash_name = "SHA-512";
105 m_strength = 512;
106 m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHA2_512;
107 break;
108 case XMSS_SHA2_20_512:
109 m_element_size = 64;
110 m_w = 16;
111 m_len = 131;
112 m_tree_height = 20;
113 m_name = "XMSS-SHA2_20_512";
114 m_hash_name = "SHA-512";
115 m_strength = 512;
116 m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHA2_512;
117 break;
118 case XMSS_SHAKE_10_256:
119 m_element_size = 32;
120 m_w = 16;
121 m_len = 67;
122 m_tree_height = 10;
123 m_name = "XMSS-SHAKE_10_256";
124 m_hash_name = "SHAKE-128(256)";
125 m_strength = 256;
126 m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHAKE_256;
127 break;
128 case XMSS_SHAKE_16_256:
129 m_element_size = 32;
130 m_w = 16;
131 m_len = 67;
132 m_tree_height = 16;
133 m_name = "XMSS-SHAKE_16_256";
134 m_hash_name = "SHAKE-128(256)";
135 m_strength = 256;
136 m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHAKE_256;
137 break;
138 case XMSS_SHAKE_20_256:
139 m_element_size = 32;
140 m_w = 16;
141 m_len = 67;
142 m_tree_height = 20;
143 m_name = "XMSS-SHAKE_20_256";
144 m_hash_name = "SHAKE-128(256)";
145 m_strength = 256;
146 m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHAKE_256;
147 break;
148 case XMSS_SHAKE_10_512:
149 m_element_size = 64;
150 m_w = 16;
151 m_len = 131;
152 m_tree_height = 10;
153 m_name = "XMSS-SHAKE_10_512";
154 m_hash_name = "SHAKE-256(512)";
155 m_strength = 512;
156 m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHAKE_512;
157 break;
158 case XMSS_SHAKE_16_512:
159 m_element_size = 64;
160 m_w = 16;
161 m_len = 131;
162 m_tree_height = 16;
163 m_name = "XMSS-SHAKE_16_512";
164 m_hash_name = "SHAKE-256(512)";
165 m_strength = 512;
166 m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHAKE_512;
167 break;
168 case XMSS_SHAKE_20_512:
169 m_element_size = 64;
170 m_w = 16;
171 m_len = 131;
172 m_tree_height = 20;
173 m_name = "XMSS-SHAKE_20_512";
174 m_hash_name = "SHAKE-256(512)";
175 m_strength = 512;
176 m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHAKE_512;
177 break;
178 default:
179 throw Not_Implemented("Algorithm id does not match any known XMSS algorithm id:" + std::to_string(oid));
180 break;
181 }
182 }
183
184}
Botan::Lookup_Error
Definition: exceptn.h:248
Botan::Not_Implemented
Definition: exceptn.h:356
Botan::XMSS_Parameters
Definition: xmss_parameters.h:24
Botan::XMSS_Parameters::oid
xmss_algorithm_t oid() const
Definition: xmss_parameters.h:84
Botan::XMSS_Parameters::XMSS_Parameters
XMSS_Parameters(const std::string &algo_name)
Definition: xmss_parameters.cpp:48
Botan::XMSS_Parameters::xmss_id_from_string
static xmss_algorithm_t xmss_id_from_string(const std::string &algo_name)
Definition: xmss_parameters.cpp:19
Botan::XMSS_Parameters::xmss_algorithm_t
xmss_algorithm_t
Definition: xmss_parameters.h:27
Botan::XMSS_Parameters::XMSS_SHA2_10_512
@ XMSS_SHA2_10_512
Definition: xmss_parameters.h:31
Botan::XMSS_Parameters::XMSS_SHA2_20_512
@ XMSS_SHA2_20_512
Definition: xmss_parameters.h:33
Botan::XMSS_Parameters::XMSS_SHAKE_10_512
@ XMSS_SHAKE_10_512
Definition: xmss_parameters.h:37
Botan::XMSS_Parameters::XMSS_SHA2_16_512
@ XMSS_SHA2_16_512
Definition: xmss_parameters.h:32
Botan::XMSS_Parameters::XMSS_SHA2_20_256
@ XMSS_SHA2_20_256
Definition: xmss_parameters.h:30
Botan::XMSS_Parameters::XMSS_SHAKE_10_256
@ XMSS_SHAKE_10_256
Definition: xmss_parameters.h:34
Botan::XMSS_Parameters::XMSS_SHAKE_16_256
@ XMSS_SHAKE_16_256
Definition: xmss_parameters.h:35
Botan::XMSS_Parameters::XMSS_SHAKE_20_256
@ XMSS_SHAKE_20_256
Definition: xmss_parameters.h:36
Botan::XMSS_Parameters::XMSS_SHAKE_16_512
@ XMSS_SHAKE_16_512
Definition: xmss_parameters.h:38
Botan::XMSS_Parameters::XMSS_SHAKE_20_512
@ XMSS_SHAKE_20_512
Definition: xmss_parameters.h:39
Botan::XMSS_Parameters::XMSS_SHA2_10_256
@ XMSS_SHA2_10_256
Definition: xmss_parameters.h:28
Botan::XMSS_Parameters::XMSS_SHA2_16_256
@ XMSS_SHA2_16_256
Definition: xmss_parameters.h:29
Botan::ASN1::to_string
std::string to_string(const BER_Object &obj)
Definition: asn1_obj.cpp:213
Botan
Definition: alg_id.cpp:13