Botan 2.13.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,2018 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 <botan/xmss_tools.h>
12 #include <botan/secmem.h>
13 #include <map>
14 #include <string>
15
16 namespace Botan {
17
18 /**
19 * Descibes a signature method for XMSS Winternitz One Time Signatures,
20 * as defined in:
21 * [1] XMSS: Extended Hash-Based Signatures,
22 * Request for Comments: 8391
23 * Release: May 2018.
24 * https://datatracker.ietf.org/doc/rfc8391/
25 **/
26 class XMSS_WOTS_Parameters final
27 {
28 public:
29 enum ots_algorithm_t
30 {
31 WOTSP_SHA2_256 = 0x00000001,
32 WOTSP_SHA2_512 = 0x00000002,
33 WOTSP_SHAKE_256 = 0x00000003,
34 WOTSP_SHAKE_512 = 0x00000004
35 };
36
37 XMSS_WOTS_Parameters(const std::string& algo_name);
38 XMSS_WOTS_Parameters(ots_algorithm_t ots_spec);
39
40 static ots_algorithm_t xmss_wots_id_from_string(const std::string& param_set);
41
42 /**
43 * Algorithm 1: convert input string to base.
44 *
45 * @param msg Input string (referred to as X in [1]).
46 * @param out_size size of message in base w.
47 *
48 * @return Input string converted to the given base.
49 **/
50 secure_vector<uint8_t> base_w(const secure_vector<uint8_t>& msg, size_t out_size) const;
51
52 secure_vector<uint8_t> base_w(size_t value) const;
53
54 void append_checksum(secure_vector<uint8_t>& data);
55
56 /**
57 * @return XMSS WOTS registry name for the chosen parameter set.
58 **/
59 const std::string& name() const
60 {
61 return m_name;
62 }
63
64 /**
65 * @return Botan name for the hash function used.
66 **/
67 const std::string& hash_function_name() const
68 {
69 return m_hash_name;
70 }
71
72 /**
73 * Retrieves the uniform length of a message, and the size of
74 * each node. This correlates to XMSS parameter "n" defined
75 * in [1].
76 *
77 * @return element length in bytes.
78 **/
79 size_t element_size() const { return m_element_size; }
80
81 /**
82 * The Winternitz parameter.
83 *
84 * @return numeric base used for internal representation of
85 * data.
86 **/
87 size_t wots_parameter() const { return m_w; }
88
89 size_t len() const { return m_len; }
90
91 size_t len_1() const { return m_len_1; }
92
93 size_t len_2() const { return m_len_2; }
94
95 size_t lg_w() const { return m_lg_w; }
96
97 ots_algorithm_t oid() const { return m_oid; }
98
99 size_t estimated_strength() const { return m_strength; }
100
101 bool operator==(const XMSS_WOTS_Parameters& p) const
102 {
103 return m_oid == p.m_oid;
104 }
105
106 private:
107 static const std::map<std::string, ots_algorithm_t> m_oid_name_lut;
108 ots_algorithm_t m_oid;
109 std::string m_name;
110 std::string m_hash_name;
111 size_t m_element_size;
112 size_t m_w;
113 size_t m_len_1;
114 size_t m_len_2;
115 size_t m_len;
116 size_t m_strength;
117 uint8_t m_lg_w;
118 };
119
120 }
121
122 #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
Definition: xmss_wots_parameters.h:26
Botan::XMSS_WOTS_Parameters::name
const std::string & name() const
Definition: xmss_wots_parameters.h:59
final
int(* final)(unsigned char *, CTX *)
Definition: commoncrypto_hash.cpp:28
Botan::XMSS_WOTS_Parameters::WOTSP_SHA2_256
Definition: xmss_wots_parameters.h:31
Botan::XMSS_WOTS_Parameters::element_size
size_t element_size() const
Definition: xmss_wots_parameters.h:79
Botan::XMSS_WOTS_Parameters::lg_w
size_t lg_w() const
Definition: xmss_wots_parameters.h:95
Botan::XMSS_WOTS_Parameters::WOTSP_SHAKE_256
Definition: xmss_wots_parameters.h:33
Botan::XMSS_WOTS_Parameters::len_2
size_t len_2() const
Definition: xmss_wots_parameters.h:93
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:90
Botan::secure_vector
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:65
Botan::XMSS_WOTS_Parameters::len
size_t len() const
Definition: xmss_wots_parameters.h:89
Botan::XMSS_WOTS_Parameters::wots_parameter
size_t wots_parameter() const
Definition: xmss_wots_parameters.h:87
Botan
Definition: alg_id.cpp:13
Botan::XMSS_WOTS_Parameters::WOTSP_SHA2_512
Definition: xmss_wots_parameters.h:32
Botan::XMSS_WOTS_Parameters::estimated_strength
size_t estimated_strength() const
Definition: xmss_wots_parameters.h:99
Botan::XMSS_WOTS_Parameters::ots_algorithm_t
ots_algorithm_t
Definition: xmss_wots_parameters.h:29
Botan::XMSS_WOTS_Parameters::append_checksum
void append_checksum(secure_vector< uint8_t > &data)
Definition: xmss_wots_parameters.cpp:123
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:101
Botan::XMSS_WOTS_Parameters::len_1
size_t len_1() const
Definition: xmss_wots_parameters.h:91
Botan::XMSS_WOTS_Parameters::oid
ots_algorithm_t oid() const
Definition: xmss_wots_parameters.h:97
Botan::XMSS_WOTS_Parameters::WOTSP_SHAKE_512
Definition: xmss_wots_parameters.h:34
Botan::XMSS_WOTS_Parameters::hash_function_name
const std::string & hash_function_name() const
Definition: xmss_wots_parameters.h:67