Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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
18 XMSS_WOTS_Signature_Operation::XMSS_WOTS_Signature_Operation(
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
40 secure_vector<uint8_t>
41 XMSS_WOTS_Signature_Operation::sign(RandomNumberGenerator&)
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 }
Botan::XMSS_WOTS_Addressed_PrivateKey
Definition: xmss_wots_addressed_privatekey.h:24
Botan::XMSS_WOTS_Addressed_PrivateKey::private_key
const XMSS_WOTS_PrivateKey & private_key() const
Definition: xmss_wots_addressed_privatekey.h:48
Botan::RandomNumberGenerator
Definition: rng.h:25
Botan::XMSS_WOTS_PrivateKey::sign
wots_keysig_t sign(const secure_vector< uint8_t > &msg, XMSS_Address &adrs)
Definition: xmss_wots_privatekey.cpp:59
Botan::XMSS_WOTS_PrivateKey
Definition: xmss_wots_privatekey.h:27
Botan::XMSS_WOTS_Parameters::element_size
size_t element_size() const
Definition: xmss_wots_parameters.h:87
Botan::XMSS_WOTS_Common_Ops
Definition: xmss_wots_common_ops.h:23
BOTAN_ASSERT
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:27
Botan::secure_vector
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:121
Botan::XMSS_WOTS_Parameters::len
size_t len() const
Definition: xmss_wots_parameters.h:97
Botan::XMSS_WOTS_Common_Ops::m_wots_params
XMSS_WOTS_Parameters m_wots_params
Definition: xmss_wots_common_ops.h:49
Botan::XMSS_WOTS_Signature_Operation::XMSS_WOTS_Signature_Operation
XMSS_WOTS_Signature_Operation(const XMSS_WOTS_Addressed_PrivateKey &private_key)
Definition: xmss_wots_signature_operation.cpp:18
Botan
Definition: alg_id.cpp:13
Botan::XMSS_WOTS_Signature_Operation::sign
secure_vector< uint8_t > sign(RandomNumberGenerator &) override
Definition: xmss_wots_signature_operation.cpp:41
Botan::XMSS_WOTS_Addressed_PublicKey::address
const XMSS_Address & address() const
Definition: xmss_wots_addressed_publickey.h:44
Botan::XMSS_WOTS_PublicKey::wots_parameters
const XMSS_WOTS_Parameters & wots_parameters() const
Definition: xmss_wots_publickey.h:229
Botan::XMSS_WOTS_Signature_Operation::update
void update(const uint8_t msg[], size_t msg_len) override
Definition: xmss_wots_signature_operation.cpp:29