10 #define TLS_VERSION_1 0x0301
11 #define TLS_VERSION_1_1 0x0302
12 #define TLS_VERSION_1_2 0x0303
14 #define TLS_VERSION TLS_VERSION_1_2
17 #define TLS_VERSION TLS_VERSION_1_1
19 #define TLS_VERSION TLS_VERSION_1
22 #define TLS_RANDOM_LEN 32
23 #define TLS_PRE_MASTER_SECRET_LEN 48
24 #define TLS_MASTER_SECRET_LEN 48
25 #define TLS_SESSION_ID_MAX_LEN 32
26 #define TLS_VERIFY_DATA_LEN 12
30 TLS_HANDSHAKE_TYPE_HELLO_REQUEST = 0,
31 TLS_HANDSHAKE_TYPE_CLIENT_HELLO = 1,
32 TLS_HANDSHAKE_TYPE_SERVER_HELLO = 2,
33 TLS_HANDSHAKE_TYPE_NEW_SESSION_TICKET = 4 ,
34 TLS_HANDSHAKE_TYPE_CERTIFICATE = 11,
35 TLS_HANDSHAKE_TYPE_SERVER_KEY_EXCHANGE = 12,
36 TLS_HANDSHAKE_TYPE_CERTIFICATE_REQUEST = 13,
37 TLS_HANDSHAKE_TYPE_SERVER_HELLO_DONE = 14,
38 TLS_HANDSHAKE_TYPE_CERTIFICATE_VERIFY = 15,
39 TLS_HANDSHAKE_TYPE_CLIENT_KEY_EXCHANGE = 16,
40 TLS_HANDSHAKE_TYPE_FINISHED = 20,
41 TLS_HANDSHAKE_TYPE_CERTIFICATE_URL = 21 ,
42 TLS_HANDSHAKE_TYPE_CERTIFICATE_STATUS = 22
46 #define TLS_NULL_WITH_NULL_NULL 0x0000
47 #define TLS_RSA_WITH_NULL_MD5 0x0001
48 #define TLS_RSA_WITH_NULL_SHA 0x0002
49 #define TLS_RSA_EXPORT_WITH_RC4_40_MD5 0x0003
50 #define TLS_RSA_WITH_RC4_128_MD5 0x0004
51 #define TLS_RSA_WITH_RC4_128_SHA 0x0005
52 #define TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 0x0006
53 #define TLS_RSA_WITH_IDEA_CBC_SHA 0x0007
54 #define TLS_RSA_EXPORT_WITH_DES40_CBC_SHA 0x0008
55 #define TLS_RSA_WITH_DES_CBC_SHA 0x0009
56 #define TLS_RSA_WITH_3DES_EDE_CBC_SHA 0x000A
57 #define TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA 0x000B
58 #define TLS_DH_DSS_WITH_DES_CBC_SHA 0x000C
59 #define TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA 0x000D
60 #define TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA 0x000E
61 #define TLS_DH_RSA_WITH_DES_CBC_SHA 0x000F
62 #define TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA 0x0010
63 #define TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA 0x0011
64 #define TLS_DHE_DSS_WITH_DES_CBC_SHA 0x0012
65 #define TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA 0x0013
66 #define TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA 0x0014
67 #define TLS_DHE_RSA_WITH_DES_CBC_SHA 0x0015
68 #define TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA 0x0016
69 #define TLS_DH_anon_EXPORT_WITH_RC4_40_MD5 0x0017
70 #define TLS_DH_anon_WITH_RC4_128_MD5 0x0018
71 #define TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA 0x0019
72 #define TLS_DH_anon_WITH_DES_CBC_SHA 0x001A
73 #define TLS_DH_anon_WITH_3DES_EDE_CBC_SHA 0x001B
74 #define TLS_RSA_WITH_AES_128_CBC_SHA 0x002F
75 #define TLS_DH_DSS_WITH_AES_128_CBC_SHA 0x0030
76 #define TLS_DH_RSA_WITH_AES_128_CBC_SHA 0x0031
77 #define TLS_DHE_DSS_WITH_AES_128_CBC_SHA 0x0032
78 #define TLS_DHE_RSA_WITH_AES_128_CBC_SHA 0x0033
79 #define TLS_DH_anon_WITH_AES_128_CBC_SHA 0x0034
80 #define TLS_RSA_WITH_AES_256_CBC_SHA 0x0035
81 #define TLS_DH_DSS_WITH_AES_256_CBC_SHA 0x0036
82 #define TLS_DH_RSA_WITH_AES_256_CBC_SHA 0x0037
83 #define TLS_DHE_DSS_WITH_AES_256_CBC_SHA 0x0038
84 #define TLS_DHE_RSA_WITH_AES_256_CBC_SHA 0x0039
85 #define TLS_DH_anon_WITH_AES_256_CBC_SHA 0x003A
86 #define TLS_RSA_WITH_NULL_SHA256 0x003B
87 #define TLS_RSA_WITH_AES_128_CBC_SHA256 0x003C
88 #define TLS_RSA_WITH_AES_256_CBC_SHA256 0x003D
89 #define TLS_DH_DSS_WITH_AES_128_CBC_SHA256 0x003E
90 #define TLS_DH_RSA_WITH_AES_128_CBC_SHA256 0x003F
91 #define TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 0x0040
92 #define TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 0x0067
93 #define TLS_DH_DSS_WITH_AES_256_CBC_SHA256 0x0068
94 #define TLS_DH_RSA_WITH_AES_256_CBC_SHA256 0x0069
95 #define TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 0x006A
96 #define TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 0x006B
97 #define TLS_DH_anon_WITH_AES_128_CBC_SHA256 0x006C
98 #define TLS_DH_anon_WITH_AES_256_CBC_SHA256 0x006D
101 #define TLS_COMPRESSION_NULL 0
105 TLS_HASH_ALG_NONE = 0,
106 TLS_HASH_ALG_MD5 = 1,
107 TLS_HASH_ALG_SHA1 = 2,
108 TLS_HASH_ALG_SHA224 = 3,
109 TLS_HASH_ALG_SHA256 = 4,
110 TLS_HASH_ALG_SHA384 = 5,
111 TLS_HASH_ALG_SHA512 = 6
116 TLS_SIGN_ALG_ANONYMOUS = 0,
117 TLS_SIGN_ALG_RSA = 1,
118 TLS_SIGN_ALG_DSA = 2,
119 TLS_SIGN_ALG_ECDSA = 3,
123 #define TLS_ALERT_LEVEL_WARNING 1
124 #define TLS_ALERT_LEVEL_FATAL 2
127 #define TLS_ALERT_CLOSE_NOTIFY 0
128 #define TLS_ALERT_UNEXPECTED_MESSAGE 10
129 #define TLS_ALERT_BAD_RECORD_MAC 20
130 #define TLS_ALERT_DECRYPTION_FAILED 21
131 #define TLS_ALERT_RECORD_OVERFLOW 22
132 #define TLS_ALERT_DECOMPRESSION_FAILURE 30
133 #define TLS_ALERT_HANDSHAKE_FAILURE 40
134 #define TLS_ALERT_BAD_CERTIFICATE 42
135 #define TLS_ALERT_UNSUPPORTED_CERTIFICATE 43
136 #define TLS_ALERT_CERTIFICATE_REVOKED 44
137 #define TLS_ALERT_CERTIFICATE_EXPIRED 45
138 #define TLS_ALERT_CERTIFICATE_UNKNOWN 46
139 #define TLS_ALERT_ILLEGAL_PARAMETER 47
140 #define TLS_ALERT_UNKNOWN_CA 48
141 #define TLS_ALERT_ACCESS_DENIED 49
142 #define TLS_ALERT_DECODE_ERROR 50
143 #define TLS_ALERT_DECRYPT_ERROR 51
144 #define TLS_ALERT_EXPORT_RESTRICTION 60
145 #define TLS_ALERT_PROTOCOL_VERSION 70
146 #define TLS_ALERT_INSUFFICIENT_SECURITY 71
147 #define TLS_ALERT_INTERNAL_ERROR 80
148 #define TLS_ALERT_USER_CANCELED 90
149 #define TLS_ALERT_NO_RENEGOTIATION 100
150 #define TLS_ALERT_UNSUPPORTED_EXTENSION 110
151 #define TLS_ALERT_CERTIFICATE_UNOBTAINABLE 111
152 #define TLS_ALERT_UNRECOGNIZED_NAME 112
153 #define TLS_ALERT_BAD_CERTIFICATE_STATUS_RESPONSE 113
154 #define TLS_ALERT_BAD_CERTIFICATE_HASH_VALUE 114
158 TLS_CHANGE_CIPHER_SPEC = 1
162 #define TLS_EXT_SERVER_NAME 0
163 #define TLS_EXT_MAX_FRAGMENT_LENGTH 1
164 #define TLS_EXT_CLIENT_CERTIFICATE_URL 2
165 #define TLS_EXT_TRUSTED_CA_KEYS 3
166 #define TLS_EXT_TRUNCATED_HMAC 4
167 #define TLS_EXT_STATUS_REQUEST 5
168 #define TLS_EXT_SESSION_TICKET 35
170 #define TLS_EXT_PAC_OPAQUE TLS_EXT_SESSION_TICKET
176 TLS_KEY_X_RSA_EXPORT,
177 TLS_KEY_X_DH_DSS_EXPORT,
179 TLS_KEY_X_DH_RSA_EXPORT,
181 TLS_KEY_X_DHE_DSS_EXPORT,
183 TLS_KEY_X_DHE_RSA_EXPORT,
185 TLS_KEY_X_DH_anon_EXPORT,
193 TLS_CIPHER_RC2_CBC_40,
195 TLS_CIPHER_DES40_CBC,
197 TLS_CIPHER_3DES_EDE_CBC,
198 TLS_CIPHER_AES_128_CBC,
199 TLS_CIPHER_AES_256_CBC
211 tls_key_exchange key_exchange;
223 tls_cipher_type type;
225 size_t expanded_key_material;
227 enum crypto_cipher_alg alg;
246 int tls_server_key_exchange_allowed(tls_cipher cipher);
249 void tls_verify_hash_add(
struct tls_verify_hash *verify,
const u8 *buf,
252 int tls_version_ok(u16 ver);
253 const char * tls_version_str(u16 ver);
254 int tls_prf(u16 ver,
const u8 *secret,
size_t secret_len,
const char *label,
255 const u8 *seed,
size_t seed_len, u8 *out,
size_t outlen);
256 int tlsv12_key_x_server_params_hash(u16 tls_version,
const u8 *client_random,
257 const u8 *server_random,
258 const u8 *server_params,
259 size_t server_params_len, u8 *hash);
260 int tls_key_x_server_params_hash(u16 tls_version,
const u8 *client_random,
261 const u8 *server_random,
262 const u8 *server_params,
263 size_t server_params_len, u8 *hash);
265 const u8 *data,
size_t data_len,
266 const u8 *pos,
size_t len, u8 *alert);
Definition: tlsv1_common.h:221
Definition: crypto_libtomcrypt.c:403
Wrapper functions for crypto libraries.
Definition: tlsv1_common.h:209
int tls_parse_cert(const u8 *buf, size_t len, struct crypto_public_key **pk)
Parse DER encoded X.509 certificate and get public key.
Definition: tlsv1_common.c:159
Definition: crypto_internal.c:13
const struct tls_cipher_suite * tls_get_cipher_suite(u16 suite)
Get TLS cipher suite.
Definition: tlsv1_common.c:103
Definition: tlsv1_common.h:231