Botan  2.9.0
Crypto and TLS for C++11
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 <string>
12 #include <vector>
13 
14 namespace Botan {
15 
16 namespace TLS {
17 
18 enum class Cipher_Algo {
20 
27 
35 
39 
44 
45  ARIA_128_GCM = 500,
47 
48  DES_EDE_CBC_HMAC_SHA1 = 1000,
50 };
51 
52 enum class KDF_Algo {
53  SHA_1,
54  SHA_256,
55  SHA_384,
56 };
57 
58 std::string BOTAN_DLL kdf_algo_to_string(KDF_Algo algo);
59 
60 enum class Nonce_Format {
61  CBC_MODE,
64 };
65 
66 // TODO encoding should match signature_algorithms extension
67 // TODO this should include hash etc as in TLS v1.3
68 enum class Auth_Method {
69  RSA,
70  DSA,
71  ECDSA,
72 
73  // These are placed outside the encodable range
74  IMPLICIT = 0x10000,
75  ANONYMOUS
76 };
77 
79 Auth_Method BOTAN_TEST_API auth_method_from_string(const std::string& str);
80 
81 /*
82 * This matches the wire encoding
83 */
84 enum class Signature_Scheme : uint16_t {
85  NONE = 0x0000,
86 
87  RSA_PKCS1_SHA1 = 0x0201,
88  RSA_PKCS1_SHA256 = 0x0401,
89  RSA_PKCS1_SHA384 = 0x0501,
90  RSA_PKCS1_SHA512 = 0x0601,
91 
92  DSA_SHA1 = 0x0202,
93  DSA_SHA256 = 0x0402,
94  DSA_SHA384 = 0x0502,
95  DSA_SHA512 = 0x0602,
96 
97  ECDSA_SHA1 = 0x0203,
98  ECDSA_SHA256 = 0x0403,
99  ECDSA_SHA384 = 0x0503,
100  ECDSA_SHA512 = 0x0603,
101 
102  RSA_PSS_SHA256 = 0x0804,
103  RSA_PSS_SHA384 = 0x0805,
104  RSA_PSS_SHA512 = 0x0806,
105 
106  EDDSA_25519 = 0x0807,
107  EDDSA_448 = 0x0808,
108 };
109 
110 BOTAN_UNSTABLE_API const std::vector<Signature_Scheme>& all_signature_schemes();
111 
114 std::string hash_function_of_scheme(Signature_Scheme scheme);
115 std::string padding_string_for_scheme(Signature_Scheme scheme);
117 
118 /*
119 * Matches with wire encoding
120 */
121 enum class Group_Params : uint16_t {
122  NONE = 0,
123 
124  SECP256R1 = 23,
125  SECP384R1 = 24,
126  SECP521R1 = 25,
127  BRAINPOOL256R1 = 26,
128  BRAINPOOL384R1 = 27,
129  BRAINPOOL512R1 = 28,
130 
131  X25519 = 29,
132 
133  FFDHE_2048 = 256,
134  FFDHE_3072 = 257,
135  FFDHE_4096 = 258,
136  FFDHE_6144 = 259,
137  FFDHE_8192 = 260,
138 };
139 
140 std::string group_param_to_string(Group_Params group);
141 Group_Params group_param_from_string(const std::string& group_name);
142 bool group_param_is_dh(Group_Params group);
143 
144 enum class Kex_Algo {
145  STATIC_RSA,
146  DH,
147  ECDH,
148  CECPQ1,
149  SRP_SHA,
150  PSK,
151  DHE_PSK,
152  ECDHE_PSK,
153 };
154 
155 std::string BOTAN_TEST_API kex_method_to_string(Kex_Algo method);
156 Kex_Algo BOTAN_TEST_API kex_method_from_string(const std::string& str);
157 
159  {
160  return (m == Kex_Algo::PSK ||
161  m == Kex_Algo::DHE_PSK ||
162  m == Kex_Algo::ECDHE_PSK);
163  }
164 
165 }
166 
167 }
168 
169 #endif
Auth_Method auth_method_from_string(const std::string &str)
Definition: tls_algos.cpp:102
#define BOTAN_UNSTABLE_API
Definition: compiler.h:38
std::string padding_string_for_scheme(Signature_Scheme scheme)
Definition: tls_algos.cpp:379
std::string sig_scheme_to_string(Signature_Scheme scheme)
Definition: tls_algos.cpp:329
std::string hash_function_of_scheme(Signature_Scheme scheme)
Definition: tls_algos.cpp:191
bool group_param_is_dh(Group_Params group)
Definition: tls_algos.cpp:118
bool key_exchange_is_psk(Kex_Algo m)
Definition: tls_algos.h:158
Signature_Scheme
Definition: tls_algos.h:84
std::string group_param_to_string(Group_Params group)
Definition: tls_algos.cpp:155
std::string kex_method_to_string(Kex_Algo method)
Definition: tls_algos.cpp:29
#define BOTAN_TEST_API
Definition: compiler.h:45
Definition: alg_id.cpp:13
const std::vector< Signature_Scheme > & all_signature_schemes()
Definition: tls_algos.cpp:229
std::string auth_method_to_string(Auth_Method method)
Definition: tls_algos.cpp:83
std::string signature_algorithm_of_scheme(Signature_Scheme scheme)
Definition: tls_algos.cpp:291
std::string kdf_algo_to_string(KDF_Algo algo)
Definition: tls_algos.cpp:14
bool signature_scheme_is_known(Signature_Scheme scheme)
Definition: tls_algos.cpp:262
Group_Params group_param_from_string(const std::string &group_name)
Definition: tls_algos.cpp:124
Kex_Algo kex_method_from_string(const std::string &str)
Definition: tls_algos.cpp:54