Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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 Matthias Gierlings
11 *
12 * Botan is released under the Simplified BSD License (see license.txt)
13 **/
14
15 #include <botan/xmss_parameters.h>
16
17 namespace Botan {
18
19 //static
20 XMSS_Parameters::xmss_algorithm_t XMSS_Parameters::xmss_id_from_string(const std::string& param_set)
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)
50 : XMSS_Parameters(XMSS_Parameters::xmss_id_from_string(param_set))
51 {
52 }
53
54
55 XMSS_Parameters::XMSS_Parameters(xmss_algorithm_t oid)
56 : m_oid(oid)
57 {
58 switch(oid)
59 {
60 case XMSS_SHA2_256_W16_H10:
61 m_element_size = 32;
62 m_w = 16;
63 m_len = 67;
64 m_tree_height = 10;
65 m_name = "XMSS_SHA2-256_W16_H10";
66 m_hash_name = "SHA-256";
67 m_strength = 256;
68 m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHA2_256_W16;
69 break;
70 case XMSS_SHA2_256_W16_H16:
71 m_element_size = 32;
72 m_w = 16;
73 m_len = 67;
74 m_tree_height = 16;
75 m_name = "XMSS_SHA2-256_W16_H16";
76 m_hash_name = "SHA-256";
77 m_strength = 256;
78 m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHA2_256_W16;
79 break;
80 case XMSS_SHA2_256_W16_H20:
81 m_element_size = 32;
82 m_w = 16;
83 m_len = 67;
84 m_tree_height = 20;
85 m_name = "XMSS_SHA2-256_W16_H20";
86 m_hash_name = "SHA-256";
87 m_strength = 256;
88 m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHA2_256_W16;
89 break;
90 case XMSS_SHA2_512_W16_H10:
91 m_element_size = 64;
92 m_w = 16;
93 m_len = 131;
94 m_tree_height = 10;
95 m_name = "XMSS_SHA2-512_W16_H10";
96 m_hash_name = "SHA-512";
97 m_strength = 512;
98 m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHA2_512_W16;
99 break;
100 case XMSS_SHA2_512_W16_H16:
101 m_element_size = 64;
102 m_w = 16;
103 m_len = 131;
104 m_tree_height = 16;
105 m_name = "XMSS_SHA2-512_W16_H16";
106 m_hash_name = "SHA-512";
107 m_strength = 512;
108 m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHA2_512_W16;
109 break;
110 case XMSS_SHA2_512_W16_H20:
111 m_element_size = 64;
112 m_w = 16;
113 m_len = 131;
114 m_tree_height = 20;
115 m_name = "XMSS_SHA2-512_W16_H20";
116 m_hash_name = "SHA-512";
117 m_strength = 512;
118 m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHA2_512_W16;
119 break;
120 case XMSS_SHAKE128_W16_H10:
121 m_element_size = 32;
122 m_w = 16;
123 m_len = 67;
124 m_tree_height = 10;
125 m_name = "XMSS_SHAKE128_W16_H10";
126 m_hash_name = "SHAKE-128(256)";
127 m_strength = 256;
128 m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHAKE128_W16;
129 break;
130 case XMSS_SHAKE128_W16_H16:
131 m_element_size = 32;
132 m_w = 16;
133 m_len = 67;
134 m_tree_height = 16;
135 m_name = "XMSS_SHAKE128_W16_H16";
136 m_hash_name = "SHAKE-128(256)";
137 m_strength = 256;
138 m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHAKE128_W16;
139 break;
140 case XMSS_SHAKE128_W16_H20:
141 m_element_size = 32;
142 m_w = 16;
143 m_len = 67;
144 m_tree_height = 20;
145 m_name = "XMSS_SHAKE128_W16_H20";
146 m_hash_name = "SHAKE-128(256)";
147 m_strength = 256;
148 m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHAKE128_W16;
149 break;
150 case XMSS_SHAKE256_W16_H10:
151 m_element_size = 64;
152 m_w = 16;
153 m_len = 131;
154 m_tree_height = 10;
155 m_name = "XMSS_SHAKE256_W16_H10";
156 m_hash_name = "SHAKE-256(512)";
157 m_strength = 512;
158 m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHAKE256_W16;
159 break;
160 case XMSS_SHAKE256_W16_H16:
161 m_element_size = 64;
162 m_w = 16;
163 m_len = 131;
164 m_tree_height = 16;
165 m_name = "XMSS_SHAKE256_W16_H16";
166 m_hash_name = "SHAKE-256(512)";
167 m_strength = 512;
168 m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHAKE256_W16;
169 break;
170 case XMSS_SHAKE256_W16_H20:
171 m_element_size = 64;
172 m_w = 16;
173 m_len = 131;
174 m_tree_height = 20;
175 m_name = "XMSS_SHAKE256_W16_H20";
176 m_hash_name = "SHAKE-256(512)";
177 m_strength = 512;
178 m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHAKE256_W16;
179 break;
180 default:
181 throw Unsupported_Argument(
182 "Algorithm id does not match any XMSS algorithm id.");
183 break;
184 }
185 }
186
187 }
Botan::Unsupported_Argument
Definition: exceptn.h:53
Botan::XMSS_Parameters::XMSS_SHA2_256_W16_H20
Definition: xmss_parameters.h:35
Botan::XMSS_Parameters::XMSS_SHA2_512_W16_H20
Definition: xmss_parameters.h:38
Botan::XMSS_Parameters::XMSS_SHAKE256_W16_H16
Definition: xmss_parameters.h:43
Botan::XMSS_Parameters::XMSS_SHA2_512_W16_H16
Definition: xmss_parameters.h:37
Botan::XMSS_Parameters::XMSS_SHAKE128_W16_H10
Definition: xmss_parameters.h:39
m_oid
OID m_oid
Definition: x509_ext.cpp:682
Botan::XMSS_Parameters::XMSS_SHAKE256_W16_H20
Definition: xmss_parameters.h:44
Botan::XMSS_Parameters::XMSS_SHA2_256_W16_H10
Definition: xmss_parameters.h:33
Botan::XMSS_Parameters
Definition: xmss_parameters.h:28
Botan::XMSS_Parameters::XMSS_SHA2_256_W16_H16
Definition: xmss_parameters.h:34
Botan::Lookup_Error
Definition: exceptn.h:71
Botan::XMSS_Parameters::XMSS_Parameters
XMSS_Parameters(const std::string &algo_name)
Definition: xmss_parameters.cpp:49
Botan
Definition: alg_id.cpp:13
Botan::XMSS_Parameters::XMSS_SHAKE128_W16_H20
Definition: xmss_parameters.h:41
Botan::XMSS_Parameters::XMSS_SHAKE256_W16_H10
Definition: xmss_parameters.h:42
Botan::XMSS_Parameters::xmss_algorithm_t
xmss_algorithm_t
Definition: xmss_parameters.h:31
Botan::XMSS_Parameters::xmss_id_from_string
static xmss_algorithm_t xmss_id_from_string(const std::string &algo_name)
Definition: xmss_parameters.cpp:20
Botan::XMSS_Parameters::XMSS_SHA2_512_W16_H10
Definition: xmss_parameters.h:36
Botan::XMSS_Parameters::XMSS_SHAKE128_W16_H16
Definition: xmss_parameters.h:40