Botan  2.13.0
Crypto and TLS for C++11
xmss_signature_operation.h
Go to the documentation of this file.
1 /*
2  * XMSS Signature Operation
3  * (C) 2016,2017,2018 Matthias Gierlings
4  *
5  * Botan is released under the Simplified BSD License (see license.txt)
6  **/
7 
8 #ifndef BOTAN_XMSS_SIGNATURE_OPERATION_H_
9 #define BOTAN_XMSS_SIGNATURE_OPERATION_H_
10 
11 #include <cstddef>
12 #include <string>
13 #include <botan/secmem.h>
14 #include <botan/types.h>
15 #include <botan/xmss_parameters.h>
16 #include <botan/xmss_privatekey.h>
17 #include <botan/xmss_address.h>
18 #include <botan/xmss_common_ops.h>
19 #include <botan/pk_ops.h>
20 #include <botan/internal/xmss_signature.h>
21 #include <botan/xmss_wots_publickey.h>
22 
23 namespace Botan {
24 
25 /**
26  * Signature generation operation for Extended Hash-Based Signatures (XMSS) as
27  * defined in:
28  *
29  * [1] XMSS: Extended Hash-Based Signatures,
30  * Request for Comments: 8391
31  * Release: May 2018.
32  * https://datatracker.ietf.org/doc/rfc8391/
33  **/
35  public XMSS_Common_Ops
36  {
37  public:
38  XMSS_Signature_Operation(const XMSS_PrivateKey& private_key);
39 
40  /**
41  * Creates an XMSS signature for the message provided through call to
42  * update().
43  *
44  * @return serialized XMSS signature.
45  **/
47 
48  void update(const uint8_t msg[], size_t msg_len) override;
49 
50  size_t signature_length() const override;
51 
52  private:
53  /**
54  * Algorithm 11: "treeSig"
55  * Generate a WOTS+ signature on a message with corresponding auth path.
56  *
57  * @param msg A message.
58  * @param xmss_priv_key A XMSS private key.
59  * @param adrs A XMSS Address.
60  **/
61  XMSS_WOTS_PublicKey::TreeSignature generate_tree_signature(
62  const secure_vector<uint8_t>& msg,
63  XMSS_PrivateKey& xmss_priv_key,
64  XMSS_Address& adrs);
65 
66  /**
67  * Algorithm 12: "XMSS_sign"
68  * Generate an XMSS signature and update the XMSS secret key
69  *
70  * @param msg A message to sign of arbitrary length.
71  * @param [out] xmss_priv_key A XMSS private key. The private key will be
72  * updated during the signing process.
73  *
74  * @return The signature of msg signed using xmss_priv_key.
75  **/
77  const secure_vector<uint8_t>& msg,
78  XMSS_PrivateKey& xmss_priv_key);
79 
80  wots_keysig_t build_auth_path(XMSS_PrivateKey& priv_key,
81  XMSS_Address& adrs);
82 
83  void initialize();
84 
85  XMSS_PrivateKey m_priv_key;
86  secure_vector<uint8_t> m_randomness;
87  uint32_t m_leaf_idx;
88  bool m_is_initialized;
89  };
90 
91 }
92 
93 #endif
94 
XMSS_Signature_Operation(const XMSS_PrivateKey &private_key)
int(* final)(unsigned char *, CTX *)
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:65
Definition: alg_id.cpp:13
std::vector< secure_vector< uint8_t > > wots_keysig_t
secure_vector< uint8_t > sign(RandomNumberGenerator &) override
void update(const uint8_t msg[], size_t msg_len) override