mbed TLS v2.7.6
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 #include "zlib.h"
53 #endif
54 
55 #if defined(MBEDTLS_HAVE_TIME)
56 #include "platform_time.h"
57 #endif
58 
59 /*
60  * SSL Error codes
61  */
62 #define MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE -0x7080
63 #define MBEDTLS_ERR_SSL_BAD_INPUT_DATA -0x7100
64 #define MBEDTLS_ERR_SSL_INVALID_MAC -0x7180
65 #define MBEDTLS_ERR_SSL_INVALID_RECORD -0x7200
66 #define MBEDTLS_ERR_SSL_CONN_EOF -0x7280
67 #define MBEDTLS_ERR_SSL_UNKNOWN_CIPHER -0x7300
68 #define MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN -0x7380
69 #define MBEDTLS_ERR_SSL_NO_RNG -0x7400
70 #define MBEDTLS_ERR_SSL_NO_CLIENT_CERTIFICATE -0x7480
71 #define MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE -0x7500
72 #define MBEDTLS_ERR_SSL_CERTIFICATE_REQUIRED -0x7580
73 #define MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED -0x7600
74 #define MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED -0x7680
75 #define MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE -0x7700
76 #define MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE -0x7780
77 #define MBEDTLS_ERR_SSL_PEER_VERIFY_FAILED -0x7800
78 #define MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY -0x7880
79 #define MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO -0x7900
80 #define MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO -0x7980
81 #define MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE -0x7A00
82 #define MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST -0x7A80
83 #define MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE -0x7B00
84 #define MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO_DONE -0x7B80
85 #define MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE -0x7C00
86 #define MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP -0x7C80
87 #define MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS -0x7D00
88 #define MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY -0x7D80
89 #define MBEDTLS_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC -0x7E00
90 #define MBEDTLS_ERR_SSL_BAD_HS_FINISHED -0x7E80
91 #define MBEDTLS_ERR_SSL_ALLOC_FAILED -0x7F00
92 #define MBEDTLS_ERR_SSL_HW_ACCEL_FAILED -0x7F80
93 #define MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH -0x6F80
94 #define MBEDTLS_ERR_SSL_COMPRESSION_FAILED -0x6F00
95 #define MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION -0x6E80
96 #define MBEDTLS_ERR_SSL_BAD_HS_NEW_SESSION_TICKET -0x6E00
97 #define MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED -0x6D80
98 #define MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH -0x6D00
99 #define MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY -0x6C80
100 #define MBEDTLS_ERR_SSL_INTERNAL_ERROR -0x6C00
101 #define MBEDTLS_ERR_SSL_COUNTER_WRAPPING -0x6B80
102 #define MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO -0x6B00
103 #define MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED -0x6A80
104 #define MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL -0x6A00
105 #define MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE -0x6980
106 #define MBEDTLS_ERR_SSL_WANT_READ -0x6900
107 #define MBEDTLS_ERR_SSL_WANT_WRITE -0x6880
108 #define MBEDTLS_ERR_SSL_TIMEOUT -0x6800
109 #define MBEDTLS_ERR_SSL_CLIENT_RECONNECT -0x6780
110 #define MBEDTLS_ERR_SSL_UNEXPECTED_RECORD -0x6700
111 #define MBEDTLS_ERR_SSL_NON_FATAL -0x6680
112 #define MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH -0x6600
114 /*
115  * Various constants
116  */
117 #define MBEDTLS_SSL_MAJOR_VERSION_3 3
118 #define MBEDTLS_SSL_MINOR_VERSION_0 0
119 #define MBEDTLS_SSL_MINOR_VERSION_1 1
120 #define MBEDTLS_SSL_MINOR_VERSION_2 2
121 #define MBEDTLS_SSL_MINOR_VERSION_3 3
123 #define MBEDTLS_SSL_TRANSPORT_STREAM 0
124 #define MBEDTLS_SSL_TRANSPORT_DATAGRAM 1
126 #define MBEDTLS_SSL_MAX_HOST_NAME_LEN 255
128 /* RFC 6066 section 4, see also mfl_code_to_length in ssl_tls.c
129  * NONE must be zero so that memset()ing structure to zero works */
130 #define MBEDTLS_SSL_MAX_FRAG_LEN_NONE 0
131 #define MBEDTLS_SSL_MAX_FRAG_LEN_512 1
132 #define MBEDTLS_SSL_MAX_FRAG_LEN_1024 2
133 #define MBEDTLS_SSL_MAX_FRAG_LEN_2048 3
134 #define MBEDTLS_SSL_MAX_FRAG_LEN_4096 4
135 #define MBEDTLS_SSL_MAX_FRAG_LEN_INVALID 5
137 #define MBEDTLS_SSL_IS_CLIENT 0
138 #define MBEDTLS_SSL_IS_SERVER 1
139 
140 #define MBEDTLS_SSL_IS_NOT_FALLBACK 0
141 #define MBEDTLS_SSL_IS_FALLBACK 1
142 
143 #define MBEDTLS_SSL_EXTENDED_MS_DISABLED 0
144 #define MBEDTLS_SSL_EXTENDED_MS_ENABLED 1
145 
146 #define MBEDTLS_SSL_ETM_DISABLED 0
147 #define MBEDTLS_SSL_ETM_ENABLED 1
148 
149 #define MBEDTLS_SSL_COMPRESS_NULL 0
150 #define MBEDTLS_SSL_COMPRESS_DEFLATE 1
151 
152 #define MBEDTLS_SSL_VERIFY_NONE 0
153 #define MBEDTLS_SSL_VERIFY_OPTIONAL 1
154 #define MBEDTLS_SSL_VERIFY_REQUIRED 2
155 #define MBEDTLS_SSL_VERIFY_UNSET 3 /* Used only for sni_authmode */
156 
157 #define MBEDTLS_SSL_LEGACY_RENEGOTIATION 0
158 #define MBEDTLS_SSL_SECURE_RENEGOTIATION 1
159 
160 #define MBEDTLS_SSL_RENEGOTIATION_DISABLED 0
161 #define MBEDTLS_SSL_RENEGOTIATION_ENABLED 1
162 
163 #define MBEDTLS_SSL_ANTI_REPLAY_DISABLED 0
164 #define MBEDTLS_SSL_ANTI_REPLAY_ENABLED 1
165 
166 #define MBEDTLS_SSL_RENEGOTIATION_NOT_ENFORCED -1
167 #define MBEDTLS_SSL_RENEGO_MAX_RECORDS_DEFAULT 16
168 
169 #define MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION 0
170 #define MBEDTLS_SSL_LEGACY_ALLOW_RENEGOTIATION 1
171 #define MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE 2
172 
173 #define MBEDTLS_SSL_TRUNC_HMAC_DISABLED 0
174 #define MBEDTLS_SSL_TRUNC_HMAC_ENABLED 1
175 #define MBEDTLS_SSL_TRUNCATED_HMAC_LEN 10 /* 80 bits, rfc 6066 section 7 */
176 
177 #define MBEDTLS_SSL_SESSION_TICKETS_DISABLED 0
178 #define MBEDTLS_SSL_SESSION_TICKETS_ENABLED 1
179 
180 #define MBEDTLS_SSL_CBC_RECORD_SPLITTING_DISABLED 0
181 #define MBEDTLS_SSL_CBC_RECORD_SPLITTING_ENABLED 1
182 
183 #define MBEDTLS_SSL_ARC4_ENABLED 0
184 #define MBEDTLS_SSL_ARC4_DISABLED 1
185 
186 #define MBEDTLS_SSL_PRESET_DEFAULT 0
187 #define MBEDTLS_SSL_PRESET_SUITEB 2
188 
189 #define MBEDTLS_SSL_CERT_REQ_CA_LIST_ENABLED 1
190 #define MBEDTLS_SSL_CERT_REQ_CA_LIST_DISABLED 0
191 
192 /*
193  * Default range for DTLS retransmission timer value, in milliseconds.
194  * RFC 6347 4.2.4.1 says from 1 second to 60 seconds.
195  */
196 #define MBEDTLS_SSL_DTLS_TIMEOUT_DFL_MIN 1000
197 #define MBEDTLS_SSL_DTLS_TIMEOUT_DFL_MAX 60000
198 
207 #if !defined(MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME)
208 #define MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME 86400
209 #endif
210 
211 /*
212  * Maxium fragment length in bytes,
213  * determines the size of each of the two internal I/O buffers.
214  *
215  * Note: the RFC defines the default size of SSL / TLS messages. If you
216  * change the value here, other clients / servers may not be able to
217  * communicate with you anymore. Only change this value if you control
218  * both sides of the connection and have it reduced at both sides, or
219  * if you're using the Max Fragment Length extension and you know all your
220  * peers are using it too!
221  */
222 #if !defined(MBEDTLS_SSL_MAX_CONTENT_LEN)
223 #define MBEDTLS_SSL_MAX_CONTENT_LEN 16384
224 #endif
225 
226 /* \} name SECTION: Module settings */
227 
228 /*
229  * Length of the verify data for secure renegotiation
230  */
231 #if defined(MBEDTLS_SSL_PROTO_SSL3)
232 #define MBEDTLS_SSL_VERIFY_DATA_MAX_LEN 36
233 #else
234 #define MBEDTLS_SSL_VERIFY_DATA_MAX_LEN 12
235 #endif
236 
237 /*
238  * Signaling ciphersuite values (SCSV)
239  */
240 #define MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO 0xFF
241 #define MBEDTLS_SSL_FALLBACK_SCSV_VALUE 0x5600
243 /*
244  * Supported Signature and Hash algorithms (For TLS 1.2)
245  * RFC 5246 section 7.4.1.4.1
246  */
247 #define MBEDTLS_SSL_HASH_NONE 0
248 #define MBEDTLS_SSL_HASH_MD5 1
249 #define MBEDTLS_SSL_HASH_SHA1 2
250 #define MBEDTLS_SSL_HASH_SHA224 3
251 #define MBEDTLS_SSL_HASH_SHA256 4
252 #define MBEDTLS_SSL_HASH_SHA384 5
253 #define MBEDTLS_SSL_HASH_SHA512 6
254 
255 #define MBEDTLS_SSL_SIG_ANON 0
256 #define MBEDTLS_SSL_SIG_RSA 1
257 #define MBEDTLS_SSL_SIG_ECDSA 3
258 
259 /*
260  * Client Certificate Types
261  * RFC 5246 section 7.4.4 plus RFC 4492 section 5.5
262  */
263 #define MBEDTLS_SSL_CERT_TYPE_RSA_SIGN 1
264 #define MBEDTLS_SSL_CERT_TYPE_ECDSA_SIGN 64
265 
266 /*
267  * Message, alert and handshake types
268  */
269 #define MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC 20
270 #define MBEDTLS_SSL_MSG_ALERT 21
271 #define MBEDTLS_SSL_MSG_HANDSHAKE 22
272 #define MBEDTLS_SSL_MSG_APPLICATION_DATA 23
273 
274 #define MBEDTLS_SSL_ALERT_LEVEL_WARNING 1
275 #define MBEDTLS_SSL_ALERT_LEVEL_FATAL 2
276 
277 #define MBEDTLS_SSL_ALERT_MSG_CLOSE_NOTIFY 0 /* 0x00 */
278 #define MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE 10 /* 0x0A */
279 #define MBEDTLS_SSL_ALERT_MSG_BAD_RECORD_MAC 20 /* 0x14 */
280 #define MBEDTLS_SSL_ALERT_MSG_DECRYPTION_FAILED 21 /* 0x15 */
281 #define MBEDTLS_SSL_ALERT_MSG_RECORD_OVERFLOW 22 /* 0x16 */
282 #define MBEDTLS_SSL_ALERT_MSG_DECOMPRESSION_FAILURE 30 /* 0x1E */
283 #define MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE 40 /* 0x28 */
284 #define MBEDTLS_SSL_ALERT_MSG_NO_CERT 41 /* 0x29 */
285 #define MBEDTLS_SSL_ALERT_MSG_BAD_CERT 42 /* 0x2A */
286 #define MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT 43 /* 0x2B */
287 #define MBEDTLS_SSL_ALERT_MSG_CERT_REVOKED 44 /* 0x2C */
288 #define MBEDTLS_SSL_ALERT_MSG_CERT_EXPIRED 45 /* 0x2D */
289 #define MBEDTLS_SSL_ALERT_MSG_CERT_UNKNOWN 46 /* 0x2E */
290 #define MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER 47 /* 0x2F */
291 #define MBEDTLS_SSL_ALERT_MSG_UNKNOWN_CA 48 /* 0x30 */
292 #define MBEDTLS_SSL_ALERT_MSG_ACCESS_DENIED 49 /* 0x31 */
293 #define MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR 50 /* 0x32 */
294 #define MBEDTLS_SSL_ALERT_MSG_DECRYPT_ERROR 51 /* 0x33 */
295 #define MBEDTLS_SSL_ALERT_MSG_EXPORT_RESTRICTION 60 /* 0x3C */
296 #define MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION 70 /* 0x46 */
297 #define MBEDTLS_SSL_ALERT_MSG_INSUFFICIENT_SECURITY 71 /* 0x47 */
298 #define MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR 80 /* 0x50 */
299 #define MBEDTLS_SSL_ALERT_MSG_INAPROPRIATE_FALLBACK 86 /* 0x56 */
300 #define MBEDTLS_SSL_ALERT_MSG_USER_CANCELED 90 /* 0x5A */
301 #define MBEDTLS_SSL_ALERT_MSG_NO_RENEGOTIATION 100 /* 0x64 */
302 #define MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_EXT 110 /* 0x6E */
303 #define MBEDTLS_SSL_ALERT_MSG_UNRECOGNIZED_NAME 112 /* 0x70 */
304 #define MBEDTLS_SSL_ALERT_MSG_UNKNOWN_PSK_IDENTITY 115 /* 0x73 */
305 #define MBEDTLS_SSL_ALERT_MSG_NO_APPLICATION_PROTOCOL 120 /* 0x78 */
306 
307 #define MBEDTLS_SSL_HS_HELLO_REQUEST 0
308 #define MBEDTLS_SSL_HS_CLIENT_HELLO 1
309 #define MBEDTLS_SSL_HS_SERVER_HELLO 2
310 #define MBEDTLS_SSL_HS_HELLO_VERIFY_REQUEST 3
311 #define MBEDTLS_SSL_HS_NEW_SESSION_TICKET 4
312 #define MBEDTLS_SSL_HS_CERTIFICATE 11
313 #define MBEDTLS_SSL_HS_SERVER_KEY_EXCHANGE 12
314 #define MBEDTLS_SSL_HS_CERTIFICATE_REQUEST 13
315 #define MBEDTLS_SSL_HS_SERVER_HELLO_DONE 14
316 #define MBEDTLS_SSL_HS_CERTIFICATE_VERIFY 15
317 #define MBEDTLS_SSL_HS_CLIENT_KEY_EXCHANGE 16
318 #define MBEDTLS_SSL_HS_FINISHED 20
319 
320 /*
321  * TLS extensions
322  */
323 #define MBEDTLS_TLS_EXT_SERVERNAME 0
324 #define MBEDTLS_TLS_EXT_SERVERNAME_HOSTNAME 0
325 
326 #define MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH 1
327 
328 #define MBEDTLS_TLS_EXT_TRUNCATED_HMAC 4
329 
330 #define MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES 10
331 #define MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS 11
332 
333 #define MBEDTLS_TLS_EXT_SIG_ALG 13
334 
335 #define MBEDTLS_TLS_EXT_ALPN 16
336 
337 #define MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC 22 /* 0x16 */
338 #define MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET 0x0017 /* 23 */
339 
340 #define MBEDTLS_TLS_EXT_SESSION_TICKET 35
341 
342 #define MBEDTLS_TLS_EXT_ECJPAKE_KKPP 256 /* experimental */
343 
344 #define MBEDTLS_TLS_EXT_RENEGOTIATION_INFO 0xFF01
345 
346 /*
347  * Size defines
348  */
349 #if !defined(MBEDTLS_PSK_MAX_LEN)
350 #define MBEDTLS_PSK_MAX_LEN 32 /* 256 bits */
351 #endif
352 
353 /* Dummy type used only for its size */
355 {
356 #if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED)
357  unsigned char _pms_rsa[48]; /* RFC 5246 8.1.1 */
358 #endif
359 #if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED)
360  unsigned char _pms_dhm[MBEDTLS_MPI_MAX_SIZE]; /* RFC 5246 8.1.2 */
361 #endif
362 #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
363  defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \
364  defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \
365  defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)
366  unsigned char _pms_ecdh[MBEDTLS_ECP_MAX_BYTES]; /* RFC 4492 5.10 */
367 #endif
368 #if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED)
369  unsigned char _pms_psk[4 + 2 * MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 2 */
370 #endif
371 #if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED)
372  unsigned char _pms_dhe_psk[4 + MBEDTLS_MPI_MAX_SIZE
373  + MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 3 */
374 #endif
375 #if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED)
376  unsigned char _pms_rsa_psk[52 + MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 4 */
377 #endif
378 #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED)
379  unsigned char _pms_ecdhe_psk[4 + MBEDTLS_ECP_MAX_BYTES
380  + MBEDTLS_PSK_MAX_LEN]; /* RFC 5489 2 */
381 #endif
382 #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
383  unsigned char _pms_ecjpake[32]; /* Thread spec: SHA-256 output */
384 #endif
385 };
386 
387 #define MBEDTLS_PREMASTER_SIZE sizeof( union mbedtls_ssl_premaster_secret )
388 
389 #ifdef __cplusplus
390 extern "C" {
391 #endif
392 
393 /*
394  * SSL state machine
395  */
396 typedef enum
397 {
417 }
419 
437 typedef int mbedtls_ssl_send_t( void *ctx,
438  const unsigned char *buf,
439  size_t len );
440 
460 typedef int mbedtls_ssl_recv_t( void *ctx,
461  unsigned char *buf,
462  size_t len );
463 
486 typedef int mbedtls_ssl_recv_timeout_t( void *ctx,
487  unsigned char *buf,
488  size_t len,
489  uint32_t timeout );
512 typedef void mbedtls_ssl_set_timer_t( void * ctx,
513  uint32_t int_ms,
514  uint32_t fin_ms );
515 
527 typedef int mbedtls_ssl_get_timer_t( void * ctx );
528 
529 
530 /* Defined below */
534 
535 /* Defined in ssl_internal.h */
539 #if defined(MBEDTLS_X509_CRT_PARSE_C)
541 #endif
542 #if defined(MBEDTLS_SSL_PROTO_DTLS)
544 #endif
545 
546 /*
547  * This structure is used for storing current session data.
548  */
550 {
551 #if defined(MBEDTLS_HAVE_TIME)
553 #endif
556  size_t id_len;
557  unsigned char id[32];
558  unsigned char master[48];
560 #if defined(MBEDTLS_X509_CRT_PARSE_C)
562 #endif /* MBEDTLS_X509_CRT_PARSE_C */
563  uint32_t verify_result;
565 #if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_CLI_C)
566  unsigned char *ticket;
567  size_t ticket_len;
568  uint32_t ticket_lifetime;
569 #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_CLI_C */
570 
571 #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
572  unsigned char mfl_code;
573 #endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
574 
575 #if defined(MBEDTLS_SSL_TRUNCATED_HMAC)
577 #endif /* MBEDTLS_SSL_TRUNCATED_HMAC */
578 
579 #if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
581 #endif
582 };
583 
588 {
589  /* Group items by size (largest first) to minimize padding overhead */
590 
591  /*
592  * Pointers
593  */
594 
595  const int *ciphersuite_list[4];
598  void (*f_dbg)(void *, int, const char *, int, const char *);
599  void *p_dbg;
602  int (*f_rng)(void *, unsigned char *, size_t);
603  void *p_rng;
606  int (*f_get_cache)(void *, mbedtls_ssl_session *);
608  int (*f_set_cache)(void *, const mbedtls_ssl_session *);
609  void *p_cache;
611 #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
612 
613  int (*f_sni)(void *, mbedtls_ssl_context *, const unsigned char *, size_t);
614  void *p_sni;
615 #endif
616 
617 #if defined(MBEDTLS_X509_CRT_PARSE_C)
618 
619  int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *);
620  void *p_vrfy;
621 #endif
622 
623 #if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED)
624 
625  int (*f_psk)(void *, mbedtls_ssl_context *, const unsigned char *, size_t);
626  void *p_psk;
627 #endif
628 
629 #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C)
630 
631  int (*f_cookie_write)( void *, unsigned char **, unsigned char *,
632  const unsigned char *, size_t );
634  int (*f_cookie_check)( void *, const unsigned char *, size_t,
635  const unsigned char *, size_t );
636  void *p_cookie;
637 #endif
638 
639 #if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_SRV_C)
640 
641  int (*f_ticket_write)( void *, const mbedtls_ssl_session *,
642  unsigned char *, const unsigned char *, size_t *, uint32_t * );
644  int (*f_ticket_parse)( void *, mbedtls_ssl_session *, unsigned char *, size_t);
645  void *p_ticket;
646 #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_SRV_C */
647 
648 #if defined(MBEDTLS_SSL_EXPORT_KEYS)
649 
650  int (*f_export_keys)( void *, const unsigned char *,
651  const unsigned char *, size_t, size_t, size_t );
653 #endif
654 
655 #if defined(MBEDTLS_X509_CRT_PARSE_C)
658  mbedtls_x509_crt *ca_chain;
660 #endif /* MBEDTLS_X509_CRT_PARSE_C */
661 
662 #if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED)
663  const int *sig_hashes;
664 #endif
665 
666 #if defined(MBEDTLS_ECP_C)
668 #endif
669 
670 #if defined(MBEDTLS_DHM_C)
673 #endif
674 
675 #if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED)
676  unsigned char *psk;
677  size_t psk_len;
678  unsigned char *psk_identity;
680 #endif
681 
682 #if defined(MBEDTLS_SSL_ALPN)
683  const char **alpn_list;
684 #endif
685 
686  /*
687  * Numerical settings (int then char)
688  */
689 
690  uint32_t read_timeout;
692 #if defined(MBEDTLS_SSL_PROTO_DTLS)
693  uint32_t hs_timeout_min;
695  uint32_t hs_timeout_max;
697 #endif
698 
699 #if defined(MBEDTLS_SSL_RENEGOTIATION)
701  unsigned char renego_period[8];
703 #endif
704 
705 #if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT)
706  unsigned int badmac_limit;
707 #endif
708 
709 #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C)
710  unsigned int dhm_min_bitlen;
711 #endif
712 
713  unsigned char max_major_ver;
714  unsigned char max_minor_ver;
715  unsigned char min_major_ver;
716  unsigned char min_minor_ver;
718  /*
719  * Flags (bitfields)
720  */
721 
722  unsigned int endpoint : 1;
723  unsigned int transport : 1;
724  unsigned int authmode : 2;
725  /* needed even with renego disabled for LEGACY_BREAK_HANDSHAKE */
726  unsigned int allow_legacy_renegotiation : 2 ;
727 #if defined(MBEDTLS_ARC4_C)
728  unsigned int arc4_disabled : 1;
729 #endif
730 #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
731  unsigned int mfl_code : 3;
732 #endif
733 #if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
734  unsigned int encrypt_then_mac : 1 ;
735 #endif
736 #if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET)
737  unsigned int extended_ms : 1;
738 #endif
739 #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)
740  unsigned int anti_replay : 1;
741 #endif
742 #if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING)
743  unsigned int cbc_record_splitting : 1;
744 #endif
745 #if defined(MBEDTLS_SSL_RENEGOTIATION)
746  unsigned int disable_renegotiation : 1;
747 #endif
748 #if defined(MBEDTLS_SSL_TRUNCATED_HMAC)
749  unsigned int trunc_hmac : 1;
750 #endif
751 #if defined(MBEDTLS_SSL_SESSION_TICKETS)
752  unsigned int session_tickets : 1;
753 #endif
754 #if defined(MBEDTLS_SSL_FALLBACK_SCSV) && defined(MBEDTLS_SSL_CLI_C)
755  unsigned int fallback : 1;
756 #endif
757 #if defined(MBEDTLS_SSL_SRV_C)
758  unsigned int cert_req_ca_list : 1;
760 #endif
761 };
762 
763 
765 {
768  /*
769  * Miscellaneous
770  */
771  int state;
772 #if defined(MBEDTLS_SSL_RENEGOTIATION)
777 #endif
778 
779  int major_ver;
780  int minor_ver;
782 #if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT)
783  unsigned badmac_seen;
784 #endif
785 
791  void *p_bio;
793  /*
794  * Session layer
795  */
804  /*
805  * Record layer transformations
806  */
812  /*
813  * Timers
814  */
815  void *p_timer;
820  /*
821  * Record layer (incoming data)
822  */
823  unsigned char *in_buf;
824  unsigned char *in_ctr;
827  unsigned char *in_hdr;
828  unsigned char *in_len;
829  unsigned char *in_iv;
830  unsigned char *in_msg;
831  unsigned char *in_offt;
834  size_t in_msglen;
835  size_t in_left;
836 #if defined(MBEDTLS_SSL_PROTO_DTLS)
837  uint16_t in_epoch;
840 #endif
841 #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)
842  uint64_t in_window_top;
843  uint64_t in_window;
844 #endif
845 
846  size_t in_hslen;
848  int nb_zero;
853  /*
854  * Record layer (outgoing data)
855  */
856  unsigned char *out_buf;
857  unsigned char *out_ctr;
858  unsigned char *out_hdr;
859  unsigned char *out_len;
860  unsigned char *out_iv;
861  unsigned char *out_msg;
864  size_t out_msglen;
865  size_t out_left;
867 #if defined(MBEDTLS_ZLIB_SUPPORT)
868  unsigned char *compress_buf;
869 #endif
870 #if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING)
871  signed char split_done;
872 #endif
873 
874  /*
875  * PKI layer
876  */
879  /*
880  * User settings
881  */
882 #if defined(MBEDTLS_X509_CRT_PARSE_C)
883  char *hostname;
885 #endif
886 
887 #if defined(MBEDTLS_SSL_ALPN)
888  const char *alpn_chosen;
889 #endif
890 
891  /*
892  * Information for DTLS hello verify
893  */
894 #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C)
895  unsigned char *cli_id;
896  size_t cli_id_len;
897 #endif
898 
899  /*
900  * Secure renegotiation
901  */
902  /* needed to know when to send extension on server */
905 #if defined(MBEDTLS_SSL_RENEGOTIATION)
907  char own_verify_data[MBEDTLS_SSL_VERIFY_DATA_MAX_LEN];
908  char peer_verify_data[MBEDTLS_SSL_VERIFY_DATA_MAX_LEN];
909 #endif
910 };
911 
912 #if defined(MBEDTLS_SSL_HW_RECORD_ACCEL)
913 
914 #define MBEDTLS_SSL_CHANNEL_OUTBOUND 0
915 #define MBEDTLS_SSL_CHANNEL_INBOUND 1
916 
917 extern int (*mbedtls_ssl_hw_record_init)(mbedtls_ssl_context *ssl,
918  const unsigned char *key_enc, const unsigned char *key_dec,
919  size_t keylen,
920  const unsigned char *iv_enc, const unsigned char *iv_dec,
921  size_t ivlen,
922  const unsigned char *mac_enc, const unsigned char *mac_dec,
923  size_t maclen);
924 extern int (*mbedtls_ssl_hw_record_activate)(mbedtls_ssl_context *ssl, int direction);
925 extern int (*mbedtls_ssl_hw_record_reset)(mbedtls_ssl_context *ssl);
926 extern int (*mbedtls_ssl_hw_record_write)(mbedtls_ssl_context *ssl);
927 extern int (*mbedtls_ssl_hw_record_read)(mbedtls_ssl_context *ssl);
928 extern int (*mbedtls_ssl_hw_record_finish)(mbedtls_ssl_context *ssl);
929 #endif /* MBEDTLS_SSL_HW_RECORD_ACCEL */
930 
939 const char *mbedtls_ssl_get_ciphersuite_name( const int ciphersuite_id );
940 
949 int mbedtls_ssl_get_ciphersuite_id( const char *ciphersuite_name );
950 
959 
981  const mbedtls_ssl_config *conf );
982 
994 
1001 void mbedtls_ssl_conf_endpoint( mbedtls_ssl_config *conf, int endpoint );
1002 
1017 void mbedtls_ssl_conf_transport( mbedtls_ssl_config *conf, int transport );
1018 
1045 void mbedtls_ssl_conf_authmode( mbedtls_ssl_config *conf, int authmode );
1046 
1047 #if defined(MBEDTLS_X509_CRT_PARSE_C)
1048 
1060  int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *),
1061  void *p_vrfy );
1062 #endif /* MBEDTLS_X509_CRT_PARSE_C */
1063 
1072  int (*f_rng)(void *, unsigned char *, size_t),
1073  void *p_rng );
1074 
1090  void (*f_dbg)(void *, int, const char *, int, const char *),
1091  void *p_dbg );
1092 
1124  void *p_bio,
1125  mbedtls_ssl_send_t *f_send,
1126  mbedtls_ssl_recv_t *f_recv,
1127  mbedtls_ssl_recv_timeout_t *f_recv_timeout );
1128 
1145 void mbedtls_ssl_conf_read_timeout( mbedtls_ssl_config *conf, uint32_t timeout );
1146 
1168  void *p_timer,
1169  mbedtls_ssl_set_timer_t *f_set_timer,
1170  mbedtls_ssl_get_timer_t *f_get_timer );
1171 
1191 typedef int mbedtls_ssl_ticket_write_t( void *p_ticket,
1192  const mbedtls_ssl_session *session,
1193  unsigned char *start,
1194  const unsigned char *end,
1195  size_t *tlen,
1196  uint32_t *lifetime );
1197 
1198 #if defined(MBEDTLS_SSL_EXPORT_KEYS)
1199 
1219 typedef int mbedtls_ssl_export_keys_t( void *p_expkey,
1220  const unsigned char *ms,
1221  const unsigned char *kb,
1222  size_t maclen,
1223  size_t keylen,
1224  size_t ivlen );
1225 #endif /* MBEDTLS_SSL_EXPORT_KEYS */
1226 
1250 typedef int mbedtls_ssl_ticket_parse_t( void *p_ticket,
1251  mbedtls_ssl_session *session,
1252  unsigned char *buf,
1253  size_t len );
1254 
1255 #if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_SRV_C)
1256 
1271  mbedtls_ssl_ticket_write_t *f_ticket_write,
1272  mbedtls_ssl_ticket_parse_t *f_ticket_parse,
1273  void *p_ticket );
1274 #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_SRV_C */
1275 
1276 #if defined(MBEDTLS_SSL_EXPORT_KEYS)
1277 
1288  mbedtls_ssl_export_keys_t *f_export_keys,
1289  void *p_export_keys );
1290 #endif /* MBEDTLS_SSL_EXPORT_KEYS */
1291 
1306 typedef int mbedtls_ssl_cookie_write_t( void *ctx,
1307  unsigned char **p, unsigned char *end,
1308  const unsigned char *info, size_t ilen );
1309 
1323 typedef int mbedtls_ssl_cookie_check_t( void *ctx,
1324  const unsigned char *cookie, size_t clen,
1325  const unsigned char *info, size_t ilen );
1326 
1327 #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C)
1328 
1357  mbedtls_ssl_cookie_write_t *f_cookie_write,
1358  mbedtls_ssl_cookie_check_t *f_cookie_check,
1359  void *p_cookie );
1360 
1381  const unsigned char *info,
1382  size_t ilen );
1383 
1384 #endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY && MBEDTLS_SSL_SRV_C */
1385 
1386 #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)
1387 
1402 void mbedtls_ssl_conf_dtls_anti_replay( mbedtls_ssl_config *conf, char mode );
1403 #endif /* MBEDTLS_SSL_DTLS_ANTI_REPLAY */
1404 
1405 #if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT)
1406 
1429 void mbedtls_ssl_conf_dtls_badmac_limit( mbedtls_ssl_config *conf, unsigned limit );
1430 #endif /* MBEDTLS_SSL_DTLS_BADMAC_LIMIT */
1431 
1432 #if defined(MBEDTLS_SSL_PROTO_DTLS)
1433 
1464 void mbedtls_ssl_conf_handshake_timeout( mbedtls_ssl_config *conf, uint32_t min, uint32_t max );
1465 #endif /* MBEDTLS_SSL_PROTO_DTLS */
1466 
1467 #if defined(MBEDTLS_SSL_SRV_C)
1468 
1506  void *p_cache,
1507  int (*f_get_cache)(void *, mbedtls_ssl_session *),
1508  int (*f_set_cache)(void *, const mbedtls_ssl_session *) );
1509 #endif /* MBEDTLS_SSL_SRV_C */
1510 
1511 #if defined(MBEDTLS_SSL_CLI_C)
1512 
1527 #endif /* MBEDTLS_SSL_CLI_C */
1528 
1545  const int *ciphersuites );
1546 
1567  const int *ciphersuites,
1568  int major, int minor );
1569 
1570 #if defined(MBEDTLS_X509_CRT_PARSE_C)
1571 
1582  const mbedtls_x509_crt_profile *profile );
1583 
1596  mbedtls_x509_crt *ca_chain,
1597  mbedtls_x509_crl *ca_crl );
1598 
1628  mbedtls_x509_crt *own_cert,
1629  mbedtls_pk_context *pk_key );
1630 #endif /* MBEDTLS_X509_CRT_PARSE_C */
1631 
1632 #if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED)
1633 
1654  const unsigned char *psk, size_t psk_len,
1655  const unsigned char *psk_identity, size_t psk_identity_len );
1656 
1657 
1671  const unsigned char *psk, size_t psk_len );
1672 
1698  int (*f_psk)(void *, mbedtls_ssl_context *, const unsigned char *,
1699  size_t),
1700  void *p_psk );
1701 #endif /* MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED */
1702 
1703 #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_SRV_C)
1704 
1705 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
1706 
1707 #if defined(MBEDTLS_DEPRECATED_WARNING)
1708 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
1709 #else
1710 #define MBEDTLS_DEPRECATED
1711 #endif
1712 
1727  const char *dhm_P,
1728  const char *dhm_G );
1729 
1730 #endif /* MBEDTLS_DEPRECATED_REMOVED */
1731 
1746  const unsigned char *dhm_P, size_t P_len,
1747  const unsigned char *dhm_G, size_t G_len );
1748 
1759 #endif /* MBEDTLS_DHM_C && defined(MBEDTLS_SSL_SRV_C) */
1760 
1761 #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C)
1762 
1771  unsigned int bitlen );
1772 #endif /* MBEDTLS_DHM_C && MBEDTLS_SSL_CLI_C */
1773 
1774 #if defined(MBEDTLS_ECP_C)
1775 
1803  const mbedtls_ecp_group_id *curves );
1804 #endif /* MBEDTLS_ECP_C */
1805 
1806 #if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED)
1807 
1826  const int *hashes );
1827 #endif /* MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */
1828 
1829 #if defined(MBEDTLS_X509_CRT_PARSE_C)
1830 
1848 int mbedtls_ssl_set_hostname( mbedtls_ssl_context *ssl, const char *hostname );
1849 #endif /* MBEDTLS_X509_CRT_PARSE_C */
1850 
1851 #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
1852 
1865  mbedtls_x509_crt *own_cert,
1866  mbedtls_pk_context *pk_key );
1867 
1880  mbedtls_x509_crt *ca_chain,
1881  mbedtls_x509_crl *ca_crl );
1882 
1894  int authmode );
1895 
1920  int (*f_sni)(void *, mbedtls_ssl_context *, const unsigned char *,
1921  size_t),
1922  void *p_sni );
1923 #endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */
1924 
1925 #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
1926 
1943 int mbedtls_ssl_set_hs_ecjpake_password( mbedtls_ssl_context *ssl,
1944  const unsigned char *pw,
1945  size_t pw_len );
1946 #endif /*MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */
1947 
1948 #if defined(MBEDTLS_SSL_ALPN)
1949 
1961 int mbedtls_ssl_conf_alpn_protocols( mbedtls_ssl_config *conf, const char **protos );
1962 
1972 const char *mbedtls_ssl_get_alpn_protocol( const mbedtls_ssl_context *ssl );
1973 #endif /* MBEDTLS_SSL_ALPN */
1974 
1991 void mbedtls_ssl_conf_max_version( mbedtls_ssl_config *conf, int major, int minor );
1992 
2011 void mbedtls_ssl_conf_min_version( mbedtls_ssl_config *conf, int major, int minor );
2012 
2013 #if defined(MBEDTLS_SSL_FALLBACK_SCSV) && defined(MBEDTLS_SSL_CLI_C)
2014 
2033 void mbedtls_ssl_conf_fallback( mbedtls_ssl_config *conf, char fallback );
2034 #endif /* MBEDTLS_SSL_FALLBACK_SCSV && MBEDTLS_SSL_CLI_C */
2035 
2036 #if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
2037 
2049 #endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */
2050 
2051 #if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET)
2052 
2064 #endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */
2065 
2066 #if defined(MBEDTLS_ARC4_C)
2067 
2082 void mbedtls_ssl_conf_arc4_support( mbedtls_ssl_config *conf, char arc4 );
2083 #endif /* MBEDTLS_ARC4_C */
2084 
2085 #if defined(MBEDTLS_SSL_SRV_C)
2086 
2096  char cert_req_ca_list );
2097 #endif /* MBEDTLS_SSL_SRV_C */
2098 
2099 #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
2100 
2115 int mbedtls_ssl_conf_max_frag_len( mbedtls_ssl_config *conf, unsigned char mfl_code );
2116 #endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
2117 
2118 #if defined(MBEDTLS_SSL_TRUNCATED_HMAC)
2119 
2127 void mbedtls_ssl_conf_truncated_hmac( mbedtls_ssl_config *conf, int truncate );
2128 #endif /* MBEDTLS_SSL_TRUNCATED_HMAC */
2129 
2130 #if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING)
2131 
2143 #endif /* MBEDTLS_SSL_CBC_RECORD_SPLITTING */
2144 
2145 #if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_CLI_C)
2146 
2156 void mbedtls_ssl_conf_session_tickets( mbedtls_ssl_config *conf, int use_tickets );
2157 #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_CLI_C */
2158 
2159 #if defined(MBEDTLS_SSL_RENEGOTIATION)
2160 
2177 void mbedtls_ssl_conf_renegotiation( mbedtls_ssl_config *conf, int renegotiation );
2178 #endif /* MBEDTLS_SSL_RENEGOTIATION */
2179 
2207 void mbedtls_ssl_conf_legacy_renegotiation( mbedtls_ssl_config *conf, int allow_legacy );
2208 
2209 #if defined(MBEDTLS_SSL_RENEGOTIATION)
2210 
2247 void mbedtls_ssl_conf_renegotiation_enforced( mbedtls_ssl_config *conf, int max_records );
2248 
2275  const unsigned char period[8] );
2276 #endif /* MBEDTLS_SSL_RENEGOTIATION */
2277 
2286 
2298 uint32_t mbedtls_ssl_get_verify_result( const mbedtls_ssl_context *ssl );
2299 
2307 const char *mbedtls_ssl_get_ciphersuite( const mbedtls_ssl_context *ssl );
2308 
2316 const char *mbedtls_ssl_get_version( const mbedtls_ssl_context *ssl );
2317 
2329 
2330 #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
2331 
2348 #endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
2349 
2350 #if defined(MBEDTLS_X509_CRT_PARSE_C)
2351 
2366 #endif /* MBEDTLS_X509_CRT_PARSE_C */
2367 
2368 #if defined(MBEDTLS_SSL_CLI_C)
2369 
2396 #endif /* MBEDTLS_SSL_CLI_C */
2397 
2420 
2441 
2442 #if defined(MBEDTLS_SSL_RENEGOTIATION)
2443 
2462 #endif /* MBEDTLS_SSL_RENEGOTIATION */
2463 
2498 int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len );
2499 
2542 int mbedtls_ssl_write( mbedtls_ssl_context *ssl, const unsigned char *buf, size_t len );
2543 
2561  unsigned char level,
2562  unsigned char message );
2577 
2584 
2596 
2613  int endpoint, int transport, int preset );
2614 
2621 
2628 
2639 
2640 #ifdef __cplusplus
2641 }
2642 #endif
2643 
2644 #endif /* ssl.h */
uint64_t in_window_top
Definition: ssl.h:842
mbedtls_ssl_send_t * f_send
Definition: ssl.h:786
void * p_rng
Definition: ssl.h:603
const char ** alpn_list
Definition: ssl.h:683
unsigned int transport
Definition: ssl.h:723
unsigned char * in_ctr
Definition: ssl.h:824
mbedtls_x509_crt * peer_cert
Definition: ssl.h:561
unsigned char * out_msg
Definition: ssl.h:861
unsigned int trunc_hmac
Definition: ssl.h:749
unsigned char * in_len
Definition: ssl.h:828
unsigned char * in_buf
Definition: ssl.h:823
unsigned int endpoint
Definition: ssl.h:722
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:1250
mbedtls_mpi dhm_P
Definition: ssl.h:671
unsigned char max_minor_ver
Definition: ssl.h:714
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:716
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:1306
unsigned char * in_hdr
Definition: ssl.h:827
size_t psk_identity_len
Definition: ssl.h:679
unsigned int dhm_min_bitlen
Definition: ssl.h:710
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:1323
void * p_sni
Definition: ssl.h:614
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:566
struct mbedtls_ssl_sig_hash_set_t mbedtls_ssl_sig_hash_set_t
Definition: ssl.h:538
size_t ticket_len
Definition: ssl.h:567
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:860
mbedtls_ssl_transform * transform_in
Definition: ssl.h:807
size_t in_left
Definition: ssl.h:835
unsigned int authmode
Definition: ssl.h:724
int mbedtls_ssl_send_t(void *ctx, const unsigned char *buf, size_t len)
Callback type: send data on the network.
Definition: ssl.h:437
unsigned int badmac_limit
Definition: ssl.h:706
void * p_psk
Definition: ssl.h:626
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:740
int mbedtls_ssl_recv_t(void *ctx, unsigned char *buf, size_t len)
Callback type: receive data from the network.
Definition: ssl.h:460
unsigned int fallback
Definition: ssl.h:755
const mbedtls_ecp_group_id * curve_list
Definition: ssl.h:667
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:360
void * p_cache
Definition: ssl.h:609
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:758
unsigned char _pms_rsa[48]
Definition: ssl.h:357
unsigned char _pms_ecdh[MBEDTLS_ECP_MAX_BYTES]
Definition: ssl.h:366
uint32_t ticket_lifetime
Definition: ssl.h:568
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:796
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:783
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:818
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:659
mbedtls_ssl_session * session_out
Definition: ssl.h:797
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:486
SSL Ciphersuites for mbed TLS.
mbedtls_ssl_transform * transform_out
Definition: ssl.h:808
unsigned char mfl_code
Definition: ssl.h:572
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:731
Multi-precision integer library.
int encrypt_then_mac
Definition: ssl.h:580
size_t in_hslen
Definition: ssl.h:846
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:843
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:543
void * p_cookie
Definition: ssl.h:636
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:809
uint32_t hs_timeout_min
Definition: ssl.h:693
mbedtls_ssl_handshake_params * handshake
Definition: ssl.h:801
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:865
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:830
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:715
struct mbedtls_ssl_transform mbedtls_ssl_transform
Definition: ssl.h:536
mbedtls_ssl_set_timer_t * f_set_timer
Definition: ssl.h:817
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:657
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:787
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:799
mbedtls_ssl_states
Definition: ssl.h:396
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:663
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:1710
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:556
unsigned int encrypt_then_mac
Definition: ssl.h:734
void * p_bio
Definition: ssl.h:791
unsigned int cbc_record_splitting
Definition: ssl.h:743
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:773
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:380
void * p_vrfy
Definition: ssl.h:620
const mbedtls_x509_crt_profile * cert_profile
Definition: ssl.h:656
void * p_timer
Definition: ssl.h:815
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:350
unsigned int session_tickets
Definition: ssl.h:752
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:798
unsigned char * in_iv
Definition: ssl.h:829
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:810
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:857
int secure_renegotiation
Definition: ssl.h:903
int mbedtls_ssl_get_timer_t(void *ctx)
Callback type: get status of timers/delays.
Definition: ssl.h:527
The DHM context structure.
Definition: dhm.h:92
const mbedtls_ssl_config * conf
Definition: ssl.h:766
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:831
unsigned int extended_ms
Definition: ssl.h:737
unsigned char max_major_ver
Definition: ssl.h:713
unsigned char * psk
Definition: ssl.h:676
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:888
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:672
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:746
void * p_export_keys
Definition: ssl.h:652
char * hostname
Definition: ssl.h:883
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:864
uint32_t read_timeout
Definition: ssl.h:690
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:376
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:1219
unsigned char * out_len
Definition: ssl.h:859
unsigned int arc4_disabled
Definition: ssl.h:728
uint32_t hs_timeout_max
Definition: ssl.h:695
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:895
int renego_max_records
Definition: ssl.h:700
mbedtls_ssl_recv_timeout_t * f_recv_timeout
Definition: ssl.h:788
mbedtls_x509_crt * ca_chain
Definition: ssl.h:658
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:906
void mbedtls_ssl_config_free(mbedtls_ssl_config *conf)
Free an SSL configuration context.
unsigned char * psk_identity
Definition: ssl.h:678
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:540
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:512
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:373
size_t next_record_offset
Definition: ssl.h:838
unsigned char * out_buf
Definition: ssl.h:856
size_t psk_len
Definition: ssl.h:677
void mbedtls_ssl_session_init(mbedtls_ssl_session *session)
Initialize SSL session structure.
void * p_dbg
Definition: ssl.h:599
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:1191
size_t cli_id_len
Definition: ssl.h:896
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:774
unsigned char * out_hdr
Definition: ssl.h:858
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:369
uint32_t verify_result
Definition: ssl.h:563
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:726
int keep_current_message
Definition: ssl.h:850
signed char split_done
Definition: ssl.h:871
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:537
#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:645
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:234
mbedtls_time_t start
Definition: ssl.h:552
size_t in_msglen
Definition: ssl.h:834
uint16_t in_epoch
Definition: ssl.h:837