Botan 3.14.1
Crypto and TLS for C&
sphincsplus.cpp
Go to the documentation of this file.
1/*
2* SLH-DSA - Stateless Hash-Based Digital Signature Standard - FIPS 205
3* (C) 2023 Jack Lloyd
4* 2023 Fabian Albert, René Meusel, Amos Treiber - Rohde & Schwarz Cybersecurity
5*
6* Botan is released under the Simplified BSD License (see license.txt)
7**/
8
9#include <botan/pk_options_readers.h>
10#include <botan/sphincsplus.h>
11
12#include <botan/rng.h>
13#include <botan/internal/buffer_slicer.h>
14#include <botan/internal/buffer_stuffer.h>
15#include <botan/internal/concat_util.h>
16#include <botan/internal/int_utils.h>
17#include <botan/internal/pk_ops_impl.h>
18#include <botan/internal/pk_options_impl.h>
19#include <botan/internal/sp_fors.h>
20#include <botan/internal/sp_hash.h>
21#include <botan/internal/sp_hypertree.h>
22#include <botan/internal/sp_treehash.h>
23#include <botan/internal/sp_types.h>
24#include <botan/internal/sp_wots.h>
25#include <botan/internal/sp_xmss.h>
26
27#include <utility>
28
29#if !defined(BOTAN_HAS_SPHINCS_PLUS_WITH_SHA2) and !defined(BOTAN_HAS_SPHINCS_PLUS_WITH_SHAKE) and \
30 !defined(BOTAN_HAS_SLH_DSA_WITH_SHA2) and !defined(BOTAN_HAS_SLH_DSA_WITH_SHAKE)
31static_assert(
32 false,
33 "botan module 'sphincsplus_common' is useful only when enabling at least 'sphincsplus_sha2', 'sphincsplus_shake', 'slh_dsa_sha2', or 'slh_dsa_shake'");
34#endif
35
36namespace Botan {
37
38namespace {
39// FIPS 205, Algorithm 22, line 8
41 const Sphincs_Parameters& params,
43 BOTAN_ARG_CHECK(params.is_slh_dsa() || context.empty(), "Context is not supported for SPHINCS+");
44#if defined(BOTAN_HAS_SLH_DSA_WITH_SHA2) || defined(BOTAN_HAS_SLH_DSA_WITH_SHAKE)
45 if(params.is_slh_dsa()) {
46 // prefix (no pre-hash mode): input mode byte + |ctx| + ctx
47 const uint8_t input_mode_byte = 0x00; // Pure (TODO: pre-hash mode: 0x01)
48 return {
50 store_be(input_mode_byte), store_be(checked_cast_to<uint8_t>(context.size())), context),
51 .message = std::move(msg),
52 };
53 }
54#endif
55#if defined(BOTAN_HAS_SPHINCS_PLUS_WITH_SHA2) || defined(BOTAN_HAS_SPHINCS_PLUS_WITH_SHAKE)
56 if(!params.is_slh_dsa()) {
57 // SPHINCS+ Round 3.1 uses the message without any prefix
58 return {
59 .prefix = {}, // SPHINCS+ has no prefix
60 .message = std::move(msg),
61 };
62 }
63#endif
64 throw Internal_Error("Missing message preparation logic for SLH-DSA or SPHINCS+");
65}
66} // namespace
67
68class SphincsPlus_PublicKeyInternal final {
69 public:
70 SphincsPlus_PublicKeyInternal(Sphincs_Parameters params,
71 SphincsPublicSeed public_seed,
72 SphincsTreeNode sphincs_root) :
73 m_params(params), m_public_seed(std::move(public_seed)), m_sphincs_root(std::move(sphincs_root)) {}
74
75 SphincsPlus_PublicKeyInternal(Sphincs_Parameters params, std::span<const uint8_t> key_bits) : m_params(params) {
76 if(key_bits.size() != m_params.public_key_bytes()) {
77 throw Decoding_Error("SLH-DSA (or SPHINCS+) Public Key doesn't have the expected length");
78 }
79
80 BufferSlicer s(key_bits);
81 m_public_seed = s.copy<SphincsPublicSeed>(params.n());
82 m_sphincs_root = s.copy<SphincsTreeNode>(params.n());
83
84 BOTAN_ASSERT_NOMSG(s.empty());
85 }
86
87 std::vector<uint8_t> key_bits() const { return concat<std::vector<uint8_t>>(m_public_seed, m_sphincs_root); }
88
89 const SphincsPublicSeed& seed() const { return m_public_seed; }
90
91 const SphincsTreeNode& root() const { return m_sphincs_root; }
92
93 const Sphincs_Parameters& parameters() const { return m_params; }
94
95 private:
96 Sphincs_Parameters m_params;
97 SphincsPublicSeed m_public_seed;
98 SphincsTreeNode m_sphincs_root;
99};
100
101class SphincsPlus_PrivateKeyInternal final {
102 public:
103 SphincsPlus_PrivateKeyInternal(SphincsSecretSeed secret_seed, SphincsSecretPRF prf) :
104 m_secret_seed(std::move(secret_seed)), m_prf(std::move(prf)) {}
105
106 SphincsPlus_PrivateKeyInternal(const Sphincs_Parameters& params, std::span<const uint8_t> key_bits) {
107 if(key_bits.size() != params.private_key_bytes() - params.public_key_bytes()) {
108 throw Decoding_Error("SLH-DSA (or SPHINCS+) Private Key doesn't have the expected length");
109 }
110
111 BufferSlicer s(key_bits);
112 m_secret_seed = s.copy<SphincsSecretSeed>(params.n());
113 m_prf = s.copy<SphincsSecretPRF>(params.n());
114
115 BOTAN_ASSERT_NOMSG(s.empty());
116 }
117
118 const SphincsSecretSeed& seed() const { return m_secret_seed; }
119
120 const SphincsSecretPRF& prf() const { return m_prf; }
121
122 secure_vector<uint8_t> key_bits() const { return concat<secure_vector<uint8_t>>(m_secret_seed, m_prf); }
123
124 private:
125 SphincsSecretSeed m_secret_seed;
126 SphincsSecretPRF m_prf;
127};
128
129SphincsPlus_PublicKey::SphincsPlus_PublicKey(std::span<const uint8_t> pub_key,
131 Sphincs_Hash_Type hash) :
132 SphincsPlus_PublicKey(pub_key, Sphincs_Parameters::create(type, hash)) {}
133
134SphincsPlus_PublicKey::SphincsPlus_PublicKey(std::span<const uint8_t> pub_key, Sphincs_Parameters params) :
135 m_public(std::make_shared<SphincsPlus_PublicKeyInternal>(params, pub_key)) {
136 if(!params.is_available()) {
137 throw Not_Implemented("This SPHINCS+ parameter set is not available in this configuration");
138 }
139}
140
141SphincsPlus_PublicKey::SphincsPlus_PublicKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits) :
142 SphincsPlus_PublicKey(key_bits, Sphincs_Parameters::create(alg_id.oid())) {
143 // The parameter set is identified by the OID; no parameters are defined.
144 if(!alg_id.parameters_are_empty()) {
145 throw Decoding_Error("Unexpected parameters for SLH-DSA/SPHINCS+ public key");
146 }
147}
148
150
152 return m_public->parameters().n() * 8;
153}
154
156 return m_public->parameters().is_slh_dsa() ? "SLH-DSA" : "SPHINCS+";
157}
158
160 return m_public->parameters().bitsec();
161}
162
164 return m_public->parameters().algorithm_identifier();
165}
166
168 return m_public->parameters().object_identifier();
169}
170
171bool SphincsPlus_PublicKey::check_key(RandomNumberGenerator& /*rng*/, bool /*strong*/) const {
172 // Nothing to check for the public key. It's literally just hashes. :-)
173 return true;
174}
175
176std::vector<uint8_t> SphincsPlus_PublicKey::raw_public_key_bits() const {
177 return m_public->key_bits();
178}
179
180std::vector<uint8_t> SphincsPlus_PublicKey::public_key_bits() const {
181 // Currently, there isn't a finalized definition of an ASN.1 structure for
182 // SLH-DSA or SPHINCS+ public keys. Therefore, we return the raw public key bits.
183 return raw_public_key_bits();
184}
185
186std::unique_ptr<Private_Key> SphincsPlus_PublicKey::generate_another(RandomNumberGenerator& rng) const {
187 return std::make_unique<SphincsPlus_PrivateKey>(rng, m_public->parameters());
188}
189
190namespace {
191
192class SphincsPlus_Verification_Operation final : public PK_Ops::Verification {
193 public:
194 explicit SphincsPlus_Verification_Operation(std::shared_ptr<const SphincsPlus_PublicKeyInternal> pub_key) :
195 m_public(std::move(pub_key)),
196 m_hashes(Botan::Sphincs_Hash_Functions::create(m_public->parameters(), m_public->seed())),
197 m_context(/* TODO: Add API */ {}) {
198 BOTAN_ARG_CHECK(m_context.size() <= 255, "Context must not exceed 255 bytes");
199
200 if(!m_public->parameters().is_available()) {
201 throw Not_Implemented("This SPHINCS+ parameter set is not available in this configuration");
202 }
203 }
204
205 /**
206 * Add more data to the message currently being signed
207 * @param msg the message
208 */
209 void update(std::span<const uint8_t> msg) override {
210 // TODO(For Pre-Hash Mode): We need to stream the message into a hash function.
211 m_msg_buffer.get().insert(m_msg_buffer.end(), msg.begin(), msg.end());
212 }
213
214 /**
215 * Perform a verification operation
216 */
217 bool is_valid_signature(std::span<const uint8_t> sig) override {
218 const auto internal_msg = prepare_message(std::exchange(m_msg_buffer, {}), m_public->parameters(), m_context);
219 return slh_verify_internal(internal_msg, sig);
220 }
221
222 std::string hash_function() const override { return m_hashes->msg_hash_function_name(); }
223
224 private:
225 /// FIPS 205, Algorithm 20
226 bool slh_verify_internal(const SphincsMessageInternal& msg, std::span<const uint8_t> sig) {
227 const auto& p = m_public->parameters();
228 if(sig.size() != p.sphincs_signature_bytes()) {
229 return false;
230 }
231
232 BufferSlicer s(sig);
233 // Compute leaf and tree index from R
234 const auto msg_random_s = s.take<SphincsMessageRandomness>(p.n());
235 auto [mhash, tree_idx, leaf_idx] = m_hashes->H_msg(msg_random_s, m_public->root(), msg);
236
237 // Reconstruct the FORS tree
238 Sphincs_Address fors_addr(Sphincs_Address_Type::ForsTree);
239 fors_addr.set_tree_address(tree_idx).set_keypair_address(leaf_idx);
240 const auto fors_sig_s = s.take<ForsSignature>(p.fors_signature_bytes());
241 const auto fors_root = fors_public_key_from_signature(mhash, fors_sig_s, fors_addr, p, *m_hashes);
242
243 // Verify the hypertree signature
244 const auto ht_sig_s = s.take<SphincsHypertreeSignature>(p.ht_signature_bytes());
245 BOTAN_ASSERT_NOMSG(s.empty());
246 return ht_verify(fors_root, ht_sig_s, m_public->root(), tree_idx, leaf_idx, p, *m_hashes);
247 }
248
249 std::shared_ptr<const SphincsPlus_PublicKeyInternal> m_public;
250 std::unique_ptr<Sphincs_Hash_Functions> m_hashes;
251 SphincsInputMessage m_msg_buffer;
252 SphincsContext m_context;
253};
254
255} // namespace
256
257std::unique_ptr<PK_Ops::Verification> SphincsPlus_PublicKey::_create_verification_op(
258 const PK_Signature_Options_Reader& options) const {
260
261 auto op = std::make_unique<SphincsPlus_Verification_Operation>(m_public);
262 // The message hash depends on the parameter set, so check against what the operation reports
263 validate_for_hash_based_signature(options, "SPHINCS+", op->hash_function());
264 return op;
265}
266
267std::unique_ptr<PK_Ops::Verification> SphincsPlus_PublicKey::create_x509_verification_op(
268 const AlgorithmIdentifier& signature_algorithm, std::string_view provider) const {
269 if(provider.empty() || provider == "base") {
270 // RFC 9909 Section 3:
271 // The contents of the parameters component for each algorithm MUST be absent.
272 if(signature_algorithm.oid() != this->object_identifier() || !signature_algorithm.parameters_are_empty()) {
273 throw Decoding_Error("Unexpected AlgorithmIdentifier for SLH-DSA (or SPHINCS+) signature");
274 }
275 return std::make_unique<SphincsPlus_Verification_Operation>(m_public);
276 }
277 throw Provider_Not_Found(algo_name(), provider);
278}
279
283
284namespace {
285
286std::span<const uint8_t> slice_off_public_key(const OID& oid, std::span<const uint8_t> key_bits) {
287 const auto params = Sphincs_Parameters::create(oid);
288 // Note: We need to transiently instantiate the `Sphincs_Parameters` object
289 // to know the size of the public/private key. That's slightly
290 // inefficient but was the best we could do. Once we get rid of the
291 // PublicKey-PrivateKey inheritance, we might want to reconsider this
292 // control flow.
293 if(key_bits.size() != params.private_key_bytes()) {
294 throw Decoding_Error("Sphincs Private Key doesn't have the expected length");
295 }
296
297 return key_bits.subspan(params.private_key_bytes() - params.public_key_bytes());
298}
299
300} // namespace
301
302SphincsPlus_PrivateKey::SphincsPlus_PrivateKey(std::span<const uint8_t> private_key,
304 Sphincs_Hash_Type hash) :
305 SphincsPlus_PrivateKey(private_key, Sphincs_Parameters::create(type, hash)) {}
306
307SphincsPlus_PrivateKey::SphincsPlus_PrivateKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits) :
308 SphincsPlus_PrivateKey(key_bits, Sphincs_Parameters::create(alg_id.oid())) {
309 // The parameter set is identified by the OID; no parameters are defined.
310 if(!alg_id.parameters_are_empty()) {
311 throw Decoding_Error("Unexpected parameters for SLH-DSA/SPHINCS+ private key");
312 }
313}
314
315SphincsPlus_PrivateKey::SphincsPlus_PrivateKey(std::span<const uint8_t> private_key, Sphincs_Parameters params) :
316 SphincsPlus_PublicKey(slice_off_public_key(params.object_identifier(), private_key), params) {
317 if(!params.is_available()) {
318 throw Not_Implemented("This SPHINCS+ parameter set is not available in this configuration");
319 }
320
321 const auto private_portion_bytes = params.private_key_bytes() - params.public_key_bytes();
322 BOTAN_ASSERT_NOMSG(private_key.size() >= private_portion_bytes);
323
324 m_private = std::make_shared<SphincsPlus_PrivateKeyInternal>(params, private_key.first(private_portion_bytes));
325}
326
331
332// FIPS 205, Algorithm 21
334 if(!params.is_available()) {
335 throw Not_Implemented("This SPHINCS+ parameter set is not available in this configuration");
336 }
337 auto sk_seed = rng.random_vec<SphincsSecretSeed>(params.n());
338 auto sk_prf = rng.random_vec<SphincsSecretPRF>(params.n());
339
340 m_private = std::make_shared<SphincsPlus_PrivateKeyInternal>(std::move(sk_seed), std::move(sk_prf));
341
342 auto pub_seed = rng.random_vec<SphincsPublicSeed>(params.n());
343 auto hashes = Sphincs_Hash_Functions::create(params, pub_seed);
344 auto root = xmss_gen_root(params, m_private->seed(), *hashes);
345
346 m_public = std::make_shared<SphincsPlus_PublicKeyInternal>(params, std::move(pub_seed), std::move(root));
347}
348
350
352 return concat(m_private->key_bits(), m_public->key_bits());
353}
354
358
359std::unique_ptr<Public_Key> SphincsPlus_PrivateKey::public_key() const {
360 return std::make_unique<SphincsPlus_PublicKey>(*this);
361}
362
364 if(strong) {
365 // Check that the embedded public root is consistent with the secret
366 // seed by recomputing it. This costs about as much as a key generation,
367 // but much less than a sign/verify roundtrip.
368 const auto& params = m_public->parameters();
369 auto hashes = Sphincs_Hash_Functions::create(params, m_public->seed());
370 const auto root = xmss_gen_root(params, m_private->seed(), *hashes);
371 return root == m_public->root();
372 }
373 return true;
374}
375
376namespace {
377
378class SphincsPlus_Signature_Operation final : public PK_Ops::Signature {
379 public:
380 SphincsPlus_Signature_Operation(std::shared_ptr<const SphincsPlus_PrivateKeyInternal> private_key,
381 std::shared_ptr<const SphincsPlus_PublicKeyInternal> public_key,
382 bool randomized) :
383 m_private(std::move(private_key)),
384 m_public(std::move(public_key)),
385 m_hashes(Botan::Sphincs_Hash_Functions::create(m_public->parameters(), m_public->seed())),
386 m_randomized(randomized),
387 m_context(/* TODO: add API for context */ {}) {
388 BOTAN_ARG_CHECK(m_context.size() <= 255, "Context must not exceed 255 bytes");
389 BOTAN_ARG_CHECK(m_public->parameters().is_available(),
390 "The selected SLH-DSA (or SPHINCS+) instance is not available in this build.");
391 }
392
393 void update(std::span<const uint8_t> msg) override {
394 // TODO(For Pre-Hash Mode): We need to stream the message into a hash function.
395 m_msg_buffer.get().insert(m_msg_buffer.end(), msg.begin(), msg.end());
396 }
397
398 std::vector<uint8_t> sign(RandomNumberGenerator& rng) override {
399 std::optional<SphincsOptionalRandomness> addrnd = std::nullopt;
400 if(m_randomized) {
401 addrnd = rng.random_vec<SphincsOptionalRandomness>(m_public->parameters().n());
402 }
403 const auto internal_msg = prepare_message(std::exchange(m_msg_buffer, {}), m_public->parameters(), m_context);
404
405 return slh_sign_internal(internal_msg, addrnd);
406 }
407
408 size_t signature_length() const override { return m_public->parameters().sphincs_signature_bytes(); }
409
410 AlgorithmIdentifier algorithm_identifier() const override {
411 return m_public->parameters().algorithm_identifier();
412 }
413
414 std::string hash_function() const override { return m_hashes->msg_hash_function_name(); }
415
416 private:
417 // FIPS 205, Algorithm 19
418 std::vector<uint8_t> slh_sign_internal(const SphincsMessageInternal& message,
419 std::optional<StrongSpan<const SphincsOptionalRandomness>> addrnd) {
420 const auto& p = m_public->parameters();
421
422 std::vector<uint8_t> sphincs_sig_buffer(p.sphincs_signature_bytes());
423 BufferStuffer sphincs_sig(sphincs_sig_buffer);
424
425 // Compute and append the digest randomization value (R of spec).
426 // Use addrng for the randomized variant. Use the public seed for the deterministic one.
427 const auto opt_rand =
428 (addrnd.has_value()) ? addrnd.value() : StrongSpan<const SphincsOptionalRandomness>(m_public->seed());
429
430 const auto msg_random_s = sphincs_sig.next<SphincsMessageRandomness>(p.n());
431 m_hashes->PRF_msg(msg_random_s, m_private->prf(), opt_rand, message);
432
433 // Derive the message digest and leaf index from R, PK and M.
434 auto [mhash, tree_idx, leaf_idx] = m_hashes->H_msg(msg_random_s, m_public->root(), message);
435
436 // Compute and append the FORS signature
437 Sphincs_Address fors_addr(Sphincs_Address_Type::ForsTree);
438 fors_addr.set_tree_address(tree_idx).set_keypair_address(leaf_idx);
439 const auto fors_root = fors_sign_and_pkgen(sphincs_sig.next<ForsSignature>(p.fors_signature_bytes()),
440 mhash,
441 m_private->seed(),
442 fors_addr,
443 p,
444 *m_hashes);
445
446 // Compute and append the XMSS hypertree signature
447 ht_sign(sphincs_sig.next<SphincsHypertreeSignature>(p.ht_signature_bytes()),
448 fors_root,
449 m_private->seed(),
450 tree_idx,
451 leaf_idx,
452 p,
453 *m_hashes);
454
455 BOTAN_ASSERT_NOMSG(sphincs_sig.full());
456 return sphincs_sig_buffer;
457 }
458
459 std::shared_ptr<const SphincsPlus_PrivateKeyInternal> m_private;
460 std::shared_ptr<const SphincsPlus_PublicKeyInternal> m_public;
461 std::unique_ptr<Sphincs_Hash_Functions> m_hashes;
462 SphincsInputMessage m_msg_buffer;
463 bool m_randomized;
464 SphincsContext m_context;
465};
466
467} // namespace
468
469std::unique_ptr<PK_Ops::Signature> SphincsPlus_PrivateKey::_create_signature_op(
470 RandomNumberGenerator& rng, const PK_Signature_Options_Reader& options) const {
471 BOTAN_UNUSED(rng);
472
473 // FIPS 205, Section 9.2
474 // The hedged variant is the default and should be used on platforms where
475 // side-channel attacks are a concern.
476 const bool randomized = !options.using_deterministic_signature();
478
479 auto op = std::make_unique<SphincsPlus_Signature_Operation>(m_private, m_public, randomized);
480 // The message hash depends on the parameter set, so check against what the operation reports
481 validate_for_hash_based_signature(options, "SPHINCS+", op->hash_function());
482 return op;
483}
484
485} // namespace Botan
#define BOTAN_UNUSED
Definition assert.h:151
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:82
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:33
bool parameters_are_empty() const
Definition asn1_obj.h:715
const OID & oid() const
Definition asn1_obj.h:688
const std::optional< std::string > & hash_function() const
void random_vec(std::span< uint8_t > v)
Definition rng.h:254
secure_vector< uint8_t > raw_private_key_bits() const override
std::unique_ptr< PK_Ops::Signature > _create_signature_op(RandomNumberGenerator &rng, const PK_Signature_Options_Reader &options) const override
SphincsPlus_PrivateKey(std::span< const uint8_t > private_key, Sphincs_Parameter_Set type, Sphincs_Hash_Type hash)
secure_vector< uint8_t > private_key_bits() const override
bool check_key(RandomNumberGenerator &rng, bool strong) const override
std::unique_ptr< Public_Key > public_key() const override
std::vector< uint8_t > public_key_bits() const override
std::vector< uint8_t > raw_public_key_bits() const override
std::shared_ptr< const SphincsPlus_PublicKeyInternal > m_public
Definition sphincsplus.h:68
std::unique_ptr< PK_Ops::Verification > create_x509_verification_op(const AlgorithmIdentifier &signature_algorithm, std::string_view provider) const override
bool supports_operation(PublicKeyOperation op) const override
std::string algo_name() const override
size_t key_length() const override
std::unique_ptr< Private_Key > generate_another(RandomNumberGenerator &rng) const final
bool check_key(RandomNumberGenerator &rng, bool strong) const override
AlgorithmIdentifier algorithm_identifier() const override
std::unique_ptr< PK_Ops::Verification > _create_verification_op(const PK_Signature_Options_Reader &options) const override
size_t estimated_strength() const override
SphincsPlus_PublicKey(std::span< const uint8_t > pub_key, Sphincs_Parameter_Set type, Sphincs_Hash_Type hash)
OID object_identifier() const override
static std::unique_ptr< Sphincs_Hash_Functions > create(const Sphincs_Parameters &sphincs_params, const SphincsPublicSeed &pub_seed)
Definition sp_hash.cpp:63
uint32_t private_key_bytes() const
uint32_t public_key_bytes() const
static Sphincs_Parameters create(Sphincs_Parameter_Set set, Sphincs_Hash_Type hash)
Gf448Elem root(const Gf448Elem &elem)
Compute the root of elem in the field.
Strong< std::vector< uint8_t >, struct SphincsTreeNode_ > SphincsTreeNode
Either an XMSS or FORS tree node or leaf.
Definition sp_types.h:70
SphincsTreeNode xmss_gen_root(const Sphincs_Parameters &params, const SphincsSecretSeed &secret_seed, Sphincs_Hash_Functions &hashes)
Definition sp_xmss.cpp:75
Strong< secure_vector< uint8_t >, struct SphincsMessageRandomness_ > SphincsMessageRandomness
Definition sp_types.h:64
Sphincs_Parameter_Set
SphincsTreeNode fors_sign_and_pkgen(StrongSpan< ForsSignature > sig_out, const SphincsHashedMessage &hashed_message, const SphincsSecretSeed &secret_seed, const Sphincs_Address &address, const Sphincs_Parameters &params, Sphincs_Hash_Functions &hashes)
FIPS 205, Algorithm 16: fors_sign (with simultaneous FORS pk generation).
Definition sp_fors.cpp:63
Strong< std::vector< uint8_t >, struct ForsSignature_ > ForsSignature
Definition sp_types.h:72
constexpr RT checked_cast_to(AT i)
Definition int_utils.h:104
void ht_sign(StrongSpan< SphincsHypertreeSignature > out_sig, const SphincsTreeNode &message_to_sign, const SphincsSecretSeed &secret_seed, XmssTreeIndexInLayer tree_index_in_layer, TreeNodeIndex idx_leaf, const Sphincs_Parameters &params, Sphincs_Hash_Functions &hashes)
FIPS 205, Algorithm 12: ht_sign.
Sphincs_Hash_Type
bool ht_verify(const SphincsTreeNode &signed_msg, StrongSpan< const SphincsHypertreeSignature > ht_sig, const SphincsTreeNode &pk_root, XmssTreeIndexInLayer tree_index_in_layer, TreeNodeIndex idx_leaf, const Sphincs_Parameters &params, Sphincs_Hash_Functions &hashes)
FIPS 205, Algorithm 13: ht_verify.
Strong< std::vector< uint8_t >, struct SphincsXmssSignature_ > SphincsHypertreeSignature
Definition sp_types.h:66
Strong< std::vector< uint8_t >, struct SphincsInputMessage_ > SphincsInputMessage
Definition sp_types.h:49
Strong< std::vector< uint8_t >, struct SphincsPublicSeed_ > SphincsPublicSeed
Definition sp_types.h:60
Strong< secure_vector< uint8_t >, struct SphincsSecretSeed_ > SphincsSecretSeed
Definition sp_types.h:61
void require_software_provider(const OptionsT &options, std::string_view algo_name)
Strong< secure_vector< uint8_t >, struct SphincsSecretPRF_ > SphincsSecretPRF
Definition sp_types.h:62
void validate_for_hash_based_signature(const PK_Signature_Options_Reader &options, std::string_view algo_name, std::string_view hash_fn)
PublicKeyOperation
Definition pk_keys.h:50
constexpr auto concat(Rs &&... ranges)
Definition concat_util.h:95
SphincsTreeNode fors_public_key_from_signature(const SphincsHashedMessage &hashed_message, StrongSpan< const ForsSignature > signature, const Sphincs_Address &address, const Sphincs_Parameters &params, Sphincs_Hash_Functions &hashes)
FIPS 205, Algorithm 17: fors_pkFromSig.
Definition sp_fors.cpp:150
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:128
Strong< secure_vector< uint8_t >, struct SphincsOptionalRandomness_ > SphincsOptionalRandomness
Definition sp_types.h:63
constexpr auto store_be(ParamTs &&... params)
Definition loadstor.h:745
Strong< std::vector< uint8_t >, struct SphincsContext_ > SphincsContext
Definition sp_types.h:57
M' representation of FIPS 205 (the input to slh_sign_internal and slh_verify_internal).
Definition sp_types.h:52