Botan 3.6.1
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/pk_keys.h>
14#include <botan/types.h>
15
16#include <optional>
17#include <string>
18
19namespace Botan::TLS {
20
21class Protocol_Version;
22
24 public:
25 /**
26 * Matches with wire encoding
27 *
28 * Note that this is intentionally left as a bare enum. It emulates the Botan 2
29 * API where `Signature_Scheme` was an enum class with associated free-standing
30 * functions. Leaving it as a bare enum resembles the legacy user-facing API.
31 */
32 enum Code : uint16_t {
33 NONE = 0x0000,
34
35 RSA_PKCS1_SHA1 = 0x0201, // not implemented
36 RSA_PKCS1_SHA256 = 0x0401,
37 RSA_PKCS1_SHA384 = 0x0501,
38 RSA_PKCS1_SHA512 = 0x0601,
39
40 ECDSA_SHA1 = 0x0203, // not implemented
41 ECDSA_SHA256 = 0x0403,
42 ECDSA_SHA384 = 0x0503,
43 ECDSA_SHA512 = 0x0603,
44
45 RSA_PSS_SHA256 = 0x0804,
46 RSA_PSS_SHA384 = 0x0805,
47 RSA_PSS_SHA512 = 0x0806,
48
49 EDDSA_25519 = 0x0807,
50 EDDSA_448 = 0x0808,
51 };
52
53 public:
54 /**
55 * @return all available signature schemes
56 */
57 static const std::vector<Signature_Scheme>& all_available_schemes();
58
59 /**
60 * Construct an uninitialized / invalid scheme
61 */
63
64 Signature_Scheme(uint16_t wire_code);
65
67
68 Signature_Scheme::Code wire_code() const noexcept { return m_code; }
69
70 /**
71 * @return true if support for this scheme is implemented in this Botan build
72 */
73 bool is_available() const noexcept;
74
75 /**
76 * @return true if the wire_code is set to any value other than `NONE`
77 */
78 bool is_set() const noexcept;
79
80 std::string to_string() const noexcept;
81 std::string hash_function_name() const noexcept;
82 std::string padding_string() const noexcept;
83 std::string algorithm_name() const noexcept;
84 AlgorithmIdentifier key_algorithm_identifier() const noexcept;
85 AlgorithmIdentifier algorithm_identifier() const noexcept;
86 std::optional<Signature_Format> format() const noexcept;
87
88 bool is_compatible_with(const Protocol_Version& protocol_version) const noexcept;
89 bool is_suitable_for(const Private_Key& private_key) const noexcept;
90
91 bool operator==(const Signature_Scheme& rhs) const { return m_code == rhs.m_code; }
92
93 bool operator!=(const Signature_Scheme& rhs) const { return !(*this == rhs); }
94
95 private:
97};
98
99std::vector<AlgorithmIdentifier> to_algorithm_identifiers(const std::vector<Signature_Scheme>& schemes);
100
101} // namespace Botan::TLS
102
103#endif // BOTAN_TLS_SIGNATURE_SCHEME_H_
Signature_Scheme::Code wire_code() const noexcept
bool operator!=(const Signature_Scheme &rhs) const
#define BOTAN_PUBLIC_API(maj, min)
Definition compiler.h:31
std::vector< AlgorithmIdentifier > to_algorithm_identifiers(const std::vector< Signature_Scheme > &schemes)
@ NONE
Definition filter.h:165
Signature_Format
Definition pk_keys.h:31