Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

xmss_wots_parameters.h
Go to the documentation of this file.
1 /*
2 * XMSS WOTS Parameters
3 * (C) 2016 Matthias Gierlings
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 **/
7
8 #ifndef BOTAN_XMSS_WOTS_PARAMETERS_H__
9 #define BOTAN_XMSS_WOTS_PARAMETERS_H__
10
11 #include <cstddef>
12 #include <cstdint>
13 #include <iterator>
14 #include <map>
15 #include <string>
16 #include <math.h>
17 #include <botan/assert.h>
18 #include <botan/types.h>
19 #include <botan/secmem.h>
20 #include <botan/exceptn.h>
21 #include <botan/xmss_tools.h>
22
23 namespace Botan {
24
25 /**
26 * Descibes a signature method for XMSS Winternitz One Time Signatures,
27 * as defined in:
28 * [1] XMSS: Extended Hash-Based Signatures,
29 * draft-itrf-cfrg-xmss-hash-based-signatures-06
30 * Release: July 2016.
31 * https://datatracker.ietf.org/doc/
32 * draft-irtf-cfrg-xmss-hash-based-signatures/?include_text=1
33 **/
34 class XMSS_WOTS_Parameters
35 {
36 public:
37 enum ots_algorithm_t
38 {
39 WOTSP_SHA2_256_W16 = 0x01000001,
40 WOTSP_SHA2_512_W16 = 0x02000002,
41 WOTSP_SHAKE128_W16 = 0x03000003,
42 WOTSP_SHAKE256_W16 = 0x04000004
43 };
44
45 XMSS_WOTS_Parameters(const std::string& algo_name);
46 XMSS_WOTS_Parameters(ots_algorithm_t ots_spec);
47
48 static ots_algorithm_t xmss_wots_id_from_string(const std::string& param_set);
49
50 /**
51 * Algorithm 1: convert input string to base.
52 *
53 * @param msg Input string (referred to as X in [1]).
54 * @param out_size size of message in base w.
55 *
56 * @return Input string converted to the given base.
57 **/
58 secure_vector<uint8_t> base_w(const secure_vector<uint8_t>& msg, size_t out_size) const;
59
60 secure_vector<uint8_t> base_w(size_t value) const;
61
62 void append_checksum(secure_vector<uint8_t>& data);
63
64 /**
65 * @return XMSS WOTS registry name for the chosen parameter set.
66 **/
67 const std::string& name() const
68 {
69 return m_name;
70 }
71
72 /**
73 * @return Botan name for the hash function used.
74 **/
75 const std::string& hash_function_name() const
76 {
77 return m_hash_name;
78 }
79
80 /**
81 * Retrieves the uniform length of a message, and the size of
82 * each node. This correlates to XMSS parameter "n" defined
83 * in [1].
84 *
85 * @return element length in bytes.
86 **/
87 size_t element_size() const { return m_element_size; }
88
89 /**
90 * The Winternitz parameter.
91 *
92 * @return numeric base used for internal representation of
93 * data.
94 **/
95 size_t wots_parameter() const { return m_w; }
96
97 size_t len() const { return m_len; }
98
99 size_t len_1() const { return m_len_1; }
100
101 size_t len_2() const { return m_len_2; }
102
103 size_t lg_w() const { return m_lg_w; }
104
105 ots_algorithm_t oid() const { return m_oid; }
106
107 size_t estimated_strength() const { return m_strength; }
108
109 bool operator==(const XMSS_WOTS_Parameters& p) const
110 {
111 return m_oid == p.m_oid;
112 }
113
114 private:
115 static const std::map<std::string, ots_algorithm_t> m_oid_name_lut;
116 ots_algorithm_t m_oid;
117 std::string m_name;
118 std::string m_hash_name;
119 size_t m_element_size;
120 size_t m_w;
121 size_t m_len_1;
122 size_t m_len_2;
123 size_t m_len;
124 size_t m_strength;
125 uint8_t m_lg_w;
126 };
127
128 }
129
130 #endif
Botan::XMSS_WOTS_Parameters::xmss_wots_id_from_string
static ots_algorithm_t xmss_wots_id_from_string(const std::string &param_set)
Definition: xmss_wots_parameters.cpp:22
Botan::XMSS_WOTS_Parameters::WOTSP_SHAKE128_W16
Definition: xmss_wots_parameters.h:41
Botan::XMSS_WOTS_Parameters
Definition: xmss_wots_parameters.h:34
Botan::XMSS_WOTS_Parameters::name
const std::string & name() const
Definition: xmss_wots_parameters.h:67
Botan::XMSS_WOTS_Parameters::WOTSP_SHA2_256_W16
Definition: xmss_wots_parameters.h:39
Botan::XMSS_WOTS_Parameters::element_size
size_t element_size() const
Definition: xmss_wots_parameters.h:87
Botan::XMSS_WOTS_Parameters::lg_w
size_t lg_w() const
Definition: xmss_wots_parameters.h:103
Botan::XMSS_WOTS_Parameters::len_2
size_t len_2() const
Definition: xmss_wots_parameters.h:101
Botan::XMSS_WOTS_Parameters::base_w
secure_vector< uint8_t > base_w(const secure_vector< uint8_t > &msg, size_t out_size) const
Definition: xmss_wots_parameters.cpp:91
Botan::secure_vector
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:121
Botan::XMSS_WOTS_Parameters::len
size_t len() const
Definition: xmss_wots_parameters.h:97
Botan::XMSS_WOTS_Parameters::wots_parameter
size_t wots_parameter() const
Definition: xmss_wots_parameters.h:95
Botan
Definition: alg_id.cpp:13
Botan::XMSS_WOTS_Parameters::WOTSP_SHA2_512_W16
Definition: xmss_wots_parameters.h:40
Botan::XMSS_WOTS_Parameters::estimated_strength
size_t estimated_strength() const
Definition: xmss_wots_parameters.h:107
Botan::XMSS_WOTS_Parameters::ots_algorithm_t
ots_algorithm_t
Definition: xmss_wots_parameters.h:37
Botan::XMSS_WOTS_Parameters::append_checksum
void append_checksum(secure_vector< uint8_t > &data)
Definition: xmss_wots_parameters.cpp:124
Botan::XMSS_WOTS_Parameters::WOTSP_SHAKE256_W16
Definition: xmss_wots_parameters.h:42
Botan::XMSS_WOTS_Parameters::XMSS_WOTS_Parameters
XMSS_WOTS_Parameters(const std::string &algo_name)
Definition: xmss_wots_parameters.cpp:35
Botan::XMSS_WOTS_Parameters::operator==
bool operator==(const XMSS_WOTS_Parameters &p) const
Definition: xmss_wots_parameters.h:109
Botan::XMSS_WOTS_Parameters::len_1
size_t len_1() const
Definition: xmss_wots_parameters.h:99
Botan::XMSS_WOTS_Parameters::oid
ots_algorithm_t oid() const
Definition: xmss_wots_parameters.h:105
Botan::XMSS_WOTS_Parameters::hash_function_name
const std::string & hash_function_name() const
Definition: xmss_wots_parameters.h:75