Botan 3.0.0-alpha0
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/types.h>
13#include <botan/asn1_obj.h>
14#include <botan/pk_keys.h>
15
16#include <optional>
17#include <string>
18
19namespace Botan::TLS {
20
21class Protocol_Version;
22
24{
25public:
26/**
27 * Matches with wire encoding
28 *
29 * Note that this is intentionally left as a bare enum. It emulates the Botan 2
30 * API where `Signature_Scheme` was an enum class with associated free-standing
31 * functions. Leaving it as a bare enum resembles the legacy user-facing API.
32 */
33enum Code : uint16_t {
34 NONE = 0x0000,
35
36 RSA_PKCS1_SHA1 = 0x0201, // not implemented
37 RSA_PKCS1_SHA256 = 0x0401,
38 RSA_PKCS1_SHA384 = 0x0501,
39 RSA_PKCS1_SHA512 = 0x0601,
40
41 ECDSA_SHA1 = 0x0203, // not implemented
42 ECDSA_SHA256 = 0x0403,
43 ECDSA_SHA384 = 0x0503,
44 ECDSA_SHA512 = 0x0603,
45
46 RSA_PSS_SHA256 = 0x0804,
47 RSA_PSS_SHA384 = 0x0805,
48 RSA_PSS_SHA512 = 0x0806,
49
50 EDDSA_25519 = 0x0807,
51 EDDSA_448 = 0x0808, // not implemented
52
53 // not implemented
54 DSA_SHA1 = 0x0202,
55 DSA_SHA256 = 0x0402,
56 DSA_SHA384 = 0x0502,
57 DSA_SHA512 = 0x0602
58};
59
60public:
61 /**
62 * @return all available signature schemes
63 */
64 static const std::vector<Signature_Scheme>& all_available_schemes();
65
66 /**
67 * Construct an uninitialized / invalid scheme
68 */
70
71 Signature_Scheme(uint16_t wire_code);
72
74
75 Signature_Scheme::Code wire_code() const noexcept { return m_code; }
76
77 /**
78 * @return true if support for this scheme is implemented in this Botan build
79 */
80 bool is_available() const noexcept;
81
82 /**
83 * @return true if the wire_code is set to any value other than `NONE`
84 */
85 bool is_set() const noexcept;
86
87 std::string to_string() const noexcept;
88 std::string hash_function_name() const noexcept;
89 std::string padding_string() const noexcept;
90 std::string algorithm_name() 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 bool operator!=(const Signature_Scheme& rhs) const { return !(*this == rhs); }
99
100private:
102};
103
104} // namespace Botan::TLS
105
106#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
@ NONE
Definition: filter.h:166
std::string to_string(ErrorType type)
Convert an ErrorType to string.
Definition: exceptn.cpp:11
Signature_Format
Definition: pk_keys.h:23
Definition: bigint.h:1077