Botan  2.1.0
Crypto and TLS for C++11
xmss_wots_signature_operation.cpp
Go to the documentation of this file.
1 /**
2  * XMSS WOTS Signature Operation
3  * Signature generation operation for Winternitz One Time Signatures for use
4  * in Extended Hash-Based Signatures (XMSS).
5  *
6  * This operation is not intended for stand-alone use and thus not registered
7  * in the Botan algorithm registry.
8  *
9  * (C) 2016 Matthias Gierlings
10  *
11  * Botan is released under the Simplified BSD License (see license.txt)
12  **/
13 
14 #include <botan/internal/xmss_wots_signature_operation.h>
15 
16 namespace Botan {
17 
19  const XMSS_WOTS_Addressed_PrivateKey& private_key)
20  : XMSS_WOTS_Common_Ops(private_key.private_key().wots_parameters().oid()),
21  m_priv_key(private_key),
22  m_msg_buf(0)
23  {
24  m_msg_buf.reserve(
25  m_priv_key.private_key().wots_parameters().element_size());
26  }
27 
28 void
29 XMSS_WOTS_Signature_Operation::update(const uint8_t msg[], size_t msg_len)
30  {
31  BOTAN_ASSERT(msg_len == m_priv_key.private_key().wots_parameters().
32  element_size() &&
33  m_msg_buf.size() == 0,
34  "XMSS WOTS only supports one message part of size n.");
35 
36  for(size_t i = 0; i < msg_len; i++)
37  m_msg_buf.push_back(msg[i]);
38  }
39 
42  {
43  secure_vector<uint8_t> result(0);
44  result.reserve(m_wots_params.len() * m_wots_params.element_size());
45  XMSS_WOTS_PrivateKey& priv_key = m_priv_key.private_key();
46  for(const auto& node : priv_key.sign(m_msg_buf, m_priv_key.address()))
47  {
48  std::copy(node.begin(), node.end(), std::back_inserter(result));
49  }
50 
51  return result;
52  }
53 
54 }
const XMSS_WOTS_PrivateKey & private_key() const
wots_keysig_t sign(const secure_vector< uint8_t > &msg, XMSS_Address &adrs)
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:27
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:121
XMSS_WOTS_Parameters m_wots_params
XMSS_WOTS_Signature_Operation(const XMSS_WOTS_Addressed_PrivateKey &private_key)
Definition: alg_id.cpp:13
secure_vector< uint8_t > sign(RandomNumberGenerator &) override
const XMSS_WOTS_Parameters & wots_parameters() const
void update(const uint8_t msg[], size_t msg_len) override