Botan 3.14.1
Crypto and TLS for C&
xmss_wots.h
Go to the documentation of this file.
1/*
2 * XMSS WOTS
3 * (C) 2016,2018 Matthias Gierlings
4 * 2023 René Meusel - Rohde & Schwarz Cybersecurity
5 *
6 * Botan is released under the Simplified BSD License (see license.txt)
7 **/
8
9#ifndef BOTAN_XMSS_WOTS_H_
10#define BOTAN_XMSS_WOTS_H_
11
12#include <botan/secmem.h>
13#include <botan/xmss_parameters.h>
14#include <botan/internal/xmss_address.h>
15#include <span>
16#include <vector>
17
18namespace Botan {
19
20class XMSS_Hash;
22
23typedef std::vector<secure_vector<uint8_t>> wots_keysig_t;
24
26 public:
27 explicit XMSS_WOTS_Base(XMSS_WOTS_Parameters params) : m_params(params) {}
28
31
32 const wots_keysig_t& key_data() const { return m_key_data; }
33
34 protected:
35 XMSS_WOTS_Parameters m_params; // NOLINT(*non-private-member-variable*)
36 wots_keysig_t m_key_data; // NOLINT(*non-private-member-variable*)
37};
38
39/**
40 * A Winternitz One Time Signature public key for use with Extended Hash-Based
41 * Signatures.
42 **/
44 public:
45 /**
46 * Creates a XMSS_WOTS_PublicKey from a message and signature using
47 * Algorithm 6 WOTS_pkFromSig defined in the XMSS standard. This
48 * overload is used to verify a message using a public key.
49 *
50 * @param params The WOTS parameters to use
51 * @param public_seed The public seed to derive the key with
52 * @param signature A WOTS signature for msg.
53 * @param msg A message.
54 * @param adrs The address of the key to retrieve.
55 * @param hash Instance of XMSS_Hash, that may only be used by the
56 * thread executing at.
57 */
59 std::span<const uint8_t> public_seed,
60 wots_keysig_t signature,
61 const secure_vector<uint8_t>& msg,
62 XMSS_Address adrs,
63 XMSS_Hash& hash);
64};
65
66/** A Winternitz One Time Signature private key for use with Extended Hash-Based
67 * Signatures.
68 **/
70 public:
71 /**
72 * Algorithm 3: "Generating a WOTS+ Private Key".
73 * Generates a private key.
74 *
75 * Note that this is implemented according to the recommendations
76 * in NIST SP.800-208 Section 6.2 to avoid a multi-target attack
77 * vulnerability. This _does not_ influence the sign/verify
78 * interoperability with implementations that do not implement this
79 * recommendation.
80 *
81 * This overload is used in multithreaded scenarios, where it is
82 * required to provide separate instances of XMSS_Hash to each thread.
83 *
84 * @param params The WOTS parameters to use
85 * @param public_seed The public seed for the private key generation
86 * @param private_seed The private seed for the private key generation
87 * @param adrs The address of the key to retrieve.
88 * @param hash Instance of XMSS_Hash, that may only be used by the
89 * thread executing at.
90 **/
92 std::span<const uint8_t> public_seed,
93 std::span<const uint8_t> private_seed,
94 XMSS_Address adrs,
95 XMSS_Hash& hash);
96
97 /**
98 * Constructor for the old derivation logic.
99 * Creates a WOTS+ private key using the old key derivation logic, i.e.
100 * the logic WITHOUT the recommendations in NIST SP.800-208. It is used
101 * to support XMSS_PrivateKeys created before the derivation logic was
102 * updated.
103 *
104 * @param params The WOTS parameters to use
105 * @param private_seed The private seed for the private key generation
106 * @param adrs The address of the key to retrieve.
107 * @param hash Instance of XMSS_Hash, that may only be used by the
108 * thread executing it.
109 **/
111 std::span<const uint8_t> private_seed,
112 XMSS_Address adrs,
113 XMSS_Hash& hash);
114
115 /**
116 * Algorithm 5: "WOTS_sign"
117 * Generates a signature from a private key and a message.
118 *
119 * This overload is used in multithreaded scenarios, where it is
120 * required to provide separate instances of XMSS_Hash to each
121 * thread.
122 *
123 * @param msg A message to sign.
124 * @param public_seed The public seed to use for the signature
125 * @param adrs An OTS hash address identifying the WOTS+ key pair
126 * used for signing.
127 * @param hash Instance of XMSS_Hash, that may only be used by the
128 * thread executing sign.
129 *
130 * @return signature for msg.
131 **/
133 std::span<const uint8_t> public_seed,
134 XMSS_Address adrs,
135 XMSS_Hash& hash);
136};
137
138/**
139 * Algorithm 2: Chaining Function, applied to many WOTS+ chains in lock-step.
140 *
141 * For each chain i the hash addresses [from[i], to[i]) are applied to
142 * the i'th n-byte node of nodes, batching the hash calls across all
143 * chains active in each step.
144 *
145 * @param params The WOTS parameters to use
146 * @param[in,out] nodes The chain nodes, transformed in place
147 * @param from Per chain, the first hash address to apply
148 * @param to Per chain, the hash address to stop at (exclusive)
149 * @param[in,out] addrs Per chain, its OTS hash address with the chain
150 * address set. The hash address and key/mask mode are modified.
151 * @param seed The public seed
152 * @param hash Instance of XMSS_Hash, that may only be used by the thread
153 * executing xmss_wots_chains.
154 **/
155void xmss_wots_chains(const XMSS_WOTS_Parameters& params,
156 std::span<uint8_t> nodes,
157 std::span<const uint8_t> from,
158 std::span<const uint8_t> to,
159 std::span<XMSS_Address> addrs,
160 std::span<const uint8_t> seed,
161 XMSS_Hash& hash);
162
163} // namespace Botan
164
165#endif
const wots_keysig_t & key_data() const
Definition xmss_wots.h:32
XMSS_WOTS_Base(XMSS_WOTS_Parameters params, wots_keysig_t key_data)
Definition xmss_wots.h:29
XMSS_WOTS_Base(XMSS_WOTS_Parameters params)
Definition xmss_wots.h:27
wots_keysig_t m_key_data
Definition xmss_wots.h:36
XMSS_WOTS_Parameters m_params
Definition xmss_wots.h:35
XMSS_WOTS_PrivateKey(XMSS_WOTS_Parameters params, std::span< const uint8_t > public_seed, std::span< const uint8_t > private_seed, XMSS_Address adrs, XMSS_Hash &hash)
wots_keysig_t sign(const secure_vector< uint8_t > &msg, std::span< const uint8_t > public_seed, XMSS_Address adrs, XMSS_Hash &hash)
XMSS_WOTS_PublicKey(XMSS_WOTS_Parameters params, std::span< const uint8_t > public_seed, wots_keysig_t signature, const secure_vector< uint8_t > &msg, XMSS_Address adrs, XMSS_Hash &hash)
void xmss_wots_chains(const XMSS_WOTS_Parameters &params, std::span< uint8_t > nodes, std::span< const uint8_t > from, std::span< const uint8_t > to, std::span< XMSS_Address > addrs, std::span< const uint8_t > seed, XMSS_Hash &hash)
std::vector< secure_vector< uint8_t > > wots_keysig_t
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:128