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_Signature_Operation Class Reference

#include <xmss_wots_signature_operation.h>

Inheritance diagram for Botan::XMSS_WOTS_Signature_Operation:
Botan::PK_Ops::Signature Botan::XMSS_WOTS_Common_Ops

Public Member Functions

secure_vector< uint8_t > sign (RandomNumberGenerator &) override
 
void update (const uint8_t msg[], size_t msg_len) override
 
 XMSS_WOTS_Signature_Operation (const XMSS_WOTS_Addressed_PrivateKey &private_key)
 
virtual ~XMSS_WOTS_Signature_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

Signature generation operation for Winternitz One Time Signatures for use in Extended Hash-Based Signatures (XMSS).

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

Definition at line 28 of file xmss_wots_signature_operation.h.

Constructor & Destructor Documentation

Botan::XMSS_WOTS_Signature_Operation::XMSS_WOTS_Signature_Operation ( const XMSS_WOTS_Addressed_PrivateKey private_key)

Definition at line 18 of file xmss_wots_signature_operation.cpp.

References Botan::XMSS_WOTS_Parameters::element_size(), Botan::XMSS_WOTS_Addressed_PrivateKey::private_key(), and Botan::XMSS_WOTS_PublicKey::wots_parameters().

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  }
const XMSS_WOTS_PrivateKey & private_key() const
XMSS_WOTS_Common_Ops(XMSS_WOTS_Parameters::ots_algorithm_t oid)
const XMSS_WOTS_Parameters & wots_parameters() const
virtual Botan::XMSS_WOTS_Signature_Operation::~XMSS_WOTS_Signature_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
secure_vector< uint8_t > Botan::XMSS_WOTS_Signature_Operation::sign ( RandomNumberGenerator )
overridevirtual

Creates a XMSS WOTS signature for the message provided through call to update(). XMSS wots only supports one message part and a fixed message size of "n" bytes where "n" equals the element size of the chosen XMSS WOTS signature method. The random number generator argument is supplied for interface compatibility and remains unused.

Returns
serialized Winternitz One Time Signature.

Implements Botan::PK_Ops::Signature.

Definition at line 41 of file xmss_wots_signature_operation.cpp.

References Botan::XMSS_WOTS_Addressed_PublicKey::address(), Botan::XMSS_WOTS_Parameters::element_size(), Botan::XMSS_WOTS_Parameters::len(), Botan::XMSS_WOTS_Common_Ops::m_wots_params, Botan::XMSS_WOTS_Addressed_PrivateKey::private_key(), and Botan::XMSS_WOTS_PrivateKey::sign().

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  }
const XMSS_WOTS_PrivateKey & private_key() const
XMSS_WOTS_Parameters m_wots_params
void Botan::XMSS_WOTS_Signature_Operation::update ( const uint8_t  msg[],
size_t  msg_len 
)
overridevirtual

Implements Botan::PK_Ops::Signature.

Definition at line 29 of file xmss_wots_signature_operation.cpp.

References BOTAN_ASSERT, Botan::XMSS_WOTS_Addressed_PrivateKey::private_key(), and Botan::XMSS_WOTS_PublicKey::wots_parameters().

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  }
const XMSS_WOTS_PrivateKey & private_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

Definition at line 49 of file xmss_wots_common_ops.h.

Referenced by Botan::XMSS_WOTS_Common_Ops::chain(), and sign().


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