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