mbed TLS v2.8.0
ssl.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
8  * SPDX-License-Identifier: Apache-2.0
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License"); you may
11  * not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  * This file is part of mbed TLS (https://tls.mbed.org)
23  */
24 #ifndef MBEDTLS_SSL_H
25 #define MBEDTLS_SSL_H
26 
27 #if !defined(MBEDTLS_CONFIG_FILE)
28 #include "config.h"
29 #else
30 #include MBEDTLS_CONFIG_FILE
31 #endif
32 
33 #include "bignum.h"
34 #include "ecp.h"
35 
36 #include "ssl_ciphersuites.h"
37 
38 #if defined(MBEDTLS_X509_CRT_PARSE_C)
39 #include "x509_crt.h"
40 #include "x509_crl.h"
41 #endif
42 
43 #if defined(MBEDTLS_DHM_C)
44 #include "dhm.h"
45 #endif
46 
47 #if defined(MBEDTLS_ECDH_C)
48 #include "ecdh.h"
49 #endif
50 
51 #if defined(MBEDTLS_ZLIB_SUPPORT)
52 
53 #if defined(MBEDTLS_DEPRECATED_WARNING)
54 #warning "Record compression support via MBEDTLS_ZLIB_SUPPORT is deprecated and will be removed in the next major revision of the library"
55 #endif
56 
57 #if defined(MBEDTLS_DEPRECATED_REMOVED)
58 #error "Record compression support via MBEDTLS_ZLIB_SUPPORT is deprecated and cannot be used if MBEDTLS_DEPRECATED_REMOVED is set"
59 #endif
60 
61 #include "zlib.h"
62 #endif
63 
64 #if defined(MBEDTLS_HAVE_TIME)
65 #include "mbedtls/platform_time.h"
66 #endif
67 
68 /*
69  * SSL Error codes
70  */
71 #define MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE -0x7080
72 #define MBEDTLS_ERR_SSL_BAD_INPUT_DATA -0x7100
73 #define MBEDTLS_ERR_SSL_INVALID_MAC -0x7180
74 #define MBEDTLS_ERR_SSL_INVALID_RECORD -0x7200
75 #define MBEDTLS_ERR_SSL_CONN_EOF -0x7280
76 #define MBEDTLS_ERR_SSL_UNKNOWN_CIPHER -0x7300
77 #define MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN -0x7380
78 #define MBEDTLS_ERR_SSL_NO_RNG -0x7400
79 #define MBEDTLS_ERR_SSL_NO_CLIENT_CERTIFICATE -0x7480
80 #define MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE -0x7500
81 #define MBEDTLS_ERR_SSL_CERTIFICATE_REQUIRED -0x7580
82 #define MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED -0x7600
83 #define MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED -0x7680
84 #define MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE -0x7700
85 #define MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE -0x7780
86 #define MBEDTLS_ERR_SSL_PEER_VERIFY_FAILED -0x7800
87 #define MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY -0x7880
88 #define MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO -0x7900
89 #define MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO -0x7980
90 #define MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE -0x7A00
91 #define MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST -0x7A80
92 #define MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE -0x7B00
93 #define MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO_DONE -0x7B80
94 #define MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE -0x7C00
95 #define MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP -0x7C80
96 #define MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS -0x7D00
97 #define MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY -0x7D80
98 #define MBEDTLS_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC -0x7E00
99 #define MBEDTLS_ERR_SSL_BAD_HS_FINISHED -0x7E80
100 #define MBEDTLS_ERR_SSL_ALLOC_FAILED -0x7F00
101 #define MBEDTLS_ERR_SSL_HW_ACCEL_FAILED -0x7F80
102 #define MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH -0x6F80
103 #define MBEDTLS_ERR_SSL_COMPRESSION_FAILED -0x6F00
104 #define MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION -0x6E80
105 #define MBEDTLS_ERR_SSL_BAD_HS_NEW_SESSION_TICKET -0x6E00
106 #define MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED -0x6D80
107 #define MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH -0x6D00
108 #define MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY -0x6C80
109 #define MBEDTLS_ERR_SSL_INTERNAL_ERROR -0x6C00
110 #define MBEDTLS_ERR_SSL_COUNTER_WRAPPING -0x6B80
111 #define MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO -0x6B00
112 #define MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED -0x6A80
113 #define MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL -0x6A00
114 #define MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE -0x6980
115 #define MBEDTLS_ERR_SSL_WANT_READ -0x6900
116 #define MBEDTLS_ERR_SSL_WANT_WRITE -0x6880
117 #define MBEDTLS_ERR_SSL_TIMEOUT -0x6800
118 #define MBEDTLS_ERR_SSL_CLIENT_RECONNECT -0x6780
119 #define MBEDTLS_ERR_SSL_UNEXPECTED_RECORD -0x6700
120 #define MBEDTLS_ERR_SSL_NON_FATAL -0x6680
121 #define MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH -0x6600
123 /*
124  * Various constants
125  */
126 #define MBEDTLS_SSL_MAJOR_VERSION_3 3
127 #define MBEDTLS_SSL_MINOR_VERSION_0 0
128 #define MBEDTLS_SSL_MINOR_VERSION_1 1
129 #define MBEDTLS_SSL_MINOR_VERSION_2 2
130 #define MBEDTLS_SSL_MINOR_VERSION_3 3
132 #define MBEDTLS_SSL_TRANSPORT_STREAM 0
133 #define MBEDTLS_SSL_TRANSPORT_DATAGRAM 1
135 #define MBEDTLS_SSL_MAX_HOST_NAME_LEN 255
137 /* RFC 6066 section 4, see also mfl_code_to_length in ssl_tls.c
138  * NONE must be zero so that memset()ing structure to zero works */
139 #define MBEDTLS_SSL_MAX_FRAG_LEN_NONE 0
140 #define MBEDTLS_SSL_MAX_FRAG_LEN_512 1
141 #define MBEDTLS_SSL_MAX_FRAG_LEN_1024 2
142 #define MBEDTLS_SSL_MAX_FRAG_LEN_2048 3
143 #define MBEDTLS_SSL_MAX_FRAG_LEN_4096 4
144 #define MBEDTLS_SSL_MAX_FRAG_LEN_INVALID 5
146 #define MBEDTLS_SSL_IS_CLIENT 0
147 #define MBEDTLS_SSL_IS_SERVER 1
148 
149 #define MBEDTLS_SSL_IS_NOT_FALLBACK 0
150 #define MBEDTLS_SSL_IS_FALLBACK 1
151 
152 #define MBEDTLS_SSL_EXTENDED_MS_DISABLED 0
153 #define MBEDTLS_SSL_EXTENDED_MS_ENABLED 1
154 
155 #define MBEDTLS_SSL_ETM_DISABLED 0
156 #define MBEDTLS_SSL_ETM_ENABLED 1
157 
158 #define MBEDTLS_SSL_COMPRESS_NULL 0
159 #define MBEDTLS_SSL_COMPRESS_DEFLATE 1
160 
161 #define MBEDTLS_SSL_VERIFY_NONE 0
162 #define MBEDTLS_SSL_VERIFY_OPTIONAL 1
163 #define MBEDTLS_SSL_VERIFY_REQUIRED 2
164 #define MBEDTLS_SSL_VERIFY_UNSET 3 /* Used only for sni_authmode */
165 
166 #define MBEDTLS_SSL_LEGACY_RENEGOTIATION 0
167 #define MBEDTLS_SSL_SECURE_RENEGOTIATION 1
168 
169 #define MBEDTLS_SSL_RENEGOTIATION_DISABLED 0
170 #define MBEDTLS_SSL_RENEGOTIATION_ENABLED 1
171 
172 #define MBEDTLS_SSL_ANTI_REPLAY_DISABLED 0
173 #define MBEDTLS_SSL_ANTI_REPLAY_ENABLED 1
174 
175 #define MBEDTLS_SSL_RENEGOTIATION_NOT_ENFORCED -1
176 #define MBEDTLS_SSL_RENEGO_MAX_RECORDS_DEFAULT 16
177 
178 #define MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION 0
179 #define MBEDTLS_SSL_LEGACY_ALLOW_RENEGOTIATION 1
180 #define MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE 2
181 
182 #define MBEDTLS_SSL_TRUNC_HMAC_DISABLED 0
183 #define MBEDTLS_SSL_TRUNC_HMAC_ENABLED 1
184 #define MBEDTLS_SSL_TRUNCATED_HMAC_LEN 10 /* 80 bits, rfc 6066 section 7 */
185 
186 #define MBEDTLS_SSL_SESSION_TICKETS_DISABLED 0
187 #define MBEDTLS_SSL_SESSION_TICKETS_ENABLED 1
188 
189 #define MBEDTLS_SSL_CBC_RECORD_SPLITTING_DISABLED 0
190 #define MBEDTLS_SSL_CBC_RECORD_SPLITTING_ENABLED 1
191 
192 #define MBEDTLS_SSL_ARC4_ENABLED 0
193 #define MBEDTLS_SSL_ARC4_DISABLED 1
194 
195 #define MBEDTLS_SSL_PRESET_DEFAULT 0
196 #define MBEDTLS_SSL_PRESET_SUITEB 2
197 
198 #define MBEDTLS_SSL_CERT_REQ_CA_LIST_ENABLED 1
199 #define MBEDTLS_SSL_CERT_REQ_CA_LIST_DISABLED 0
200 
201 /*
202  * Default range for DTLS retransmission timer value, in milliseconds.
203  * RFC 6347 4.2.4.1 says from 1 second to 60 seconds.
204  */
205 #define MBEDTLS_SSL_DTLS_TIMEOUT_DFL_MIN 1000
206 #define MBEDTLS_SSL_DTLS_TIMEOUT_DFL_MAX 60000
207 
216 #if !defined(MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME)
217 #define MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME 86400
218 #endif
219 
220 /*
221  * Maxium fragment length in bytes,
222  * determines the size of each of the two internal I/O buffers.
223  *
224  * Note: the RFC defines the default size of SSL / TLS messages. If you
225  * change the value here, other clients / servers may not be able to
226  * communicate with you anymore. Only change this value if you control
227  * both sides of the connection and have it reduced at both sides, or
228  * if you're using the Max Fragment Length extension and you know all your
229  * peers are using it too!
230  */
231 #if !defined(MBEDTLS_SSL_MAX_CONTENT_LEN)
232 #define MBEDTLS_SSL_MAX_CONTENT_LEN 16384
233 #endif
234 
235 /* \} name SECTION: Module settings */
236 
237 /*
238  * Length of the verify data for secure renegotiation
239  */
240 #if defined(MBEDTLS_SSL_PROTO_SSL3)
241 #define MBEDTLS_SSL_VERIFY_DATA_MAX_LEN 36
242 #else
243 #define MBEDTLS_SSL_VERIFY_DATA_MAX_LEN 12
244 #endif
245 
246 /*
247  * Signaling ciphersuite values (SCSV)
248  */
249 #define MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO 0xFF
250 #define MBEDTLS_SSL_FALLBACK_SCSV_VALUE 0x5600
252 /*
253  * Supported Signature and Hash algorithms (For TLS 1.2)
254  * RFC 5246 section 7.4.1.4.1
255  */
256 #define MBEDTLS_SSL_HASH_NONE 0
257 #define MBEDTLS_SSL_HASH_MD5 1
258 #define MBEDTLS_SSL_HASH_SHA1 2
259 #define MBEDTLS_SSL_HASH_SHA224 3
260 #define MBEDTLS_SSL_HASH_SHA256 4
261 #define MBEDTLS_SSL_HASH_SHA384 5
262 #define MBEDTLS_SSL_HASH_SHA512 6
263 
264 #define MBEDTLS_SSL_SIG_ANON 0
265 #define MBEDTLS_SSL_SIG_RSA 1
266 #define MBEDTLS_SSL_SIG_ECDSA 3
267 
268 /*
269  * Client Certificate Types
270  * RFC 5246 section 7.4.4 plus RFC 4492 section 5.5
271  */
272 #define MBEDTLS_SSL_CERT_TYPE_RSA_SIGN 1
273 #define MBEDTLS_SSL_CERT_TYPE_ECDSA_SIGN 64
274 
275 /*
276  * Message, alert and handshake types
277  */
278 #define MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC 20
279 #define MBEDTLS_SSL_MSG_ALERT 21
280 #define MBEDTLS_SSL_MSG_HANDSHAKE 22
281 #define MBEDTLS_SSL_MSG_APPLICATION_DATA 23
282 
283 #define MBEDTLS_SSL_ALERT_LEVEL_WARNING 1
284 #define MBEDTLS_SSL_ALERT_LEVEL_FATAL 2
285 
286 #define MBEDTLS_SSL_ALERT_MSG_CLOSE_NOTIFY 0 /* 0x00 */
287 #define MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE 10 /* 0x0A */
288 #define MBEDTLS_SSL_ALERT_MSG_BAD_RECORD_MAC 20 /* 0x14 */
289 #define MBEDTLS_SSL_ALERT_MSG_DECRYPTION_FAILED 21 /* 0x15 */
290 #define MBEDTLS_SSL_ALERT_MSG_RECORD_OVERFLOW 22 /* 0x16 */
291 #define MBEDTLS_SSL_ALERT_MSG_DECOMPRESSION_FAILURE 30 /* 0x1E */
292 #define MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE 40 /* 0x28 */
293 #define MBEDTLS_SSL_ALERT_MSG_NO_CERT 41 /* 0x29 */
294 #define MBEDTLS_SSL_ALERT_MSG_BAD_CERT 42 /* 0x2A */
295 #define MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT 43 /* 0x2B */
296 #define MBEDTLS_SSL_ALERT_MSG_CERT_REVOKED 44 /* 0x2C */
297 #define MBEDTLS_SSL_ALERT_MSG_CERT_EXPIRED 45 /* 0x2D */
298 #define MBEDTLS_SSL_ALERT_MSG_CERT_UNKNOWN 46 /* 0x2E */
299 #define MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER 47 /* 0x2F */
300 #define MBEDTLS_SSL_ALERT_MSG_UNKNOWN_CA 48 /* 0x30 */
301 #define MBEDTLS_SSL_ALERT_MSG_ACCESS_DENIED 49 /* 0x31 */
302 #define MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR 50 /* 0x32 */
303 #define MBEDTLS_SSL_ALERT_MSG_DECRYPT_ERROR 51 /* 0x33 */
304 #define MBEDTLS_SSL_ALERT_MSG_EXPORT_RESTRICTION 60 /* 0x3C */
305 #define MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION 70 /* 0x46 */
306 #define MBEDTLS_SSL_ALERT_MSG_INSUFFICIENT_SECURITY 71 /* 0x47 */
307 #define MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR 80 /* 0x50 */
308 #define MBEDTLS_SSL_ALERT_MSG_INAPROPRIATE_FALLBACK 86 /* 0x56 */
309 #define MBEDTLS_SSL_ALERT_MSG_USER_CANCELED 90 /* 0x5A */
310 #define MBEDTLS_SSL_ALERT_MSG_NO_RENEGOTIATION 100 /* 0x64 */
311 #define MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_EXT 110 /* 0x6E */
312 #define MBEDTLS_SSL_ALERT_MSG_UNRECOGNIZED_NAME 112 /* 0x70 */
313 #define MBEDTLS_SSL_ALERT_MSG_UNKNOWN_PSK_IDENTITY 115 /* 0x73 */
314 #define MBEDTLS_SSL_ALERT_MSG_NO_APPLICATION_PROTOCOL 120 /* 0x78 */
315 
316 #define MBEDTLS_SSL_HS_HELLO_REQUEST 0
317 #define MBEDTLS_SSL_HS_CLIENT_HELLO 1
318 #define MBEDTLS_SSL_HS_SERVER_HELLO 2
319 #define MBEDTLS_SSL_HS_HELLO_VERIFY_REQUEST 3
320 #define MBEDTLS_SSL_HS_NEW_SESSION_TICKET 4
321 #define MBEDTLS_SSL_HS_CERTIFICATE 11
322 #define MBEDTLS_SSL_HS_SERVER_KEY_EXCHANGE 12
323 #define MBEDTLS_SSL_HS_CERTIFICATE_REQUEST 13
324 #define MBEDTLS_SSL_HS_SERVER_HELLO_DONE 14
325 #define MBEDTLS_SSL_HS_CERTIFICATE_VERIFY 15
326 #define MBEDTLS_SSL_HS_CLIENT_KEY_EXCHANGE 16
327 #define MBEDTLS_SSL_HS_FINISHED 20
328 
329 /*
330  * TLS extensions
331  */
332 #define MBEDTLS_TLS_EXT_SERVERNAME 0
333 #define MBEDTLS_TLS_EXT_SERVERNAME_HOSTNAME 0
334 
335 #define MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH 1
336 
337 #define MBEDTLS_TLS_EXT_TRUNCATED_HMAC 4
338 
339 #define MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES 10
340 #define MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS 11
341 
342 #define MBEDTLS_TLS_EXT_SIG_ALG 13
343 
344 #define MBEDTLS_TLS_EXT_ALPN 16
345 
346 #define MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC 22 /* 0x16 */
347 #define MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET 0x0017 /* 23 */
348 
349 #define MBEDTLS_TLS_EXT_SESSION_TICKET 35
350 
351 #define MBEDTLS_TLS_EXT_ECJPAKE_KKPP 256 /* experimental */
352 
353 #define MBEDTLS_TLS_EXT_RENEGOTIATION_INFO 0xFF01
354 
355 /*
356  * Size defines
357  */
358 #if !defined(MBEDTLS_PSK_MAX_LEN)
359 #define MBEDTLS_PSK_MAX_LEN 32 /* 256 bits */
360 #endif
361 
362 /* Dummy type used only for its size */
364 {
365 #if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED)
366  unsigned char _pms_rsa[48]; /* RFC 5246 8.1.1 */
367 #endif
368 #if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED)
369  unsigned char _pms_dhm[MBEDTLS_MPI_MAX_SIZE]; /* RFC 5246 8.1.2 */
370 #endif
371 #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
372  defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \
373  defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \
374  defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)
375  unsigned char _pms_ecdh[MBEDTLS_ECP_MAX_BYTES]; /* RFC 4492 5.10 */
376 #endif
377 #if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED)
378  unsigned char _pms_psk[4 + 2 * MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 2 */
379 #endif
380 #if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED)
381  unsigned char _pms_dhe_psk[4 + MBEDTLS_MPI_MAX_SIZE
382  + MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 3 */
383 #endif
384 #if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED)
385  unsigned char _pms_rsa_psk[52 + MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 4 */
386 #endif
387 #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED)
388  unsigned char _pms_ecdhe_psk[4 + MBEDTLS_ECP_MAX_BYTES
389  + MBEDTLS_PSK_MAX_LEN]; /* RFC 5489 2 */
390 #endif
391 #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
392  unsigned char _pms_ecjpake[32]; /* Thread spec: SHA-256 output */
393 #endif
394 };
395 
396 #define MBEDTLS_PREMASTER_SIZE sizeof( union mbedtls_ssl_premaster_secret )
397 
398 #ifdef __cplusplus
399 extern "C" {
400 #endif
401 
402 /*
403  * SSL state machine
404  */
405 typedef enum
406 {
426 }
428 
446 typedef int mbedtls_ssl_send_t( void *ctx,
447  const unsigned char *buf,
448  size_t len );
449 
469 typedef int mbedtls_ssl_recv_t( void *ctx,
470  unsigned char *buf,
471  size_t len );
472 
495 typedef int mbedtls_ssl_recv_timeout_t( void *ctx,
496  unsigned char *buf,
497  size_t len,
498  uint32_t timeout );
521 typedef void mbedtls_ssl_set_timer_t( void * ctx,
522  uint32_t int_ms,
523  uint32_t fin_ms );
524 
536 typedef int mbedtls_ssl_get_timer_t( void * ctx );
537 
538 
539 /* Defined below */
543 
544 /* Defined in ssl_internal.h */
548 #if defined(MBEDTLS_X509_CRT_PARSE_C)
550 #endif
551 #if defined(MBEDTLS_SSL_PROTO_DTLS)
553 #endif
554 
555 /*
556  * This structure is used for storing current session data.
557  */
559 {
560 #if defined(MBEDTLS_HAVE_TIME)
562 #endif
565  size_t id_len;
566  unsigned char id[32];
567  unsigned char master[48];
569 #if defined(MBEDTLS_X509_CRT_PARSE_C)
571 #endif /* MBEDTLS_X509_CRT_PARSE_C */
572  uint32_t verify_result;
574 #if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_CLI_C)
575  unsigned char *ticket;
576  size_t ticket_len;
577  uint32_t ticket_lifetime;
578 #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_CLI_C */
579 
580 #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
581  unsigned char mfl_code;
582 #endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
583 
584 #if defined(MBEDTLS_SSL_TRUNCATED_HMAC)
586 #endif /* MBEDTLS_SSL_TRUNCATED_HMAC */
587 
588 #if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
590 #endif
591 };
592 
597 {
598  /* Group items by size (largest first) to minimize padding overhead */
599 
600  /*
601  * Pointers
602  */
603 
604  const int *ciphersuite_list[4];
607  void (*f_dbg)(void *, int, const char *, int, const char *);
608  void *p_dbg;
611  int (*f_rng)(void *, unsigned char *, size_t);
612  void *p_rng;
615  int (*f_get_cache)(void *, mbedtls_ssl_session *);
617  int (*f_set_cache)(void *, const mbedtls_ssl_session *);
618  void *p_cache;
620 #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
621 
622  int (*f_sni)(void *, mbedtls_ssl_context *, const unsigned char *, size_t);
623  void *p_sni;
624 #endif
625 
626 #if defined(MBEDTLS_X509_CRT_PARSE_C)
627 
628  int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *);
629  void *p_vrfy;
630 #endif
631 
632 #if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED)
633 
634  int (*f_psk)(void *, mbedtls_ssl_context *, const unsigned char *, size_t);
635  void *p_psk;
636 #endif
637 
638 #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C)
639 
640  int (*f_cookie_write)( void *, unsigned char **, unsigned char *,
641  const unsigned char *, size_t );
643  int (*f_cookie_check)( void *, const unsigned char *, size_t,
644  const unsigned char *, size_t );
645  void *p_cookie;
646 #endif
647 
648 #if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_SRV_C)
649 
650  int (*f_ticket_write)( void *, const mbedtls_ssl_session *,
651  unsigned char *, const unsigned char *, size_t *, uint32_t * );
653  int (*f_ticket_parse)( void *, mbedtls_ssl_session *, unsigned char *, size_t);
654  void *p_ticket;
655 #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_SRV_C */
656 
657 #if defined(MBEDTLS_SSL_EXPORT_KEYS)
658 
659  int (*f_export_keys)( void *, const unsigned char *,
660  const unsigned char *, size_t, size_t, size_t );
662 #endif
663 
664 #if defined(MBEDTLS_X509_CRT_PARSE_C)
667  mbedtls_x509_crt *ca_chain;
669 #endif /* MBEDTLS_X509_CRT_PARSE_C */
670 
671 #if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED)
672  const int *sig_hashes;
673 #endif
674 
675 #if defined(MBEDTLS_ECP_C)
677 #endif
678 
679 #if defined(MBEDTLS_DHM_C)
682 #endif
683 
684 #if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED)
685  unsigned char *psk;
686  size_t psk_len;
687  unsigned char *psk_identity;
689 #endif
690 
691 #if defined(MBEDTLS_SSL_ALPN)
692  const char **alpn_list;
693 #endif
694 
695  /*
696  * Numerical settings (int then char)
697  */
698 
699  uint32_t read_timeout;
701 #if defined(MBEDTLS_SSL_PROTO_DTLS)
702  uint32_t hs_timeout_min;
704  uint32_t hs_timeout_max;
706 #endif
707 
708 #if defined(MBEDTLS_SSL_RENEGOTIATION)
710  unsigned char renego_period[8];
712 #endif
713 
714 #if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT)
715  unsigned int badmac_limit;
716 #endif
717 
718 #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C)
719  unsigned int dhm_min_bitlen;
720 #endif
721 
722  unsigned char max_major_ver;
723  unsigned char max_minor_ver;
724  unsigned char min_major_ver;
725  unsigned char min_minor_ver;
727  /*
728  * Flags (bitfields)
729  */
730 
731  unsigned int endpoint : 1;
732  unsigned int transport : 1;
733  unsigned int authmode : 2;
734  /* needed even with renego disabled for LEGACY_BREAK_HANDSHAKE */
735  unsigned int allow_legacy_renegotiation : 2 ;
736 #if defined(MBEDTLS_ARC4_C)
737  unsigned int arc4_disabled : 1;
738 #endif
739 #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
740  unsigned int mfl_code : 3;
741 #endif
742 #if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
743  unsigned int encrypt_then_mac : 1 ;
744 #endif
745 #if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET)
746  unsigned int extended_ms : 1;
747 #endif
748 #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)
749  unsigned int anti_replay : 1;
750 #endif
751 #if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING)
752  unsigned int cbc_record_splitting : 1;
753 #endif
754 #if defined(MBEDTLS_SSL_RENEGOTIATION)
755  unsigned int disable_renegotiation : 1;
756 #endif
757 #if defined(MBEDTLS_SSL_TRUNCATED_HMAC)
758  unsigned int trunc_hmac : 1;
759 #endif
760 #if defined(MBEDTLS_SSL_SESSION_TICKETS)
761  unsigned int session_tickets : 1;
762 #endif
763 #if defined(MBEDTLS_SSL_FALLBACK_SCSV) && defined(MBEDTLS_SSL_CLI_C)
764  unsigned int fallback : 1;
765 #endif
766 #if defined(MBEDTLS_SSL_SRV_C)
767  unsigned int cert_req_ca_list : 1;
769 #endif
770 };
771 
772 
774 {
777  /*
778  * Miscellaneous
779  */
780  int state;
781 #if defined(MBEDTLS_SSL_RENEGOTIATION)
786 #endif
787 
788  int major_ver;
789  int minor_ver;
791 #if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT)
792  unsigned badmac_seen;
793 #endif
794 
800  void *p_bio;
802  /*
803  * Session layer
804  */
813  /*
814  * Record layer transformations
815  */
821  /*
822  * Timers
823  */
824  void *p_timer;
829  /*
830  * Record layer (incoming data)
831  */
832  unsigned char *in_buf;
833  unsigned char *in_ctr;
836  unsigned char *in_hdr;
837  unsigned char *in_len;
838  unsigned char *in_iv;
839  unsigned char *in_msg;
840  unsigned char *in_offt;
843  size_t in_msglen;
844  size_t in_left;
845 #if defined(MBEDTLS_SSL_PROTO_DTLS)
846  uint16_t in_epoch;
849 #endif
850 #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)
851  uint64_t in_window_top;
852  uint64_t in_window;
853 #endif
854 
855  size_t in_hslen;
857  int nb_zero;
862  /*
863  * Record layer (outgoing data)
864  */
865  unsigned char *out_buf;
866  unsigned char *out_ctr;
867  unsigned char *out_hdr;
868  unsigned char *out_len;
869  unsigned char *out_iv;
870  unsigned char *out_msg;
873  size_t out_msglen;
874  size_t out_left;
876 #if defined(MBEDTLS_ZLIB_SUPPORT)
877  unsigned char *compress_buf;
878 #endif
879 #if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING)
880  signed char split_done;
881 #endif
882 
883  /*
884  * PKI layer
885  */
888  /*
889  * User settings
890  */
891 #if defined(MBEDTLS_X509_CRT_PARSE_C)
892  char *hostname;
894 #endif
895 
896 #if defined(MBEDTLS_SSL_ALPN)
897  const char *alpn_chosen;
898 #endif
899 
900  /*
901  * Information for DTLS hello verify
902  */
903 #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C)
904  unsigned char *cli_id;
905  size_t cli_id_len;
906 #endif
907 
908  /*
909  * Secure renegotiation
910  */
911  /* needed to know when to send extension on server */
914 #if defined(MBEDTLS_SSL_RENEGOTIATION)
916  char own_verify_data[MBEDTLS_SSL_VERIFY_DATA_MAX_LEN];
917  char peer_verify_data[MBEDTLS_SSL_VERIFY_DATA_MAX_LEN];
918 #endif
919 };
920 
921 #if defined(MBEDTLS_SSL_HW_RECORD_ACCEL)
922 
923 #define MBEDTLS_SSL_CHANNEL_OUTBOUND 0
924 #define MBEDTLS_SSL_CHANNEL_INBOUND 1
925 
926 extern int (*mbedtls_ssl_hw_record_init)(mbedtls_ssl_context *ssl,
927  const unsigned char *key_enc, const unsigned char *key_dec,
928  size_t keylen,
929  const unsigned char *iv_enc, const unsigned char *iv_dec,
930  size_t ivlen,
931  const unsigned char *mac_enc, const unsigned char *mac_dec,
932  size_t maclen);
933 extern int (*mbedtls_ssl_hw_record_activate)(mbedtls_ssl_context *ssl, int direction);
934 extern int (*mbedtls_ssl_hw_record_reset)(mbedtls_ssl_context *ssl);
935 extern int (*mbedtls_ssl_hw_record_write)(mbedtls_ssl_context *ssl);
936 extern int (*mbedtls_ssl_hw_record_read)(mbedtls_ssl_context *ssl);
937 extern int (*mbedtls_ssl_hw_record_finish)(mbedtls_ssl_context *ssl);
938 #endif /* MBEDTLS_SSL_HW_RECORD_ACCEL */
939 
946 const int *mbedtls_ssl_list_ciphersuites( void );
947 
956 const char *mbedtls_ssl_get_ciphersuite_name( const int ciphersuite_id );
957 
966 int mbedtls_ssl_get_ciphersuite_id( const char *ciphersuite_name );
967 
976 
998  const mbedtls_ssl_config *conf );
999 
1011 
1018 void mbedtls_ssl_conf_endpoint( mbedtls_ssl_config *conf, int endpoint );
1019 
1034 void mbedtls_ssl_conf_transport( mbedtls_ssl_config *conf, int transport );
1035 
1062 void mbedtls_ssl_conf_authmode( mbedtls_ssl_config *conf, int authmode );
1063 
1064 #if defined(MBEDTLS_X509_CRT_PARSE_C)
1065 
1077  int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *),
1078  void *p_vrfy );
1079 #endif /* MBEDTLS_X509_CRT_PARSE_C */
1080 
1089  int (*f_rng)(void *, unsigned char *, size_t),
1090  void *p_rng );
1091 
1107  void (*f_dbg)(void *, int, const char *, int, const char *),
1108  void *p_dbg );
1109 
1141  void *p_bio,
1142  mbedtls_ssl_send_t *f_send,
1143  mbedtls_ssl_recv_t *f_recv,
1144  mbedtls_ssl_recv_timeout_t *f_recv_timeout );
1145 
1162 void mbedtls_ssl_conf_read_timeout( mbedtls_ssl_config *conf, uint32_t timeout );
1163 
1185  void *p_timer,
1186  mbedtls_ssl_set_timer_t *f_set_timer,
1187  mbedtls_ssl_get_timer_t *f_get_timer );
1188 
1208 typedef int mbedtls_ssl_ticket_write_t( void *p_ticket,
1209  const mbedtls_ssl_session *session,
1210  unsigned char *start,
1211  const unsigned char *end,
1212  size_t *tlen,
1213  uint32_t *lifetime );
1214 
1215 #if defined(MBEDTLS_SSL_EXPORT_KEYS)
1216 
1236 typedef int mbedtls_ssl_export_keys_t( void *p_expkey,
1237  const unsigned char *ms,
1238  const unsigned char *kb,
1239  size_t maclen,
1240  size_t keylen,
1241  size_t ivlen );
1242 #endif /* MBEDTLS_SSL_EXPORT_KEYS */
1243 
1267 typedef int mbedtls_ssl_ticket_parse_t( void *p_ticket,
1268  mbedtls_ssl_session *session,
1269  unsigned char *buf,
1270  size_t len );
1271 
1272 #if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_SRV_C)
1273 
1288  mbedtls_ssl_ticket_write_t *f_ticket_write,
1289  mbedtls_ssl_ticket_parse_t *f_ticket_parse,
1290  void *p_ticket );
1291 #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_SRV_C */
1292 
1293 #if defined(MBEDTLS_SSL_EXPORT_KEYS)
1294 
1305  mbedtls_ssl_export_keys_t *f_export_keys,
1306  void *p_export_keys );
1307 #endif /* MBEDTLS_SSL_EXPORT_KEYS */
1308 
1323 typedef int mbedtls_ssl_cookie_write_t( void *ctx,
1324  unsigned char **p, unsigned char *end,
1325  const unsigned char *info, size_t ilen );
1326 
1340 typedef int mbedtls_ssl_cookie_check_t( void *ctx,
1341  const unsigned char *cookie, size_t clen,
1342  const unsigned char *info, size_t ilen );
1343 
1344 #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C)
1345 
1374  mbedtls_ssl_cookie_write_t *f_cookie_write,
1375  mbedtls_ssl_cookie_check_t *f_cookie_check,
1376  void *p_cookie );
1377 
1398  const unsigned char *info,
1399  size_t ilen );
1400 
1401 #endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY && MBEDTLS_SSL_SRV_C */
1402 
1403 #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)
1404 
1419 void mbedtls_ssl_conf_dtls_anti_replay( mbedtls_ssl_config *conf, char mode );
1420 #endif /* MBEDTLS_SSL_DTLS_ANTI_REPLAY */
1421 
1422 #if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT)
1423 
1446 void mbedtls_ssl_conf_dtls_badmac_limit( mbedtls_ssl_config *conf, unsigned limit );
1447 #endif /* MBEDTLS_SSL_DTLS_BADMAC_LIMIT */
1448 
1449 #if defined(MBEDTLS_SSL_PROTO_DTLS)
1450 
1481 void mbedtls_ssl_conf_handshake_timeout( mbedtls_ssl_config *conf, uint32_t min, uint32_t max );
1482 #endif /* MBEDTLS_SSL_PROTO_DTLS */
1483 
1484 #if defined(MBEDTLS_SSL_SRV_C)
1485 
1523  void *p_cache,
1524  int (*f_get_cache)(void *, mbedtls_ssl_session *),
1525  int (*f_set_cache)(void *, const mbedtls_ssl_session *) );
1526 #endif /* MBEDTLS_SSL_SRV_C */
1527 
1528 #if defined(MBEDTLS_SSL_CLI_C)
1529 
1544 #endif /* MBEDTLS_SSL_CLI_C */
1545 
1562  const int *ciphersuites );
1563 
1584  const int *ciphersuites,
1585  int major, int minor );
1586 
1587 #if defined(MBEDTLS_X509_CRT_PARSE_C)
1588 
1599  const mbedtls_x509_crt_profile *profile );
1600 
1609  mbedtls_x509_crt *ca_chain,
1610  mbedtls_x509_crl *ca_crl );
1611 
1641  mbedtls_x509_crt *own_cert,
1642  mbedtls_pk_context *pk_key );
1643 #endif /* MBEDTLS_X509_CRT_PARSE_C */
1644 
1645 #if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED)
1646 
1667  const unsigned char *psk, size_t psk_len,
1668  const unsigned char *psk_identity, size_t psk_identity_len );
1669 
1670 
1684  const unsigned char *psk, size_t psk_len );
1685 
1711  int (*f_psk)(void *, mbedtls_ssl_context *, const unsigned char *,
1712  size_t),
1713  void *p_psk );
1714 #endif /* MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED */
1715 
1716 #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_SRV_C)
1717 
1718 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
1719 
1720 #if defined(MBEDTLS_DEPRECATED_WARNING)
1721 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
1722 #else
1723 #define MBEDTLS_DEPRECATED
1724 #endif
1725 
1740  const char *dhm_P,
1741  const char *dhm_G );
1742 
1743 #endif /* MBEDTLS_DEPRECATED_REMOVED */
1744 
1759  const unsigned char *dhm_P, size_t P_len,
1760  const unsigned char *dhm_G, size_t G_len );
1761 
1772 #endif /* MBEDTLS_DHM_C && defined(MBEDTLS_SSL_SRV_C) */
1773 
1774 #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C)
1775 
1784  unsigned int bitlen );
1785 #endif /* MBEDTLS_DHM_C && MBEDTLS_SSL_CLI_C */
1786 
1787 #if defined(MBEDTLS_ECP_C)
1788 
1816  const mbedtls_ecp_group_id *curves );
1817 #endif /* MBEDTLS_ECP_C */
1818 
1819 #if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED)
1820 
1839  const int *hashes );
1840 #endif /* MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */
1841 
1842 #if defined(MBEDTLS_X509_CRT_PARSE_C)
1843 
1861 int mbedtls_ssl_set_hostname( mbedtls_ssl_context *ssl, const char *hostname );
1862 #endif /* MBEDTLS_X509_CRT_PARSE_C */
1863 
1864 #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
1865 
1878  mbedtls_x509_crt *own_cert,
1879  mbedtls_pk_context *pk_key );
1880 
1893  mbedtls_x509_crt *ca_chain,
1894  mbedtls_x509_crl *ca_crl );
1895 
1907  int authmode );
1908 
1933  int (*f_sni)(void *, mbedtls_ssl_context *, const unsigned char *,
1934  size_t),
1935  void *p_sni );
1936 #endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */
1937 
1938 #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
1939 
1956 int mbedtls_ssl_set_hs_ecjpake_password( mbedtls_ssl_context *ssl,
1957  const unsigned char *pw,
1958  size_t pw_len );
1959 #endif /*MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */
1960 
1961 #if defined(MBEDTLS_SSL_ALPN)
1962 
1974 int mbedtls_ssl_conf_alpn_protocols( mbedtls_ssl_config *conf, const char **protos );
1975 
1985 const char *mbedtls_ssl_get_alpn_protocol( const mbedtls_ssl_context *ssl );
1986 #endif /* MBEDTLS_SSL_ALPN */
1987 
2004 void mbedtls_ssl_conf_max_version( mbedtls_ssl_config *conf, int major, int minor );
2005 
2024 void mbedtls_ssl_conf_min_version( mbedtls_ssl_config *conf, int major, int minor );
2025 
2026 #if defined(MBEDTLS_SSL_FALLBACK_SCSV) && defined(MBEDTLS_SSL_CLI_C)
2027 
2046 void mbedtls_ssl_conf_fallback( mbedtls_ssl_config *conf, char fallback );
2047 #endif /* MBEDTLS_SSL_FALLBACK_SCSV && MBEDTLS_SSL_CLI_C */
2048 
2049 #if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
2050 
2062 #endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */
2063 
2064 #if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET)
2065 
2077 #endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */
2078 
2079 #if defined(MBEDTLS_ARC4_C)
2080 
2095 void mbedtls_ssl_conf_arc4_support( mbedtls_ssl_config *conf, char arc4 );
2096 #endif /* MBEDTLS_ARC4_C */
2097 
2098 #if defined(MBEDTLS_SSL_SRV_C)
2099 
2109  char cert_req_ca_list );
2110 #endif /* MBEDTLS_SSL_SRV_C */
2111 
2112 #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
2113 
2128 int mbedtls_ssl_conf_max_frag_len( mbedtls_ssl_config *conf, unsigned char mfl_code );
2129 #endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
2130 
2131 #if defined(MBEDTLS_SSL_TRUNCATED_HMAC)
2132 
2140 void mbedtls_ssl_conf_truncated_hmac( mbedtls_ssl_config *conf, int truncate );
2141 #endif /* MBEDTLS_SSL_TRUNCATED_HMAC */
2142 
2143 #if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING)
2144 
2156 #endif /* MBEDTLS_SSL_CBC_RECORD_SPLITTING */
2157 
2158 #if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_CLI_C)
2159 
2169 void mbedtls_ssl_conf_session_tickets( mbedtls_ssl_config *conf, int use_tickets );
2170 #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_CLI_C */
2171 
2172 #if defined(MBEDTLS_SSL_RENEGOTIATION)
2173 
2190 void mbedtls_ssl_conf_renegotiation( mbedtls_ssl_config *conf, int renegotiation );
2191 #endif /* MBEDTLS_SSL_RENEGOTIATION */
2192 
2220 void mbedtls_ssl_conf_legacy_renegotiation( mbedtls_ssl_config *conf, int allow_legacy );
2221 
2222 #if defined(MBEDTLS_SSL_RENEGOTIATION)
2223 
2260 void mbedtls_ssl_conf_renegotiation_enforced( mbedtls_ssl_config *conf, int max_records );
2261 
2288  const unsigned char period[8] );
2289 #endif /* MBEDTLS_SSL_RENEGOTIATION */
2290 
2299 
2311 uint32_t mbedtls_ssl_get_verify_result( const mbedtls_ssl_context *ssl );
2312 
2320 const char *mbedtls_ssl_get_ciphersuite( const mbedtls_ssl_context *ssl );
2321 
2329 const char *mbedtls_ssl_get_version( const mbedtls_ssl_context *ssl );
2330 
2342 
2343 #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
2344 
2361 #endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
2362 
2363 #if defined(MBEDTLS_X509_CRT_PARSE_C)
2364 
2379 #endif /* MBEDTLS_X509_CRT_PARSE_C */
2380 
2381 #if defined(MBEDTLS_SSL_CLI_C)
2382 
2399 #endif /* MBEDTLS_SSL_CLI_C */
2400 
2423 
2444 
2445 #if defined(MBEDTLS_SSL_RENEGOTIATION)
2446 
2465 #endif /* MBEDTLS_SSL_RENEGOTIATION */
2466 
2501 int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len );
2502 
2538 int mbedtls_ssl_write( mbedtls_ssl_context *ssl, const unsigned char *buf, size_t len );
2539 
2557  unsigned char level,
2558  unsigned char message );
2573 
2580 
2592 
2609  int endpoint, int transport, int preset );
2610 
2617 
2624 
2632 
2633 #ifdef __cplusplus
2634 }
2635 #endif
2636 
2637 #endif /* ssl.h */
uint64_t in_window_top
Definition: ssl.h:851
mbedtls_ssl_send_t * f_send
Definition: ssl.h:795
void * p_rng
Definition: ssl.h:612
const char ** alpn_list
Definition: ssl.h:692
unsigned int transport
Definition: ssl.h:732
unsigned char * in_ctr
Definition: ssl.h:833
mbedtls_x509_crt * peer_cert
Definition: ssl.h:570
unsigned char * out_msg
Definition: ssl.h:870
unsigned int trunc_hmac
Definition: ssl.h:758
unsigned char * in_len
Definition: ssl.h:837
unsigned char * in_buf
Definition: ssl.h:832
unsigned int endpoint
Definition: ssl.h:731
Public key container.
Definition: pk.h:128
void mbedtls_ssl_set_hs_ca_chain(mbedtls_ssl_context *ssl, mbedtls_x509_crt *ca_chain, mbedtls_x509_crl *ca_crl)
Set the data required to verify peer certificate for the current handshake.
int mbedtls_ssl_ticket_parse_t(void *p_ticket, mbedtls_ssl_session *session, unsigned char *buf, size_t len)
Callback type: parse and load session ticket.
Definition: ssl.h:1267
mbedtls_mpi dhm_P
Definition: ssl.h:680
unsigned char max_minor_ver
Definition: ssl.h:723
const char * mbedtls_ssl_get_ciphersuite_name(const int ciphersuite_id)
Return the name of the ciphersuite associated with the given ID.
void mbedtls_ssl_conf_encrypt_then_mac(mbedtls_ssl_config *conf, char etm)
Enable or disable Encrypt-then-MAC (Default: MBEDTLS_SSL_ETM_ENABLED)
unsigned char min_minor_ver
Definition: ssl.h:725
int mbedtls_ssl_cookie_write_t(void *ctx, unsigned char **p, unsigned char *end, const unsigned char *info, size_t ilen)
Callback type: generate a cookie.
Definition: ssl.h:1323
unsigned char * in_hdr
Definition: ssl.h:836
size_t psk_identity_len
Definition: ssl.h:688
unsigned int dhm_min_bitlen
Definition: ssl.h:719
int mbedtls_ssl_cookie_check_t(void *ctx, const unsigned char *cookie, size_t clen, const unsigned char *info, size_t ilen)
Callback type: verify a cookie.
Definition: ssl.h:1340
void * p_sni
Definition: ssl.h:623
void mbedtls_ssl_set_timer_cb(mbedtls_ssl_context *ssl, void *p_timer, mbedtls_ssl_set_timer_t *f_set_timer, mbedtls_ssl_get_timer_t *f_get_timer)
Set the timer callbacks (Mandatory for DTLS.)
unsigned char * ticket
Definition: ssl.h:575
struct mbedtls_ssl_sig_hash_set_t mbedtls_ssl_sig_hash_set_t
Definition: ssl.h:547
size_t ticket_len
Definition: ssl.h:576
void mbedtls_ssl_conf_extended_master_secret(mbedtls_ssl_config *conf, char ems)
Enable or disable Extended Master Secret negotiation. (Default: MBEDTLS_SSL_EXTENDED_MS_ENABLED) ...
unsigned char * out_iv
Definition: ssl.h:869
mbedtls_ssl_transform * transform_in
Definition: ssl.h:816
size_t in_left
Definition: ssl.h:844
unsigned int authmode
Definition: ssl.h:733
int mbedtls_ssl_send_t(void *ctx, const unsigned char *buf, size_t len)
Callback type: send data on the network.
Definition: ssl.h:446
unsigned int badmac_limit
Definition: ssl.h:715
void * p_psk
Definition: ssl.h:635
void mbedtls_ssl_conf_fallback(mbedtls_ssl_config *conf, char fallback)
Set the fallback flag (client-side only). (Default: MBEDTLS_SSL_IS_NOT_FALLBACK). ...
unsigned int anti_replay
Definition: ssl.h:749
int mbedtls_ssl_recv_t(void *ctx, unsigned char *buf, size_t len)
Callback type: receive data from the network.
Definition: ssl.h:469
unsigned int fallback
Definition: ssl.h:764
const mbedtls_ecp_group_id * curve_list
Definition: ssl.h:676
Elliptic curves over GF(p)
void mbedtls_ssl_conf_cbc_record_splitting(mbedtls_ssl_config *conf, char split)
Enable / Disable 1/n-1 record splitting (Default: MBEDTLS_SSL_CBC_RECORD_SPLITTING_ENABLED) ...
unsigned char _pms_dhm[MBEDTLS_MPI_MAX_SIZE]
Definition: ssl.h:369
void * p_cache
Definition: ssl.h:618
void mbedtls_ssl_conf_verify(mbedtls_ssl_config *conf, int(*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *), void *p_vrfy)
Set the verification callback (Optional).
unsigned int cert_req_ca_list
Definition: ssl.h:767
unsigned char _pms_rsa[48]
Definition: ssl.h:366
unsigned char _pms_ecdh[MBEDTLS_ECP_MAX_BYTES]
Definition: ssl.h:375
uint32_t ticket_lifetime
Definition: ssl.h:577
void mbedtls_ssl_conf_renegotiation(mbedtls_ssl_config *conf, int renegotiation)
Enable / Disable renegotiation support for connection when initiated by peer (Default: MBEDTLS_SSL_RE...
mbedtls_ssl_session * session_in
Definition: ssl.h:805
int mbedtls_ssl_conf_dh_param_bin(mbedtls_ssl_config *conf, const unsigned char *dhm_P, size_t P_len, const unsigned char *dhm_G, size_t G_len)
Set the Diffie-Hellman public P and G values from big-endian binary presentations. (Default values: MBEDTLS_DHM_RFC3526_MODP_2048_[PG]_BIN)
unsigned badmac_seen
Definition: ssl.h:792
void mbedtls_ssl_conf_dtls_anti_replay(mbedtls_ssl_config *conf, char mode)
Enable or disable anti-replay protection for DTLS. (DTLS only, no effect on TLS.) Default: enabled...
mbedtls_ssl_get_timer_t * f_get_timer
Definition: ssl.h:827
Configuration options (set of defines)
void mbedtls_ssl_conf_max_version(mbedtls_ssl_config *conf, int major, int minor)
Set the maximum supported version sent from the client side and/or accepted at the server side (Defau...
uint32_t mbedtls_ssl_get_verify_result(const mbedtls_ssl_context *ssl)
Return the result of the certificate verification.
void mbedtls_ssl_conf_session_tickets_cb(mbedtls_ssl_config *conf, mbedtls_ssl_ticket_write_t *f_ticket_write, mbedtls_ssl_ticket_parse_t *f_ticket_parse, void *p_ticket)
Configure SSL session ticket callbacks (server only). (Default: none.)
mbedtls_x509_crl * ca_crl
Definition: ssl.h:668
mbedtls_ssl_session * session_out
Definition: ssl.h:806
const mbedtls_x509_crt * mbedtls_ssl_get_peer_cert(const mbedtls_ssl_context *ssl)
Return the peer certificate from the current connection.
int mbedtls_ssl_send_alert_message(mbedtls_ssl_context *ssl, unsigned char level, unsigned char message)
Send an alert message.
int mbedtls_ssl_recv_timeout_t(void *ctx, unsigned char *buf, size_t len, uint32_t timeout)
Callback type: receive data from the network, with timeout.
Definition: ssl.h:495
SSL Ciphersuites for mbed TLS.
mbedtls_ssl_transform * transform_out
Definition: ssl.h:817
unsigned char mfl_code
Definition: ssl.h:581
void mbedtls_ssl_conf_renegotiation_period(mbedtls_ssl_config *conf, const unsigned char period[8])
Set record counter threshold for periodic renegotiation. (Default: 2^48 - 1)
unsigned int mfl_code
Definition: ssl.h:740
Multi-precision integer library.
int encrypt_then_mac
Definition: ssl.h:589
size_t in_hslen
Definition: ssl.h:855
int mbedtls_ssl_conf_psk(mbedtls_ssl_config *conf, const unsigned char *psk, size_t psk_len, const unsigned char *psk_identity, size_t psk_identity_len)
Set the Pre Shared Key (PSK) and the expected identity name.
int mbedtls_ssl_conf_max_frag_len(mbedtls_ssl_config *conf, unsigned char mfl_code)
Set the maximum fragment length to emit and/or negotiate (Default: MBEDTLS_SSL_MAX_CONTENT_LEN, usually 2^14 bytes) (Server: set maximum fragment length to emit, usually negotiated by the client during handshake (Client: set maximum fragment length to emit and negotiate with the server during handshake)
time_t mbedtls_time_t
Definition: platform_time.h:53
int mbedtls_ssl_write(mbedtls_ssl_context *ssl, const unsigned char *buf, size_t len)
Try to write exactly 'len' application data bytes.
void mbedtls_ssl_conf_cert_req_ca_list(mbedtls_ssl_config *conf, char cert_req_ca_list)
Whether to send a list of acceptable CAs in CertificateRequest messages. (Default: do send) ...
void mbedtls_ssl_conf_min_version(mbedtls_ssl_config *conf, int major, int minor)
Set the minimum accepted SSL/TLS protocol version (Default: TLS 1.0)
uint64_t in_window
Definition: ssl.h:852
int mbedtls_ssl_close_notify(mbedtls_ssl_context *ssl)
Notify the peer that the connection is being closed.
struct mbedtls_ssl_flight_item mbedtls_ssl_flight_item
Definition: ssl.h:552
void * p_cookie
Definition: ssl.h:645
void mbedtls_ssl_conf_session_tickets(mbedtls_ssl_config *conf, int use_tickets)
Enable / Disable session tickets (client only). (Default: MBEDTLS_SSL_SESSION_TICKETS_ENABLED.)
void mbedtls_ssl_conf_ciphersuites_for_version(mbedtls_ssl_config *conf, const int *ciphersuites, int major, int minor)
Set the list of allowed ciphersuites and the preference order for a specific version of the protocol...
mbedtls_ssl_transform * transform
Definition: ssl.h:818
uint32_t hs_timeout_min
Definition: ssl.h:702
mbedtls_ssl_handshake_params * handshake
Definition: ssl.h:810
void mbedtls_ssl_free(mbedtls_ssl_context *ssl)
Free referenced items in an SSL context and clear memory.
void mbedtls_ssl_conf_export_keys_cb(mbedtls_ssl_config *conf, mbedtls_ssl_export_keys_t *f_export_keys, void *p_export_keys)
Configure key export callback. (Default: none.)
void mbedtls_ssl_conf_endpoint(mbedtls_ssl_config *conf, int endpoint)
Set the current endpoint type.
size_t out_left
Definition: ssl.h:874
void mbedtls_ssl_session_free(mbedtls_ssl_session *session)
Free referenced items in an SSL session including the peer certificate and clear memory.
void mbedtls_ssl_conf_arc4_support(mbedtls_ssl_config *conf, char arc4)
Disable or enable support for RC4 (Default: MBEDTLS_SSL_ARC4_DISABLED)
unsigned char * in_msg
Definition: ssl.h:839
void mbedtls_ssl_conf_sig_hashes(mbedtls_ssl_config *conf, const int *hashes)
Set the allowed hashes for signatures during the handshake. (Default: all available hashes except MD5...
unsigned char min_major_ver
Definition: ssl.h:724
struct mbedtls_ssl_transform mbedtls_ssl_transform
Definition: ssl.h:545
mbedtls_ssl_set_timer_t * f_set_timer
Definition: ssl.h:826
const char * mbedtls_ssl_get_alpn_protocol(const mbedtls_ssl_context *ssl)
Get the name of the negotiated Application Layer Protocol. This function should be called after the h...
void mbedtls_ssl_conf_dhm_min_bitlen(mbedtls_ssl_config *conf, unsigned int bitlen)
Set the minimum length for Diffie-Hellman parameters. (Client-side only.) (Default: 1024 bits...
void mbedtls_ssl_conf_dtls_cookies(mbedtls_ssl_config *conf, mbedtls_ssl_cookie_write_t *f_cookie_write, mbedtls_ssl_cookie_check_t *f_cookie_check, void *p_cookie)
Register callbacks for DTLS cookies (Server only. DTLS only.)
mbedtls_ssl_key_cert * key_cert
Definition: ssl.h:666
MBEDTLS_DEPRECATED int mbedtls_ssl_conf_dh_param(mbedtls_ssl_config *conf, const char *dhm_P, const char *dhm_G)
Set the Diffie-Hellman public P and G values, read as hexadecimal strings (server-side only) (Default...
mbedtls_ssl_recv_t * f_recv
Definition: ssl.h:796
int mbedtls_ssl_get_ciphersuite_id(const char *ciphersuite_name)
Return the ID of the ciphersuite associated with the given name.
void mbedtls_ssl_conf_transport(mbedtls_ssl_config *conf, int transport)
Set the transport type (TLS or DTLS). Default: TLS.
mbedtls_ssl_session * session_negotiate
Definition: ssl.h:808
mbedtls_ssl_states
Definition: ssl.h:405
void mbedtls_ssl_conf_sni(mbedtls_ssl_config *conf, int(*f_sni)(void *, mbedtls_ssl_context *, const unsigned char *, size_t), void *p_sni)
Set server side ServerName TLS extension callback (optional, server-side only).
const int * sig_hashes
Definition: ssl.h:672
const int * mbedtls_ssl_list_ciphersuites(void)
Returns the list of ciphersuites supported by the SSL/TLS module.
void mbedtls_ssl_conf_renegotiation_enforced(mbedtls_ssl_config *conf, int max_records)
Enforce renegotiation requests. (Default: enforced, max_records = 16)
#define MBEDTLS_DEPRECATED
Definition: ssl.h:1721
int mbedtls_ssl_set_client_transport_id(mbedtls_ssl_context *ssl, const unsigned char *info, size_t ilen)
Set client's transport-level identification info. (Server only. DTLS only.)
void mbedtls_ssl_set_bio(mbedtls_ssl_context *ssl, void *p_bio, mbedtls_ssl_send_t *f_send, mbedtls_ssl_recv_t *f_recv, mbedtls_ssl_recv_timeout_t *f_recv_timeout)
Set the underlying BIO callbacks for write, read and read-with-timeout.
size_t id_len
Definition: ssl.h:565
unsigned int encrypt_then_mac
Definition: ssl.h:743
void * p_bio
Definition: ssl.h:800
unsigned int cbc_record_splitting
Definition: ssl.h:752
void mbedtls_ssl_conf_rng(mbedtls_ssl_config *conf, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Set the random number generator callback.
int renego_status
Definition: ssl.h:782
int mbedtls_ssl_conf_alpn_protocols(mbedtls_ssl_config *conf, const char **protos)
Set the supported Application Layer Protocols.
void mbedtls_ssl_conf_cert_profile(mbedtls_ssl_config *conf, const mbedtls_x509_crt_profile *profile)
Set the X.509 security profile used for verification.
unsigned char _pms_ecdhe_psk[4+MBEDTLS_ECP_MAX_BYTES+MBEDTLS_PSK_MAX_LEN]
Definition: ssl.h:389
void * p_vrfy
Definition: ssl.h:629
const mbedtls_x509_crt_profile * cert_profile
Definition: ssl.h:665
void * p_timer
Definition: ssl.h:824
Diffie-Hellman-Merkle key exchange.
X.509 certificate parsing and writing.
void mbedtls_ssl_conf_session_cache(mbedtls_ssl_config *conf, void *p_cache, int(*f_get_cache)(void *, mbedtls_ssl_session *), int(*f_set_cache)(void *, const mbedtls_ssl_session *))
Set the session cache callbacks (server-side only) If not set, no session resuming is done (except if...
#define MBEDTLS_PSK_MAX_LEN
Definition: ssl.h:359
unsigned int session_tickets
Definition: ssl.h:761
void mbedtls_ssl_conf_truncated_hmac(mbedtls_ssl_config *conf, int truncate)
Activate negotiation of truncated HMAC (Default: MBEDTLS_SSL_TRUNC_HMAC_DISABLED) ...
mbedtls_ssl_session * session
Definition: ssl.h:807
unsigned char * in_iv
Definition: ssl.h:838
void mbedtls_ssl_init(mbedtls_ssl_context *ssl)
Initialize an SSL context Just makes the context ready for mbedtls_ssl_setup() or mbedtls_ssl_free() ...
mbedtls_ssl_transform * transform_negotiate
Definition: ssl.h:819
const char * mbedtls_ssl_get_ciphersuite(const mbedtls_ssl_context *ssl)
Return the name of the current ciphersuite.
mbedtls_ecp_group_id
Definition: ecp.h:64
unsigned char * out_ctr
Definition: ssl.h:866
int secure_renegotiation
Definition: ssl.h:912
int mbedtls_ssl_get_timer_t(void *ctx)
Callback type: get status of timers/delays.
Definition: ssl.h:536
The DHM context structure.
Definition: dhm.h:92
const mbedtls_ssl_config * conf
Definition: ssl.h:775
void mbedtls_ssl_conf_dbg(mbedtls_ssl_config *conf, void(*f_dbg)(void *, int, const char *, int, const char *), void *p_dbg)
Set the debug callback.
unsigned char * in_offt
Definition: ssl.h:840
unsigned int extended_ms
Definition: ssl.h:746
unsigned char max_major_ver
Definition: ssl.h:722
unsigned char * psk
Definition: ssl.h:685
void mbedtls_ssl_config_init(mbedtls_ssl_config *conf)
Initialize an SSL configuration context Just makes the context ready for mbedtls_ssl_config_defaults(...
int mbedtls_ssl_get_record_expansion(const mbedtls_ssl_context *ssl)
Return the (maximum) number of bytes added by the record layer: header + encryption/MAC overhead (inc...
const char * alpn_chosen
Definition: ssl.h:897
The Elliptic Curve Diffie-Hellman (ECDH) protocol APIs.
int mbedtls_ssl_conf_dh_param_ctx(mbedtls_ssl_config *conf, mbedtls_dhm_context *dhm_ctx)
Set the Diffie-Hellman public P and G values, read from existing context (server-side only) ...
mbedtls_mpi dhm_G
Definition: ssl.h:681
int mbedtls_ssl_set_session(mbedtls_ssl_context *ssl, const mbedtls_ssl_session *session)
Request resumption of session (client-side only) Session data is copied from presented session struct...
#define MBEDTLS_MPI_MAX_SIZE
Definition: bignum.h:77
unsigned int disable_renegotiation
Definition: ssl.h:755
void * p_export_keys
Definition: ssl.h:661
char * hostname
Definition: ssl.h:892
int mbedtls_ssl_set_hs_own_cert(mbedtls_ssl_context *ssl, mbedtls_x509_crt *own_cert, mbedtls_pk_context *pk_key)
Set own certificate and key for the current handshake.
int mbedtls_ssl_conf_own_cert(mbedtls_ssl_config *conf, mbedtls_x509_crt *own_cert, mbedtls_pk_context *pk_key)
Set own certificate chain and private key.
int mbedtls_ssl_setup(mbedtls_ssl_context *ssl, const mbedtls_ssl_config *conf)
Set up an SSL context for use.
size_t out_msglen
Definition: ssl.h:873
uint32_t read_timeout
Definition: ssl.h:699
void mbedtls_ssl_conf_legacy_renegotiation(mbedtls_ssl_config *conf, int allow_legacy)
Prevent or allow legacy renegotiation. (Default: MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION) ...
unsigned char _pms_rsa_psk[52+MBEDTLS_PSK_MAX_LEN]
Definition: ssl.h:385
int mbedtls_ssl_renegotiate(mbedtls_ssl_context *ssl)
Initiate an SSL renegotiation on the running connection. Client: perform the renegotiation right now...
int mbedtls_ssl_export_keys_t(void *p_expkey, const unsigned char *ms, const unsigned char *kb, size_t maclen, size_t keylen, size_t ivlen)
Callback type: Export key block and master secret.
Definition: ssl.h:1236
unsigned char * out_len
Definition: ssl.h:868
unsigned int arc4_disabled
Definition: ssl.h:737
uint32_t hs_timeout_max
Definition: ssl.h:704
MPI structure.
Definition: bignum.h:180
X.509 certificate revocation list parsing.
void mbedtls_ssl_conf_psk_cb(mbedtls_ssl_config *conf, int(*f_psk)(void *, mbedtls_ssl_context *, const unsigned char *, size_t), void *p_psk)
Set the PSK callback (server-side only).
unsigned char * cli_id
Definition: ssl.h:904
int renego_max_records
Definition: ssl.h:709
mbedtls_ssl_recv_timeout_t * f_recv_timeout
Definition: ssl.h:797
mbedtls_x509_crt * ca_chain
Definition: ssl.h:667
void mbedtls_ssl_conf_read_timeout(mbedtls_ssl_config *conf, uint32_t timeout)
Set the timeout period for mbedtls_ssl_read() (Default: no timeout.)
size_t verify_data_len
Definition: ssl.h:915
void mbedtls_ssl_config_free(mbedtls_ssl_config *conf)
Free an SSL configuration context.
unsigned char * psk_identity
Definition: ssl.h:687
int mbedtls_ssl_read(mbedtls_ssl_context *ssl, unsigned char *buf, size_t len)
Read at most 'len' application data bytes.
struct mbedtls_ssl_key_cert mbedtls_ssl_key_cert
Definition: ssl.h:549
void mbedtls_ssl_set_timer_t(void *ctx, uint32_t int_ms, uint32_t fin_ms)
Callback type: set a pair of timers/delays to watch.
Definition: ssl.h:521
size_t mbedtls_ssl_get_bytes_avail(const mbedtls_ssl_context *ssl)
Return the number of data bytes available to read.
unsigned char _pms_dhe_psk[4+MBEDTLS_MPI_MAX_SIZE+MBEDTLS_PSK_MAX_LEN]
Definition: ssl.h:382
size_t next_record_offset
Definition: ssl.h:847
unsigned char * out_buf
Definition: ssl.h:865
size_t psk_len
Definition: ssl.h:686
void mbedtls_ssl_session_init(mbedtls_ssl_session *session)
Initialize SSL session structure.
void * p_dbg
Definition: ssl.h:608
int mbedtls_ssl_ticket_write_t(void *p_ticket, const mbedtls_ssl_session *session, unsigned char *start, const unsigned char *end, size_t *tlen, uint32_t *lifetime)
Callback type: generate and write session ticket.
Definition: ssl.h:1208
size_t cli_id_len
Definition: ssl.h:905
void mbedtls_ssl_conf_handshake_timeout(mbedtls_ssl_config *conf, uint32_t min, uint32_t max)
Set retransmit timeout values for the DTLS handshake. (DTLS only, no effect on TLS.)
mbed TLS Platform time abstraction
int mbedtls_ssl_config_defaults(mbedtls_ssl_config *conf, int endpoint, int transport, int preset)
Load reasonnable default SSL configuration values. (You need to call mbedtls_ssl_config_init() first...
void mbedtls_ssl_conf_ca_chain(mbedtls_ssl_config *conf, mbedtls_x509_crt *ca_chain, mbedtls_x509_crl *ca_crl)
Set the data required to verify peer certificate.
void mbedtls_ssl_conf_curves(mbedtls_ssl_config *conf, const mbedtls_ecp_group_id *curves)
Set the allowed curves in order of preference. (Default: all defined curves.)
int renego_records_seen
Definition: ssl.h:783
unsigned char * out_hdr
Definition: ssl.h:867
void mbedtls_ssl_conf_dtls_badmac_limit(mbedtls_ssl_config *conf, unsigned limit)
Set a limit on the number of records with a bad MAC before terminating the connection. (DTLS only, no effect on TLS.) Default: 0 (disabled).
unsigned char _pms_psk[4+2 *MBEDTLS_PSK_MAX_LEN]
Definition: ssl.h:378
uint32_t verify_result
Definition: ssl.h:572
int mbedtls_ssl_handshake(mbedtls_ssl_context *ssl)
Perform the SSL handshake.
void mbedtls_ssl_set_hs_authmode(mbedtls_ssl_context *ssl, int authmode)
Set authmode for the current handshake.
unsigned int allow_legacy_renegotiation
Definition: ssl.h:735
int keep_current_message
Definition: ssl.h:859
signed char split_done
Definition: ssl.h:880
int mbedtls_ssl_handshake_step(mbedtls_ssl_context *ssl)
Perform a single step of the SSL handshake.
const char * mbedtls_ssl_get_version(const mbedtls_ssl_context *ssl)
Return the current SSL version (SSLv3/TLSv1/etc)
void mbedtls_ssl_conf_authmode(mbedtls_ssl_config *conf, int authmode)
Set the certificate verification mode Default: NONE on server, REQUIRED on client.
int mbedtls_ssl_session_reset(mbedtls_ssl_context *ssl)
Reset an already initialized SSL context for re-use while retaining application-set variables...
int mbedtls_ssl_set_hostname(mbedtls_ssl_context *ssl, const char *hostname)
Set or reset the hostname to check against the received server certificate. It sets the ServerName TL...
struct mbedtls_ssl_handshake_params mbedtls_ssl_handshake_params
Definition: ssl.h:546
#define MBEDTLS_ECP_MAX_BYTES
Definition: ecp.h:190
int mbedtls_ssl_set_hs_psk(mbedtls_ssl_context *ssl, const unsigned char *psk, size_t psk_len)
Set the Pre Shared Key (PSK) for the current handshake.
int mbedtls_ssl_get_session(const mbedtls_ssl_context *ssl, mbedtls_ssl_session *session)
Save session in order to resume it later (client-side only) Session data is copied to presented sessi...
void * p_ticket
Definition: ssl.h:654
void mbedtls_ssl_conf_ciphersuites(mbedtls_ssl_config *conf, const int *ciphersuites)
Set the list of allowed ciphersuites and the preference order. First in the list has the highest pref...
size_t mbedtls_ssl_get_max_frag_len(const mbedtls_ssl_context *ssl)
Return the maximum fragment length (payload, in bytes). This is the value negotiated with peer if any...
#define MBEDTLS_SSL_VERIFY_DATA_MAX_LEN
Definition: ssl.h:243
mbedtls_time_t start
Definition: ssl.h:561
size_t in_msglen
Definition: ssl.h:843
uint16_t in_epoch
Definition: ssl.h:846