Botan  2.1.0
Crypto and TLS for C++11
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Botan::XMSS_WOTS_Verification_Operation Class Reference

#include <xmss_wots_verification_operation.h>

Inheritance diagram for Botan::XMSS_WOTS_Verification_Operation:
Botan::PK_Ops::Verification Botan::XMSS_WOTS_Common_Ops

Public Member Functions

virtual bool is_valid_signature (const uint8_t sig[], size_t sig_len) override
 
void update (const uint8_t msg[], size_t msg_len) override
 
 XMSS_WOTS_Verification_Operation (const XMSS_WOTS_Addressed_PublicKey &public_key)
 
virtual ~XMSS_WOTS_Verification_Operation ()=default
 

Protected Member Functions

void chain (secure_vector< uint8_t > &result, size_t start_idx, size_t steps, XMSS_Address &adrs, const secure_vector< uint8_t > &seed)
 

Protected Attributes

XMSS_Hash m_hash
 
XMSS_WOTS_Parameters m_wots_params
 

Detailed Description

Provides signature verification capabilities for Winternitz One Time Signatures used in Extended Merkle Tree Signatures (XMSS).

This operation is not intended for stand-alone use and thus not registered in the Botan algorithm registry.

Definition at line 27 of file xmss_wots_verification_operation.h.

Constructor & Destructor Documentation

Botan::XMSS_WOTS_Verification_Operation::XMSS_WOTS_Verification_Operation ( const XMSS_WOTS_Addressed_PublicKey public_key)

Definition at line 18 of file xmss_wots_verification_operation.cpp.

References Botan::XMSS_WOTS_Addressed_PublicKey::public_key(), and Botan::XMSS_WOTS_PublicKey::wots_parameters().

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  }
const XMSS_WOTS_PublicKey & public_key() const
XMSS_WOTS_Common_Ops(XMSS_WOTS_Parameters::ots_algorithm_t oid)
const XMSS_WOTS_Parameters & wots_parameters() const
virtual Botan::XMSS_WOTS_Verification_Operation::~XMSS_WOTS_Verification_Operation ( )
virtualdefault

Member Function Documentation

void Botan::XMSS_WOTS_Common_Ops::chain ( secure_vector< uint8_t > &  result,
size_t  start_idx,
size_t  steps,
XMSS_Address adrs,
const secure_vector< uint8_t > &  seed 
)
protectedinherited

Algorithm 2: Chaining Function.

Parameters
[out]resultContains the n-byte input string "x" upon call to chain(), that will be replaced with the value obtained by iterating the cryptographic hash function "F" steps times on the input x using the outputs of the PRNG "G".
[in]start_idxThe start index.
[in]stepsA number of steps.
[in]adrsAn OTS Hash Address.
[in]seedA Seed.

Definition at line 16 of file xmss_wots_common_ops.cpp.

References Botan::XMSS_Address::bytes(), Botan::XMSS_Hash::f(), Botan::XMSS_Address::Key_Mode, Botan::XMSS_WOTS_Common_Ops::m_hash, Botan::XMSS_WOTS_Common_Ops::m_wots_params, Botan::XMSS_Address::Mask_Mode, Botan::XMSS_Hash::prf(), Botan::XMSS_Address::set_hash_address(), Botan::XMSS_Address::set_key_mask_mode(), Botan::XMSS_WOTS_Parameters::wots_parameter(), and Botan::xor_buf().

21  {
22  for(size_t i = start_idx;
23  i < (start_idx + steps) && i < m_wots_params.wots_parameter();
24  i++)
25  {
26  adrs.set_hash_address(i);
27 
28  //Calculate tmp XOR bitmask
29  adrs.set_key_mask_mode(XMSS_Address::Key_Mask::Mask_Mode);
30  xor_buf(result, m_hash.prf(seed, adrs.bytes()), result.size());
31 
32  // Calculate key
33  adrs.set_key_mask_mode(XMSS_Address::Key_Mask::Key_Mode);
34 
35  //Calculate f(key, tmp XOR bitmask)
36  m_hash.f(result, m_hash.prf(seed, adrs.bytes()), result);
37  }
38  }
void xor_buf(T out[], const T in[], size_t length)
Definition: mem_ops.h:115
void f(secure_vector< uint8_t > &result, const secure_vector< uint8_t > &key, const secure_vector< uint8_t > &data)
Definition: xmss_hash.h:74
XMSS_WOTS_Parameters m_wots_params
void prf(secure_vector< uint8_t > &result, const secure_vector< uint8_t > &key, const secure_vector< uint8_t > &data)
Definition: xmss_hash.h:38
bool Botan::XMSS_WOTS_Verification_Operation::is_valid_signature ( const uint8_t  sig[],
size_t  sig_len 
)
overridevirtual

Implements Botan::PK_Ops::Verification.

Definition at line 42 of file xmss_wots_verification_operation.cpp.

References Botan::XMSS_WOTS_Addressed_PublicKey::address(), BOTAN_ASSERT, Botan::XMSS_WOTS_Parameters::element_size(), Botan::XMSS_WOTS_PublicKey::key_data(), Botan::XMSS_WOTS_Parameters::len(), Botan::XMSS_WOTS_Parameters::oid(), Botan::XMSS_WOTS_Addressed_PublicKey::public_key(), Botan::XMSS_WOTS_PublicKey::public_seed(), and Botan::XMSS_WOTS_PublicKey::wots_parameters().

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  }
const XMSS_WOTS_PublicKey & public_key() const
const secure_vector< uint8_t > & public_seed() const
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:27
std::vector< secure_vector< uint8_t > > wots_keysig_t
const XMSS_WOTS_Parameters & wots_parameters() const
const wots_keysig_t & key_data() const
void Botan::XMSS_WOTS_Verification_Operation::update ( const uint8_t  msg[],
size_t  msg_len 
)
overridevirtual

Implements Botan::PK_Ops::Verification.

Definition at line 29 of file xmss_wots_verification_operation.cpp.

References BOTAN_ASSERT, Botan::XMSS_WOTS_Addressed_PublicKey::public_key(), and Botan::XMSS_WOTS_PublicKey::wots_parameters().

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  }
const XMSS_WOTS_PublicKey & public_key() const
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:27
const XMSS_WOTS_Parameters & wots_parameters() const

Member Data Documentation

XMSS_Hash Botan::XMSS_WOTS_Common_Ops::m_hash
protectedinherited

Definition at line 50 of file xmss_wots_common_ops.h.

Referenced by Botan::XMSS_WOTS_Common_Ops::chain().

XMSS_WOTS_Parameters Botan::XMSS_WOTS_Common_Ops::m_wots_params
protectedinherited

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