Botan 2.13.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

xmss_wots_publickey.cpp
Go to the documentation of this file.
1 /*
2 * XMSS WOTS Public Key
3 * A Winternitz One Time Signature public key for use with Extended Hash-Based
4 * Signatures.
5 *
6 * (C) 2016,2017,2018 Matthias Gierlings
7 *
8 * Botan is released under the Simplified BSD License (see license.txt)
9 **/
10
11 #include <botan/xmss_wots_publickey.h>
12
13 namespace Botan {
14
15 void
16 XMSS_WOTS_PublicKey::chain(secure_vector<uint8_t>& result,
17 size_t start_idx,
18 size_t steps,
19 XMSS_Address& adrs,
20 const secure_vector<uint8_t>& seed,
21 XMSS_Hash& hash)
22 {
23 secure_vector<uint8_t> prf_output(hash.output_length());
24
25 for(size_t i = start_idx;
26 i < (start_idx + steps) && i < m_wots_params.wots_parameter();
27 i++)
28 {
29 adrs.set_hash_address(static_cast<uint32_t>(i));
30
31 //Calculate tmp XOR bitmask
32 adrs.set_key_mask_mode(XMSS_Address::Key_Mask::Mask_Mode);
33 hash.prf(prf_output, seed, adrs.bytes());
34 xor_buf(result, prf_output, result.size());
35
36 // Calculate key
37 adrs.set_key_mask_mode(XMSS_Address::Key_Mask::Key_Mode);
38
39 //Calculate f(key, tmp XOR bitmask)
40 hash.prf(prf_output, seed, adrs.bytes());
41 hash.f(result, prf_output, result);
42 }
43 }
44
45 wots_keysig_t
46 XMSS_WOTS_PublicKey::pub_key_from_signature(const secure_vector<uint8_t>& msg,
47 const wots_keysig_t& sig,
48 XMSS_Address& adrs,
49 const secure_vector<uint8_t>& seed)
50 {
51 secure_vector<uint8_t> msg_digest
52 {
53 m_wots_params.base_w(msg, m_wots_params.len_1())
54 };
55
56 m_wots_params.append_checksum(msg_digest);
57 wots_keysig_t result(sig);
58
59 for(size_t i = 0; i < m_wots_params.len(); i++)
60 {
61 adrs.set_chain_address(static_cast<uint32_t>(i));
62 chain(result[i],
63 msg_digest[i],
64 m_wots_params.wots_parameter() - 1 - msg_digest[i],
65 adrs,
66 seed);
67 }
68 return result;
69 }
70
71 }
Botan::XMSS_Hash
Definition: xmss_hash.h:21
Botan::XMSS_Address
Definition: xmss_address.h:21
Botan::XMSS_Hash::f
void f(secure_vector< uint8_t > &result, const secure_vector< uint8_t > &key, const secure_vector< uint8_t > &data)
Definition: xmss_hash.h:71
Botan::XMSS_WOTS_PublicKey::chain
void chain(secure_vector< uint8_t > &x, size_t start_idx, size_t steps, XMSS_Address &adrs, const secure_vector< uint8_t > &public_seed, XMSS_Hash &hash)
Definition: xmss_wots_publickey.cpp:16
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::xor_buf
void xor_buf(uint8_t out[], const uint8_t in[], size_t length)
Definition: mem_ops.h:232
Botan::XMSS_WOTS_Parameters::len
size_t len() const
Definition: xmss_wots_parameters.h:89
Botan::XMSS_Hash::prf
void prf(secure_vector< uint8_t > &result, const secure_vector< uint8_t > &key, const secure_vector< uint8_t > &data)
Definition: xmss_hash.h:35
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_Address::set_chain_address
void set_chain_address(uint32_t value)
Definition: xmss_address.h:220
Botan::wots_keysig_t
std::vector< secure_vector< uint8_t > > wots_keysig_t
Definition: xmss_common_ops.h:21
Botan::XMSS_Hash::output_length
size_t output_length() const
Definition: xmss_hash.h:137
Botan::XMSS_WOTS_Parameters::append_checksum
void append_checksum(secure_vector< uint8_t > &data)
Definition: xmss_wots_parameters.cpp:123
Botan::XMSS_Address::set_key_mask_mode
void set_key_mask_mode(Key_Mask value)
Definition: xmss_address.h:134
Botan::XMSS_Address::bytes
const secure_vector< uint8_t > & bytes() const
Definition: xmss_address.h:322
Botan::XMSS_WOTS_Parameters::len_1
size_t len_1() const
Definition: xmss_wots_parameters.h:91
Botan::XMSS_Address::Key_Mask::Mask_Mode
Botan::XMSS_Address::set_hash_address
void set_hash_address(uint32_t value)
Definition: xmss_address.h:282
hash
MechanismType hash
Definition: p11_mechanism.cpp:64
Botan::XMSS_WOTS_PublicKey::m_wots_params
XMSS_WOTS_Parameters m_wots_params
Definition: xmss_wots_publickey.h:325
Botan::XMSS_Address::Key_Mask::Key_Mode