Botan 3.14.1
Crypto and TLS for C&
Botan::XMSS_WOTS_PrivateKey Class Reference

#include <xmss_wots.h>

Inheritance diagram for Botan::XMSS_WOTS_PrivateKey:
Botan::XMSS_WOTS_Base

Public Member Functions

const wots_keysig_t & key_data () const
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_PrivateKey (XMSS_WOTS_Parameters params, std::span< const uint8_t > private_seed, XMSS_Address adrs, XMSS_Hash &hash)
 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)

Protected Attributes

wots_keysig_t m_key_data
XMSS_WOTS_Parameters m_params

Detailed Description

A Winternitz One Time Signature private key for use with Extended Hash-Based Signatures.

Definition at line 69 of file xmss_wots.h.

Constructor & Destructor Documentation

◆ XMSS_WOTS_PrivateKey() [1/2]

Botan::XMSS_WOTS_PrivateKey::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 )

Algorithm 3: "Generating a WOTS+ Private Key". Generates a private key.

Note that this is implemented according to the recommendations in NIST SP.800-208 Section 6.2 to avoid a multi-target attack vulnerability. This does not influence the sign/verify interoperability with implementations that do not implement this recommendation.

This overload is used in multithreaded scenarios, where it is required to provide separate instances of XMSS_Hash to each thread.

Parameters
paramsThe WOTS parameters to use
public_seedThe public seed for the private key generation
private_seedThe private seed for the private key generation
adrsThe address of the key to retrieve.
HashesInstance of XMSS_Hash, that may only be used by the thread executing at.

Definition at line 244 of file xmss_wots.cpp.

248 :
249 XMSS_WOTS_Base(params) {
250 const size_t len = m_params.len();
251 const size_t n = hash.output_length();
252
253 m_key_data.resize(len);
254
255 std::vector<XMSS_Address> addrs(len, adrs);
256 const size_t data_len = public_seed.size() + adrs.size();
257 std::vector<uint8_t> data_arena(len * data_len);
258
259 std::vector<std::span<uint8_t>> outputs(len);
260 std::vector<std::span<const uint8_t>> data(len);
261
262 for(size_t i = 0; i < len; ++i) {
263 addrs[i].set_chain_address(static_cast<uint32_t>(i));
264
265 const auto slot = std::span(data_arena).subspan(i * data_len, data_len);
266 copy_mem(slot.first(public_seed.size()), public_seed);
267 copy_mem(slot.subspan(public_seed.size()), addrs[i].bytes());
268
269 m_key_data[i].resize(n);
270 outputs[i] = std::span(m_key_data[i]);
271 data[i] = slot;
272 }
273
274 hash.prf_keygen_batch(outputs, private_seed, data);
275}
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
constexpr void copy_mem(T *out, const T *in, size_t n)
Definition mem_ops.h:144

References Botan::copy_mem(), Botan::XMSS_WOTS_Base::m_key_data, Botan::XMSS_WOTS_Base::m_params, Botan::XMSS_Hash::output_length(), Botan::XMSS_Hash::prf_keygen_batch(), Botan::XMSS_Address::size(), and Botan::XMSS_WOTS_Base::XMSS_WOTS_Base().

◆ XMSS_WOTS_PrivateKey() [2/2]

Botan::XMSS_WOTS_PrivateKey::XMSS_WOTS_PrivateKey ( XMSS_WOTS_Parameters params,
std::span< const uint8_t > private_seed,
XMSS_Address adrs,
XMSS_Hash & hash )

Constructor for the old derivation logic. Creates a WOTS+ private key using the old key derivation logic, i.e. the logic WITHOUT the recommendations in NIST SP.800-208. It is used to support XMSS_PrivateKeys created before the derivation logic was updated.

Parameters
paramsThe WOTS parameters to use
private_seedThe private seed for the private key generation
adrsThe address of the key to retrieve.
HashesInstance of XMSS_Hash, that may only be used by the thread executing it.

Definition at line 278 of file xmss_wots.cpp.

281 :
282 XMSS_WOTS_Base(params) {
283 m_key_data.resize(m_params.len());
284
286 hash.prf(r, private_seed, adrs.bytes());
287
288 for(size_t i = 0; i < m_params.len(); ++i) {
290 hash.prf(m_key_data[i], r, m_key_data[i]);
291 }
292}
void xmss_concat(secure_vector< uint8_t > &target, const T &src)
Definition xmss_tools.h:28
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:128

References Botan::XMSS_Address::bytes(), Botan::XMSS_WOTS_Base::m_key_data, Botan::XMSS_WOTS_Base::m_params, Botan::XMSS_Hash::prf(), and Botan::XMSS_WOTS_Base::XMSS_WOTS_Base().

Member Function Documentation

◆ key_data()

const wots_keysig_t & Botan::XMSS_WOTS_Base::key_data ( ) const
inlineinherited

◆ sign()

wots_keysig_t Botan::XMSS_WOTS_PrivateKey::sign ( const secure_vector< uint8_t > & msg,
std::span< const uint8_t > public_seed,
XMSS_Address adrs,
XMSS_Hash & hash )

Algorithm 5: "WOTS_sign" Generates a signature from a private key and a message.

This overload is used in multithreaded scenarios, where it is required to provide separate instances of XMSS_Hash to each thread.

Parameters
msgA message to sign.
public_seedThe public seed to use for the signature
adrsAn OTS hash address identifying the WOTS+ key pair used for signing.
HashesInstance of XMSS_Hash, that may only be used by the thread executing sign.
Returns
signature for msg.

Definition at line 231 of file xmss_wots.cpp.

234 {
235 const secure_vector<uint8_t> msg_digest = base_w_with_checksum(m_params, msg);
236 auto sig = this->key_data();
237
238 const std::vector<uint8_t> from(m_params.len(), 0);
239 chains(m_params, sig, from, msg_digest, adrs, public_seed, hash);
240
241 return sig;
242}
const wots_keysig_t & key_data() const
Definition xmss_wots.h:32

References Botan::XMSS_WOTS_Base::key_data(), and Botan::XMSS_WOTS_Base::m_params.

Member Data Documentation

◆ m_key_data

◆ m_params


The documentation for this class was generated from the following files: