Botan 2.19.5 Crypto and TLS for C&

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 <botan/pk_ops.h>
12#include <botan/xmss.h>
13#include <botan/internal/xmss_address.h>
14#include <botan/internal/xmss_signature.h>
15#include <botan/xmss_wots.h>
16
17 namespace Botan {
18
19/**
20 * Signature generation operation for Extended Hash-Based Signatures (XMSS) as
21 * defined in:
22 *
23 * [1] XMSS: Extended Hash-Based Signatures,
24 * Request for Comments: 8391
25 * Release: May 2018.
26 * https://datatracker.ietf.org/doc/rfc8391/
27 **/
28 class XMSS_Signature_Operation final : public virtual PK_Ops::Signature
29 {
30 public:
31 XMSS_Signature_Operation(const XMSS_PrivateKey& private_key);
32
33 /**
34 * Creates an XMSS signature for the message provided through call to
35 * update().
36 *
37 * @return serialized XMSS signature.
38 **/
39 secure_vector<uint8_t> sign(RandomNumberGenerator&) override;
40
41 void update(const uint8_t msg[], size_t msg_len) override;
42
43 size_t signature_length() const override;
44
45 private:
46 /**
47 * Algorithm 11: "treeSig"
48 * Generate a WOTS+ signature on a message with corresponding auth path.
49 *
50 * @param msg A message.
51 * @param xmss_priv_key A XMSS private key.
52 * @param adrs A XMSS Address.
53 **/
54 XMSS_WOTS_PublicKey::TreeSignature generate_tree_signature(
55 const secure_vector<uint8_t>& msg,
56 XMSS_PrivateKey& xmss_priv_key,
57 XMSS_Address& adrs);
58
59 /**
60 * Algorithm 12: "XMSS_sign"
61 * Generate an XMSS signature and update the XMSS secret key
62 *
63 * @param msg A message to sign of arbitrary length.
64 * @param [out] xmss_priv_key A XMSS private key. The private key will be
65 * updated during the signing process.
66 *
67 * @return The signature of msg signed using xmss_priv_key.
68 **/
69 XMSS_Signature sign(
70 const secure_vector<uint8_t>& msg,
71 XMSS_PrivateKey& xmss_priv_key);
72
73 wots_keysig_t build_auth_path(XMSS_PrivateKey& priv_key,
74 XMSS_Address& adrs);
75
76 void initialize();
77
78 XMSS_PrivateKey m_priv_key;
79 const XMSS_Parameters m_xmss_params;
80 XMSS_Hash m_hash;
81 secure_vector<uint8_t> m_randomness;
82 uint32_t m_leaf_idx;
83 bool m_is_initialized;
84 };
85
86}
87
88#endif
89
Botan::PK_Ops::Signature
Definition: pk_ops.h:91
Botan::RandomNumberGenerator
Definition: rng.h:26
Botan::XMSS_Address
Definition: xmss_address.h:22
Botan::XMSS_Hash
Definition: xmss_hash.h:22
Botan::XMSS_Parameters
Definition: xmss_parameters.h:24
Botan::XMSS_PrivateKey
Definition: xmss.h:271
Botan::XMSS_Signature_Operation
Definition: xmss_signature_operation.h:29
Botan::XMSS_Signature_Operation::XMSS_Signature_Operation
XMSS_Signature_Operation(const XMSS_PrivateKey &private_key)
Definition: xmss_signature_operation.cpp:21
Botan::XMSS_Signature_Operation::signature_length
size_t signature_length() const override
Definition: xmss_signature_operation.cpp:56
Botan::XMSS_Signature_Operation::sign
secure_vector< uint8_t > sign(RandomNumberGenerator &) override
Definition: xmss_signature_operation.cpp:88
Botan::XMSS_Signature_Operation::update
void update(const uint8_t msg[], size_t msg_len) override
Definition: xmss_signature_operation.cpp:81
Botan::XMSS_Signature
Definition: xmss_signature.h:21
Botan::XMSS_WOTS_PublicKey::TreeSignature
Definition: xmss_wots.h:138
final
int(* final)(unsigned char *, CTX *)
Definition: commoncrypto_hash.cpp:29
Botan
Definition: alg_id.cpp:13
Botan::wots_keysig_t
std::vector< secure_vector< uint8_t > > wots_keysig_t
Definition: xmss_common_ops.h:21
Botan::secure_vector
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65