Botan  2.6.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 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  * draft-itrf-cfrg-xmss-hash-based-signatures-06
31  * Release: July 2016.
32  * https://datatracker.ietf.org/doc/
33  * draft-irtf-cfrg-xmss-hash-based-signatures/?include_text=1
34  **/
35 class XMSS_Signature_Operation final : public virtual PK_Ops::Signature,
36  public XMSS_Common_Ops
37  {
38  public:
39  XMSS_Signature_Operation(const XMSS_PrivateKey& private_key);
40 
41  /**
42  * Creates an XMSS signature for the message provided through call to
43  * update().
44  *
45  * @return serialized XMSS signature.
46  **/
48 
49  void update(const uint8_t msg[], size_t msg_len) override;
50 
51  private:
52  /**
53  * Algorithm 11: "treeSig"
54  * Generate a WOTS+ signature on a message with corresponding auth path.
55  *
56  * @param msg A message.
57  * @param xmss_priv_key A XMSS private key.
58  * @param adrs A XMSS Address.
59  **/
60  XMSS_WOTS_PublicKey::TreeSignature generate_tree_signature(
61  const secure_vector<uint8_t>& msg,
62  XMSS_PrivateKey& xmss_priv_key,
63  XMSS_Address& adrs);
64 
65  /**
66  * Algorithm 12: "XMSS_sign"
67  * Generate an XMSS signature and update the XMSS secret key
68  *
69  * @param msg A message to sign of arbitrary length.
70  * @param [out] xmss_priv_key A XMSS private key. The private key will be
71  * updated during the signing process.
72  *
73  * @return The signature of msg signed using xmss_priv_key.
74  **/
76  const secure_vector<uint8_t>& msg,
77  XMSS_PrivateKey& xmss_priv_key);
78 
79  wots_keysig_t build_auth_path(XMSS_PrivateKey& priv_key,
80  XMSS_Address& adrs);
81 
82  void initialize();
83 
84  XMSS_PrivateKey m_priv_key;
85  secure_vector<uint8_t> m_randomness;
86  size_t m_leaf_idx;
87  bool m_is_initialized;
88  };
89 
90 }
91 
92 #endif
93 
XMSS_Signature_Operation(const XMSS_PrivateKey &private_key)
Definition: alg_id.cpp:13
std::vector< secure_vector< uint8_t > > wots_keysig_t
secure_vector< uint8_t > sign(RandomNumberGenerator &) override
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:88
void update(const uint8_t msg[], size_t msg_len) override