Botan 3.0.0
Crypto and TLS for C&
tls_algos.h
Go to the documentation of this file.
1/*
2* (C) 2017 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#ifndef BOTAN_TLS_ALGO_IDS_H_
8#define BOTAN_TLS_ALGO_IDS_H_
9
10#include <botan/types.h>
11#include <botan/asn1_obj.h>
12#include <botan/pk_keys.h>
13#include <string>
14#include <vector>
15
16//BOTAN_FUTURE_INTERNAL_HEADER(tls_algos.h)
17
18namespace Botan {
19
20namespace TLS {
21
22enum class Cipher_Algo {
24
27
29
32
35
40
46
48};
49
50enum class KDF_Algo {
51 SHA_1,
52 SHA_256,
53 SHA_384,
54};
55
56std::string BOTAN_DLL kdf_algo_to_string(KDF_Algo algo);
57
58enum class Nonce_Format {
62};
63
64// TODO encoding should match signature_algorithms extension
65// TODO this should include hash etc as in TLS v1.3
66enum class Auth_Method {
67 RSA,
68 ECDSA,
69
70 // To support TLS 1.3 ciphersuites, which do not determine the auth method
72
73 // These are placed outside the encodable range
74 IMPLICIT = 0x10000
75};
76
79
80/*
81* Matches with wire encoding
82*/
83enum class Group_Params : uint16_t {
84 NONE = 0,
85
86 SECP256R1 = 23,
87 SECP384R1 = 24,
88 SECP521R1 = 25,
89 BRAINPOOL256R1 = 26,
90 BRAINPOOL384R1 = 27,
91 BRAINPOOL512R1 = 28,
92
93 X25519 = 29,
94
95 FFDHE_2048 = 256,
96 FFDHE_3072 = 257,
97 FFDHE_4096 = 258,
98 FFDHE_6144 = 259,
99 FFDHE_8192 = 260,
100};
101
102constexpr bool is_x25519(const Group_Params group)
103 {
104 return group == Group_Params::X25519;
105 }
106
107constexpr bool is_ecdh(const Group_Params group)
108 {
109 return
110 group == Group_Params::SECP256R1 ||
111 group == Group_Params::SECP384R1 ||
112 group == Group_Params::SECP521R1 ||
116 }
117
118constexpr bool is_dh(const Group_Params group)
119 {
120 return
121 group == Group_Params::FFDHE_2048 ||
122 group == Group_Params::FFDHE_3072 ||
123 group == Group_Params::FFDHE_4096 ||
124 group == Group_Params::FFDHE_6144 ||
126 }
127
128std::string group_param_to_string(Group_Params group);
129Group_Params group_param_from_string(std::string_view group_name);
131
132enum class Kex_Algo {
134 DH,
135 ECDH,
136 PSK,
137 ECDHE_PSK,
138 DHE_PSK,
139
140 // To support TLS 1.3 ciphersuites, which do not determine the kex algo
142};
143
146
148 {
149 return (m == Kex_Algo::PSK ||
150 m == Kex_Algo::ECDHE_PSK ||
151 m == Kex_Algo::DHE_PSK);
152 }
153
154}
155
156}
157
158#endif
#define BOTAN_TEST_API
Definition: compiler.h:51
#define BOTAN_DLL
Definition: build.h:62
Kex_Algo kex_method_from_string(std::string_view str)
Definition: tls_algos.cpp:52
constexpr bool is_x25519(const Group_Params group)
Definition: tls_algos.h:102
Auth_Method auth_method_from_string(std::string_view str)
Definition: tls_algos.cpp:95
std::string kdf_algo_to_string(KDF_Algo algo)
Definition: tls_algos.cpp:14
constexpr bool is_ecdh(const Group_Params group)
Definition: tls_algos.h:107
std::string kex_method_to_string(Kex_Algo method)
Definition: tls_algos.cpp:29
bool group_param_is_dh(Group_Params group)
Definition: tls_algos.cpp:109
bool key_exchange_is_psk(Kex_Algo m)
Definition: tls_algos.h:147
std::string group_param_to_string(Group_Params group)
Definition: tls_algos.cpp:146
constexpr bool is_dh(const Group_Params group)
Definition: tls_algos.h:118
std::string auth_method_to_string(Auth_Method method)
Definition: tls_algos.cpp:78
Group_Params group_param_from_string(std::string_view group_name)
Definition: tls_algos.cpp:115
Definition: alg_id.cpp:12