Botan 3.5.0
Crypto and TLS for C&
sphincsplus.h
Go to the documentation of this file.
1/*
2 * SPHINCS+ Hash based signature scheme
3 * Based on the creative commons (CC0 1.0) reference implementation by the
4 * designers (https://github.com/sphincs/sphincsplus/)
5 *
6 * (C) 2023 Jack Lloyd
7 * 2023 Fabian Albert, René Meusel, Rohde & Schwarz Cybersecurity
8 *
9 * Botan is released under the Simplified BSD License (see license.txt)
10 **/
11
12#ifndef BOTAN_SPHINCS_PLUS_H_
13#define BOTAN_SPHINCS_PLUS_H_
14
15#include <botan/pk_keys.h>
16#include <botan/sp_parameters.h>
17
18#include <memory>
19#include <vector>
20
21namespace Botan {
22
23class SphincsPlus_PublicKeyInternal;
24class SphincsPlus_PrivateKeyInternal;
25
26/**
27 * This implementation is based on
28 * https://github.com/sphincs/sphincsplus/commit/06f42f47491085ac879a72b486ca8edb10891963
29 *
30 * which implements SPHINCS+ Specification Round 3.1 (https://sphincs.org/data/sphincs+-r3.1-specification.pdf).
31 * The used tweaked hashes are implemented according to the variant 'simple' ('robust' is not supported).
32 */
34 public:
35 SphincsPlus_PublicKey(std::span<const uint8_t> pub_key, Sphincs_Parameter_Set type, Sphincs_Hash_Type hash);
36 SphincsPlus_PublicKey(std::span<const uint8_t> pub_key, Sphincs_Parameters params);
37 SphincsPlus_PublicKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits);
38
40
41 size_t key_length() const override;
42
43 std::string algo_name() const override { return "SPHINCS+"; }
44
45 size_t estimated_strength() const override;
46 AlgorithmIdentifier algorithm_identifier() const override;
47 OID object_identifier() const override;
48 bool check_key(RandomNumberGenerator& rng, bool strong) const override;
49 std::vector<uint8_t> raw_public_key_bits() const override;
50 std::vector<uint8_t> public_key_bits() const override;
51
52 std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator& rng) const final;
53
54 std::unique_ptr<PK_Ops::Verification> create_verification_op(std::string_view params,
55 std::string_view provider) const override;
56
57 std::unique_ptr<PK_Ops::Verification> create_x509_verification_op(const AlgorithmIdentifier& signature_algorithm,
58 std::string_view provider) const override;
59
60 bool supports_operation(PublicKeyOperation op) const override;
61
62 protected:
64
65 std::shared_ptr<SphincsPlus_PublicKeyInternal> m_public;
66};
67
70
72 public virtual Private_Key {
73 public:
74 SphincsPlus_PrivateKey(std::span<const uint8_t> private_key, Sphincs_Parameter_Set type, Sphincs_Hash_Type hash);
75 SphincsPlus_PrivateKey(std::span<const uint8_t> private_key, Sphincs_Parameters params);
76 SphincsPlus_PrivateKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits);
79
81
82 secure_vector<uint8_t> private_key_bits() const override;
83 secure_vector<uint8_t> raw_private_key_bits() const override;
84 std::unique_ptr<Public_Key> public_key() const override;
85
86 std::unique_ptr<PK_Ops::Signature> create_signature_op(RandomNumberGenerator& rng,
87 std::string_view params,
88 std::string_view provider) const override;
89
90 private:
91 std::shared_ptr<SphincsPlus_PrivateKeyInternal> m_private;
92};
93
95
96} // namespace Botan
97
98#endif
std::string algo_name() const override
Definition sphincsplus.h:43
std::shared_ptr< SphincsPlus_PublicKeyInternal > m_public
Definition sphincsplus.h:65
int(* final)(unsigned char *, CTX *)
#define BOTAN_DIAGNOSTIC_POP
Definition compiler.h:191
#define BOTAN_DIAGNOSTIC_PUSH
Definition compiler.h:188
#define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
Definition compiler.h:190
#define BOTAN_PUBLIC_API(maj, min)
Definition compiler.h:31
PublicKeyOperation
Definition pk_keys.h:45
Sphincs_Parameter_Set
Sphincs_Hash_Type
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:61