Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

xmss_wots_verification_operation.cpp
Go to the documentation of this file.
1 /**
2 * XMSS WOTS Verification Operation
3 * Provides signature verification capabilities for Winternitz One Time
4 * Signatures used 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_verification_operation.h>
15
16 namespace Botan {
17
18 XMSS_WOTS_Verification_Operation::XMSS_WOTS_Verification_Operation(
19 const XMSS_WOTS_Addressed_PublicKey& public_key)
20 : XMSS_WOTS_Common_Ops(public_key.public_key().wots_parameters().oid()),
21 m_pub_key(public_key),
22 m_msg_buf(0)
23 {
24 m_msg_buf.reserve(m_pub_key.public_key().wots_parameters().
25 element_size());
26 }
27
28 void
29 XMSS_WOTS_Verification_Operation::update(const uint8_t msg[], size_t msg_len)
30 {
31 BOTAN_ASSERT(msg_len == m_pub_key.public_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 {
38 m_msg_buf.push_back(msg[i]);
39 }
40 }
41
42 bool XMSS_WOTS_Verification_Operation::is_valid_signature(const uint8_t sig[],
43 size_t sig_len)
44 {
45 const XMSS_WOTS_Parameters& w = m_pub_key.public_key().wots_parameters();
46
47 BOTAN_ASSERT(sig_len == w.element_size() * w.len(),
48 "Invalid signature size.");
49
50 wots_keysig_t signature(0);
51 signature.reserve(sig_len);
52
53 size_t begin = 0;
54 size_t end = 0;
55 while(signature.size() < w.len())
56 {
57 begin = end;
58 end = begin + w.element_size();
59 signature.push_back(secure_vector<uint8_t>(sig + begin, sig + end));
60 }
61
62 XMSS_WOTS_PublicKey pubkey_msg(w.oid(),
63 m_msg_buf,
64 signature,
65 m_pub_key.address(),
66 m_pub_key.public_key().public_seed());
67
68 return pubkey_msg.key_data() == m_pub_key.public_key().key_data();
69 }
70
71 }
72
Botan::XMSS_WOTS_Addressed_PublicKey::public_key
const XMSS_WOTS_PublicKey & public_key() const
Definition: xmss_wots_addressed_publickey.h:41
Botan::XMSS_WOTS_Verification_Operation::XMSS_WOTS_Verification_Operation
XMSS_WOTS_Verification_Operation(const XMSS_WOTS_Addressed_PublicKey &public_key)
Definition: xmss_wots_verification_operation.cpp:18
Botan::XMSS_WOTS_Verification_Operation::is_valid_signature
virtual bool is_valid_signature(const uint8_t sig[], size_t sig_len) override
Definition: xmss_wots_verification_operation.cpp:42
Botan::XMSS_WOTS_Parameters
Definition: xmss_wots_parameters.h:34
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::XMSS_WOTS_PublicKey::public_seed
const secure_vector< uint8_t > & public_seed() const
Definition: xmss_wots_publickey.h:201
BOTAN_ASSERT
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:27
Botan::XMSS_WOTS_Addressed_PublicKey
Definition: xmss_wots_addressed_publickey.h:24
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
Definition: alg_id.cpp:13
Botan::wots_keysig_t
std::vector< secure_vector< uint8_t > > wots_keysig_t
Definition: xmss_common_ops.h:20
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_PublicKey
Definition: xmss_wots_publickey.h:32
Botan::XMSS_WOTS_Parameters::oid
ots_algorithm_t oid() const
Definition: xmss_wots_parameters.h:105
Botan::XMSS_WOTS_PublicKey::key_data
const wots_keysig_t & key_data() const
Definition: xmss_wots_publickey.h:215
Botan::XMSS_WOTS_Verification_Operation::update
void update(const uint8_t msg[], size_t msg_len) override
Definition: xmss_wots_verification_operation.cpp:29