Botan 3.11.0
Crypto and TLS for C&
tls_signature_scheme.h
Go to the documentation of this file.
1/*
2* TLS Signature Scheme
3* (C) 2022 Jack Lloyd
4* 2022 Hannes Rantzsch, René Meusel - neXenio GmbH
5*
6* Botan is released under the Simplified BSD License (see license.txt)
7*/
8
9#ifndef BOTAN_TLS_SIGNATURE_SCHEME_H_
10#define BOTAN_TLS_SIGNATURE_SCHEME_H_
11
12#include <botan/asn1_obj.h>
13#include <botan/types.h>
14#include <optional>
15#include <string>
16#include <vector>
17
18namespace Botan {
19
20enum class Signature_Format : uint8_t;
21class Private_Key;
22
23} // namespace Botan
24
25namespace Botan::TLS {
26
28
30 public:
31 /**
32 * Matches with wire encoding
33 *
34 * Note that this is intentionally left as a bare enum. It emulates the Botan 2
35 * API where `Signature_Scheme` was an enum class with associated free-standing
36 * functions. Leaving it as a bare enum resembles the legacy user-facing API.
37 */
38 enum Code : uint16_t /* NOLINT(*-use-enum-class) */ {
39 NONE = 0x0000,
40
41 RSA_PKCS1_SHA1 = 0x0201, // not implemented
45
46 ECDSA_SHA1 = 0x0203, // not implemented
47 ECDSA_SHA256 = 0x0403,
48 ECDSA_SHA384 = 0x0503,
49 ECDSA_SHA512 = 0x0603,
50
54
55 EDDSA_25519 = 0x0807,
56 EDDSA_448 = 0x0808,
57 };
58
59 public:
60 /**
61 * @return all available signature schemes
62 */
63 static const std::vector<Signature_Scheme>& all_available_schemes();
64
65 /**
66 * Construct an uninitialized / invalid scheme
67 */
69
70 /* NOLINT(*-explicit-conversions) */ Signature_Scheme(uint16_t wire_code);
71
72 /* NOLINT(*-explicit-conversions) */ Signature_Scheme(Signature_Scheme::Code wire_code);
73
74 Signature_Scheme::Code wire_code() const noexcept { return m_code; }
75
76 /**
77 * @return true if support for this scheme is implemented in this Botan build
78 */
79 bool is_available() const noexcept;
80
81 /**
82 * @return true if the wire_code is set to any value other than `NONE`
83 */
84 bool is_set() const noexcept;
85
86 std::string to_string() const noexcept;
87 std::string hash_function_name() const noexcept;
88 std::string padding_string() const noexcept;
89 std::string algorithm_name() const noexcept;
90 AlgorithmIdentifier key_algorithm_identifier() const noexcept;
91 AlgorithmIdentifier algorithm_identifier() const noexcept;
92 std::optional<Signature_Format> format() const noexcept;
93
94 bool is_compatible_with(const Protocol_Version& protocol_version) const noexcept;
95 bool is_suitable_for(const Private_Key& private_key) const noexcept;
96
97 bool operator==(const Signature_Scheme& rhs) const { return m_code == rhs.m_code; }
98
99 bool operator!=(const Signature_Scheme& rhs) const { return !(*this == rhs); }
100
101 private:
103};
104
105std::vector<AlgorithmIdentifier> to_algorithm_identifiers(const std::vector<Signature_Scheme>& schemes);
106
107} // namespace Botan::TLS
108
109#endif // BOTAN_TLS_SIGNATURE_SCHEME_H_
#define BOTAN_PUBLIC_API(maj, min)
Definition api.h:21
Signature_Scheme::Code wire_code() const noexcept
bool operator!=(const Signature_Scheme &rhs) const
std::vector< AlgorithmIdentifier > to_algorithm_identifiers(const std::vector< Signature_Scheme > &schemes)
Signature_Format
Definition pk_keys.h:32
std::string to_string(ErrorType type)
Convert an ErrorType to string.
Definition exceptn.cpp:13