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