blob: 71596897c8923e9449be81d10ead87472d1de281 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
/*
* TLS Cipher Suites
* (C) 2004-2011,2012 Jack Lloyd
* 2016 Matthias Gierlings
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
#ifndef BOTAN_TLS_CIPHER_SUITES_H__
#define BOTAN_TLS_CIPHER_SUITES_H__
#include <botan/types.h>
#include <string>
#include <vector>
namespace Botan {
namespace TLS {
/**
* Ciphersuite Information
*/
class BOTAN_DLL Ciphersuite
{
public:
/**
* Convert an SSL/TLS ciphersuite to algorithm fields
* @param suite the ciphersuite code number
* @return ciphersuite object
*/
static Ciphersuite by_id(u16bit suite);
static std::vector<u16bit> all_known_ciphersuite_ids();
/*
* Returns the compiled in list of cipher suites.
*/
static const std::vector<Ciphersuite>& all_cipher_suites();
/**
* Returns true iff this suite is a known SCSV
*/
static bool is_scsv(u16bit suite);
/**
* Generate a static list of all known ciphersuites and return it.
*
* @return list of all known ciphersuites
*/
static const std::vector<Ciphersuite>& all_known_ciphersuites();
/**
* Formats the ciphersuite back to an RFC-style ciphersuite string
* @return RFC ciphersuite string identifier
*/
std::string to_string() const { return m_iana_id; }
/**
* @return ciphersuite number
*/
u16bit ciphersuite_code() const { return m_ciphersuite_code; }
/**
* @return true if this is a PSK ciphersuite
*/
bool psk_ciphersuite() const;
/**
* @return true if this is an ECC ciphersuite
*/
bool ecc_ciphersuite() const;
/**
* @return key exchange algorithm used by this ciphersuite
*/
std::string kex_algo() const { return m_kex_algo; }
/**
* @return signature algorithm used by this ciphersuite
*/
std::string sig_algo() const { return m_sig_algo; }
/**
* @return symmetric cipher algorithm used by this ciphersuite
*/
std::string cipher_algo() const { return m_cipher_algo; }
/**
* @return message authentication algorithm used by this ciphersuite
*/
std::string mac_algo() const { return m_mac_algo; }
std::string prf_algo() const
{
if(m_prf_algo && *m_prf_algo)
return m_prf_algo;
return m_mac_algo;
}
/**
* @return cipher key length used by this ciphersuite
*/
size_t cipher_keylen() const { return m_cipher_keylen; }
size_t nonce_bytes_from_record() const { return m_nonce_bytes_from_record; }
size_t nonce_bytes_from_handshake() const { return m_nonce_bytes_from_handshake; }
size_t mac_keylen() const { return m_mac_keylen; }
/**
* @return true if this is a valid/known ciphersuite
*/
bool valid() const;
Ciphersuite() {}
private:
Ciphersuite(u16bit ciphersuite_code,
const char* iana_id,
const char* sig_algo,
const char* kex_algo,
const char* cipher_algo,
size_t cipher_keylen,
size_t nonce_bytes_from_handshake,
size_t nonce_bytes_from_record,
const char* mac_algo,
size_t mac_keylen,
const char* prf_algo = "");
u16bit m_ciphersuite_code = 0;
/*
All of these const char* strings are references to compile time
constants in tls_suite_info.cpp
*/
const char* m_iana_id;
const char* m_sig_algo;
const char* m_kex_algo;
const char* m_prf_algo;
const char* m_cipher_algo;
const char* m_mac_algo;
size_t m_cipher_keylen = 0;
size_t m_nonce_bytes_from_handshake = 0;
size_t m_nonce_bytes_from_record = 0;
size_t m_mac_keylen = 0;
};
}
}
#endif
|