Botan 3.4.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> public_key_bits() const override;
50
51 std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator& rng) const final;
52
53 std::unique_ptr<PK_Ops::Verification> create_verification_op(std::string_view params,
54 std::string_view provider) const override;
55
56 std::unique_ptr<PK_Ops::Verification> create_x509_verification_op(const AlgorithmIdentifier& signature_algorithm,
57 std::string_view provider) const override;
58
59 bool supports_operation(PublicKeyOperation op) const override;
60
61 protected:
63
64 std::shared_ptr<SphincsPlus_PublicKeyInternal> m_public;
65};
66
69
71 public virtual Private_Key {
72 public:
73 SphincsPlus_PrivateKey(std::span<const uint8_t> private_key, Sphincs_Parameter_Set type, Sphincs_Hash_Type hash);
74 SphincsPlus_PrivateKey(std::span<const uint8_t> private_key, Sphincs_Parameters params);
75 SphincsPlus_PrivateKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits);
78
80
81 secure_vector<uint8_t> private_key_bits() const override;
82 secure_vector<uint8_t> raw_private_key_bits() const override;
83 std::unique_ptr<Public_Key> public_key() const override;
84
85 std::unique_ptr<PK_Ops::Signature> create_signature_op(RandomNumberGenerator& rng,
86 std::string_view params,
87 std::string_view provider) const override;
88
89 private:
90 std::shared_ptr<SphincsPlus_PrivateKeyInternal> m_private;
91};
92
94
95} // namespace Botan
96
97#endif
std::string algo_name() const override
Definition sphincsplus.h:43
std::shared_ptr< SphincsPlus_PublicKeyInternal > m_public
Definition sphincsplus.h:64
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