mbed TLS v2.16.12
ssl.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright The Mbed TLS Contributors
8  * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
9  *
10  * This file is provided under the Apache License 2.0, or the
11  * GNU General Public License v2.0 or later.
12  *
13  * **********
14  * Apache License 2.0:
15  *
16  * Licensed under the Apache License, Version 2.0 (the "License"); you may
17  * not use this file except in compliance with the License.
18  * You may obtain a copy of the License at
19  *
20  * http://www.apache.org/licenses/LICENSE-2.0
21  *
22  * Unless required by applicable law or agreed to in writing, software
23  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
24  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25  * See the License for the specific language governing permissions and
26  * limitations under the License.
27  *
28  * **********
29  *
30  * **********
31  * GNU General Public License v2.0 or later:
32  *
33  * This program is free software; you can redistribute it and/or modify
34  * it under the terms of the GNU General Public License as published by
35  * the Free Software Foundation; either version 2 of the License, or
36  * (at your option) any later version.
37  *
38  * This program is distributed in the hope that it will be useful,
39  * but WITHOUT ANY WARRANTY; without even the implied warranty of
40  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41  * GNU General Public License for more details.
42  *
43  * You should have received a copy of the GNU General Public License along
44  * with this program; if not, write to the Free Software Foundation, Inc.,
45  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
46  *
47  * **********
48  */
49 #ifndef MBEDTLS_SSL_H
50 #define MBEDTLS_SSL_H
51 
52 #if !defined(MBEDTLS_CONFIG_FILE)
53 #include "config.h"
54 #else
55 #include MBEDTLS_CONFIG_FILE
56 #endif
57 
58 #include "bignum.h"
59 #include "ecp.h"
60 
61 #include "ssl_ciphersuites.h"
62 
63 #if defined(MBEDTLS_X509_CRT_PARSE_C)
64 #include "x509_crt.h"
65 #include "x509_crl.h"
66 #endif
67 
68 #if defined(MBEDTLS_DHM_C)
69 #include "dhm.h"
70 #endif
71 
72 #if defined(MBEDTLS_ECDH_C)
73 #include "ecdh.h"
74 #endif
75 
76 #if defined(MBEDTLS_ZLIB_SUPPORT)
77 
78 #if defined(MBEDTLS_DEPRECATED_WARNING)
79 #warning "Record compression support via MBEDTLS_ZLIB_SUPPORT is deprecated and will be removed in the next major revision of the library"
80 #endif
81 
82 #if defined(MBEDTLS_DEPRECATED_REMOVED)
83 #error "Record compression support via MBEDTLS_ZLIB_SUPPORT is deprecated and cannot be used if MBEDTLS_DEPRECATED_REMOVED is set"
84 #endif
85 
86 #include "zlib.h"
87 #endif
88 
89 #if defined(MBEDTLS_HAVE_TIME)
90 #include "platform_time.h"
91 #endif
92 
93 /*
94  * SSL Error codes
95  */
97 #define MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE -0x7080
98 
99 #define MBEDTLS_ERR_SSL_BAD_INPUT_DATA -0x7100
100 
101 #define MBEDTLS_ERR_SSL_INVALID_MAC -0x7180
102 
103 #define MBEDTLS_ERR_SSL_INVALID_RECORD -0x7200
104 
105 #define MBEDTLS_ERR_SSL_CONN_EOF -0x7280
106 
107 #define MBEDTLS_ERR_SSL_UNKNOWN_CIPHER -0x7300
108 
109 #define MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN -0x7380
110 
111 #define MBEDTLS_ERR_SSL_NO_RNG -0x7400
112 
113 #define MBEDTLS_ERR_SSL_NO_CLIENT_CERTIFICATE -0x7480
114 
115 #define MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE -0x7500
116 
117 #define MBEDTLS_ERR_SSL_CERTIFICATE_REQUIRED -0x7580
118 
119 #define MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED -0x7600
120 
121 #define MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED -0x7680
122 
123 #define MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE -0x7700
124 
125 #define MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE -0x7780
126 
127 #define MBEDTLS_ERR_SSL_PEER_VERIFY_FAILED -0x7800
128 
129 #define MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY -0x7880
130 
131 #define MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO -0x7900
132 
133 #define MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO -0x7980
134 
135 #define MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE -0x7A00
136 
137 #define MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST -0x7A80
138 
139 #define MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE -0x7B00
140 
141 #define MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO_DONE -0x7B80
142 
143 #define MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE -0x7C00
144 
145 #define MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP -0x7C80
146 
147 #define MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS -0x7D00
148 
149 #define MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY -0x7D80
150 
151 #define MBEDTLS_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC -0x7E00
152 
153 #define MBEDTLS_ERR_SSL_BAD_HS_FINISHED -0x7E80
154 
155 #define MBEDTLS_ERR_SSL_ALLOC_FAILED -0x7F00
156 
157 #define MBEDTLS_ERR_SSL_HW_ACCEL_FAILED -0x7F80
158 
159 #define MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH -0x6F80
160 
161 #define MBEDTLS_ERR_SSL_COMPRESSION_FAILED -0x6F00
162 
163 #define MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION -0x6E80
164 
165 #define MBEDTLS_ERR_SSL_BAD_HS_NEW_SESSION_TICKET -0x6E00
166 
167 #define MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED -0x6D80
168 
169 #define MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH -0x6D00
170 
171 #define MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY -0x6C80
172 
173 #define MBEDTLS_ERR_SSL_INTERNAL_ERROR -0x6C00
174 
175 #define MBEDTLS_ERR_SSL_COUNTER_WRAPPING -0x6B80
176 
177 #define MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO -0x6B00
178 
179 #define MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED -0x6A80
180 
181 #define MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL -0x6A00
182 
183 #define MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE -0x6980
184 
185 #define MBEDTLS_ERR_SSL_WANT_READ -0x6900
186 
187 #define MBEDTLS_ERR_SSL_WANT_WRITE -0x6880
188 
189 #define MBEDTLS_ERR_SSL_TIMEOUT -0x6800
190 
191 #define MBEDTLS_ERR_SSL_CLIENT_RECONNECT -0x6780
192 
193 #define MBEDTLS_ERR_SSL_UNEXPECTED_RECORD -0x6700
194 
195 #define MBEDTLS_ERR_SSL_NON_FATAL -0x6680
196 
197 #define MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH -0x6600
198 
199 #define MBEDTLS_ERR_SSL_CONTINUE_PROCESSING -0x6580
200 
201 #define MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS -0x6500
202 
203 #define MBEDTLS_ERR_SSL_EARLY_MESSAGE -0x6480
204 
205 #define MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS -0x7000
206 
207 #define MBEDTLS_ERR_SSL_BAD_CONFIG -0x5E80
208 
209 /*
210  * Various constants
211  */
212 #define MBEDTLS_SSL_MAJOR_VERSION_3 3
213 #define MBEDTLS_SSL_MINOR_VERSION_0 0
214 #define MBEDTLS_SSL_MINOR_VERSION_1 1
215 #define MBEDTLS_SSL_MINOR_VERSION_2 2
216 #define MBEDTLS_SSL_MINOR_VERSION_3 3
218 #define MBEDTLS_SSL_TRANSPORT_STREAM 0
219 #define MBEDTLS_SSL_TRANSPORT_DATAGRAM 1
221 #define MBEDTLS_SSL_MAX_HOST_NAME_LEN 255
222 #define MBEDTLS_SSL_MAX_ALPN_NAME_LEN 255
224 #define MBEDTLS_SSL_MAX_ALPN_LIST_LEN 65535
226 /* RFC 6066 section 4, see also mfl_code_to_length in ssl_tls.c
227  * NONE must be zero so that memset()ing structure to zero works */
228 #define MBEDTLS_SSL_MAX_FRAG_LEN_NONE 0
229 #define MBEDTLS_SSL_MAX_FRAG_LEN_512 1
230 #define MBEDTLS_SSL_MAX_FRAG_LEN_1024 2
231 #define MBEDTLS_SSL_MAX_FRAG_LEN_2048 3
232 #define MBEDTLS_SSL_MAX_FRAG_LEN_4096 4
233 #define MBEDTLS_SSL_MAX_FRAG_LEN_INVALID 5
235 #define MBEDTLS_SSL_IS_CLIENT 0
236 #define MBEDTLS_SSL_IS_SERVER 1
237 
238 #define MBEDTLS_SSL_IS_NOT_FALLBACK 0
239 #define MBEDTLS_SSL_IS_FALLBACK 1
240 
241 #define MBEDTLS_SSL_EXTENDED_MS_DISABLED 0
242 #define MBEDTLS_SSL_EXTENDED_MS_ENABLED 1
243 
244 #define MBEDTLS_SSL_ETM_DISABLED 0
245 #define MBEDTLS_SSL_ETM_ENABLED 1
246 
247 #define MBEDTLS_SSL_COMPRESS_NULL 0
248 #define MBEDTLS_SSL_COMPRESS_DEFLATE 1
249 
250 #define MBEDTLS_SSL_VERIFY_NONE 0
251 #define MBEDTLS_SSL_VERIFY_OPTIONAL 1
252 #define MBEDTLS_SSL_VERIFY_REQUIRED 2
253 #define MBEDTLS_SSL_VERIFY_UNSET 3 /* Used only for sni_authmode */
254 
255 #define MBEDTLS_SSL_LEGACY_RENEGOTIATION 0
256 #define MBEDTLS_SSL_SECURE_RENEGOTIATION 1
257 
258 #define MBEDTLS_SSL_RENEGOTIATION_DISABLED 0
259 #define MBEDTLS_SSL_RENEGOTIATION_ENABLED 1
260 
261 #define MBEDTLS_SSL_ANTI_REPLAY_DISABLED 0
262 #define MBEDTLS_SSL_ANTI_REPLAY_ENABLED 1
263 
264 #define MBEDTLS_SSL_RENEGOTIATION_NOT_ENFORCED -1
265 #define MBEDTLS_SSL_RENEGO_MAX_RECORDS_DEFAULT 16
266 
267 #define MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION 0
268 #define MBEDTLS_SSL_LEGACY_ALLOW_RENEGOTIATION 1
269 #define MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE 2
270 
271 #define MBEDTLS_SSL_TRUNC_HMAC_DISABLED 0
272 #define MBEDTLS_SSL_TRUNC_HMAC_ENABLED 1
273 #define MBEDTLS_SSL_TRUNCATED_HMAC_LEN 10 /* 80 bits, rfc 6066 section 7 */
274 
275 #define MBEDTLS_SSL_SESSION_TICKETS_DISABLED 0
276 #define MBEDTLS_SSL_SESSION_TICKETS_ENABLED 1
277 
278 #define MBEDTLS_SSL_CBC_RECORD_SPLITTING_DISABLED 0
279 #define MBEDTLS_SSL_CBC_RECORD_SPLITTING_ENABLED 1
280 
281 #define MBEDTLS_SSL_ARC4_ENABLED 0
282 #define MBEDTLS_SSL_ARC4_DISABLED 1
283 
284 #define MBEDTLS_SSL_PRESET_DEFAULT 0
285 #define MBEDTLS_SSL_PRESET_SUITEB 2
286 
287 #define MBEDTLS_SSL_CERT_REQ_CA_LIST_ENABLED 1
288 #define MBEDTLS_SSL_CERT_REQ_CA_LIST_DISABLED 0
289 
290 /*
291  * Default range for DTLS retransmission timer value, in milliseconds.
292  * RFC 6347 4.2.4.1 says from 1 second to 60 seconds.
293  */
294 #define MBEDTLS_SSL_DTLS_TIMEOUT_DFL_MIN 1000
295 #define MBEDTLS_SSL_DTLS_TIMEOUT_DFL_MAX 60000
296 
305 #if !defined(MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME)
306 #define MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME 86400
307 #endif
308 
309 /*
310  * Maximum fragment length in bytes,
311  * determines the size of each of the two internal I/O buffers.
312  *
313  * Note: the RFC defines the default size of SSL / TLS messages. If you
314  * change the value here, other clients / servers may not be able to
315  * communicate with you anymore. Only change this value if you control
316  * both sides of the connection and have it reduced at both sides, or
317  * if you're using the Max Fragment Length extension and you know all your
318  * peers are using it too!
319  */
320 #if !defined(MBEDTLS_SSL_MAX_CONTENT_LEN)
321 #define MBEDTLS_SSL_MAX_CONTENT_LEN 16384
322 #endif
323 
324 #if !defined(MBEDTLS_SSL_IN_CONTENT_LEN)
325 #define MBEDTLS_SSL_IN_CONTENT_LEN MBEDTLS_SSL_MAX_CONTENT_LEN
326 #endif
327 
328 #if !defined(MBEDTLS_SSL_OUT_CONTENT_LEN)
329 #define MBEDTLS_SSL_OUT_CONTENT_LEN MBEDTLS_SSL_MAX_CONTENT_LEN
330 #endif
331 
332 /*
333  * Maximum number of heap-allocated bytes for the purpose of
334  * DTLS handshake message reassembly and future message buffering.
335  */
336 #if !defined(MBEDTLS_SSL_DTLS_MAX_BUFFERING)
337 #define MBEDTLS_SSL_DTLS_MAX_BUFFERING 32768
338 #endif
339 
340 /* \} name SECTION: Module settings */
341 
342 /*
343  * Length of the verify data for secure renegotiation
344  */
345 #if defined(MBEDTLS_SSL_PROTO_SSL3)
346 #define MBEDTLS_SSL_VERIFY_DATA_MAX_LEN 36
347 #else
348 #define MBEDTLS_SSL_VERIFY_DATA_MAX_LEN 12
349 #endif
350 
351 /*
352  * Signaling ciphersuite values (SCSV)
353  */
354 #define MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO 0xFF
355 #define MBEDTLS_SSL_FALLBACK_SCSV_VALUE 0x5600
357 /*
358  * Supported Signature and Hash algorithms (For TLS 1.2)
359  * RFC 5246 section 7.4.1.4.1
360  */
361 #define MBEDTLS_SSL_HASH_NONE 0
362 #define MBEDTLS_SSL_HASH_MD5 1
363 #define MBEDTLS_SSL_HASH_SHA1 2
364 #define MBEDTLS_SSL_HASH_SHA224 3
365 #define MBEDTLS_SSL_HASH_SHA256 4
366 #define MBEDTLS_SSL_HASH_SHA384 5
367 #define MBEDTLS_SSL_HASH_SHA512 6
368 
369 #define MBEDTLS_SSL_SIG_ANON 0
370 #define MBEDTLS_SSL_SIG_RSA 1
371 #define MBEDTLS_SSL_SIG_ECDSA 3
372 
373 /*
374  * Client Certificate Types
375  * RFC 5246 section 7.4.4 plus RFC 4492 section 5.5
376  */
377 #define MBEDTLS_SSL_CERT_TYPE_RSA_SIGN 1
378 #define MBEDTLS_SSL_CERT_TYPE_ECDSA_SIGN 64
379 
380 /*
381  * Message, alert and handshake types
382  */
383 #define MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC 20
384 #define MBEDTLS_SSL_MSG_ALERT 21
385 #define MBEDTLS_SSL_MSG_HANDSHAKE 22
386 #define MBEDTLS_SSL_MSG_APPLICATION_DATA 23
387 
388 #define MBEDTLS_SSL_ALERT_LEVEL_WARNING 1
389 #define MBEDTLS_SSL_ALERT_LEVEL_FATAL 2
390 
391 #define MBEDTLS_SSL_ALERT_MSG_CLOSE_NOTIFY 0 /* 0x00 */
392 #define MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE 10 /* 0x0A */
393 #define MBEDTLS_SSL_ALERT_MSG_BAD_RECORD_MAC 20 /* 0x14 */
394 #define MBEDTLS_SSL_ALERT_MSG_DECRYPTION_FAILED 21 /* 0x15 */
395 #define MBEDTLS_SSL_ALERT_MSG_RECORD_OVERFLOW 22 /* 0x16 */
396 #define MBEDTLS_SSL_ALERT_MSG_DECOMPRESSION_FAILURE 30 /* 0x1E */
397 #define MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE 40 /* 0x28 */
398 #define MBEDTLS_SSL_ALERT_MSG_NO_CERT 41 /* 0x29 */
399 #define MBEDTLS_SSL_ALERT_MSG_BAD_CERT 42 /* 0x2A */
400 #define MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT 43 /* 0x2B */
401 #define MBEDTLS_SSL_ALERT_MSG_CERT_REVOKED 44 /* 0x2C */
402 #define MBEDTLS_SSL_ALERT_MSG_CERT_EXPIRED 45 /* 0x2D */
403 #define MBEDTLS_SSL_ALERT_MSG_CERT_UNKNOWN 46 /* 0x2E */
404 #define MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER 47 /* 0x2F */
405 #define MBEDTLS_SSL_ALERT_MSG_UNKNOWN_CA 48 /* 0x30 */
406 #define MBEDTLS_SSL_ALERT_MSG_ACCESS_DENIED 49 /* 0x31 */
407 #define MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR 50 /* 0x32 */
408 #define MBEDTLS_SSL_ALERT_MSG_DECRYPT_ERROR 51 /* 0x33 */
409 #define MBEDTLS_SSL_ALERT_MSG_EXPORT_RESTRICTION 60 /* 0x3C */
410 #define MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION 70 /* 0x46 */
411 #define MBEDTLS_SSL_ALERT_MSG_INSUFFICIENT_SECURITY 71 /* 0x47 */
412 #define MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR 80 /* 0x50 */
413 #define MBEDTLS_SSL_ALERT_MSG_INAPROPRIATE_FALLBACK 86 /* 0x56 */
414 #define MBEDTLS_SSL_ALERT_MSG_USER_CANCELED 90 /* 0x5A */
415 #define MBEDTLS_SSL_ALERT_MSG_NO_RENEGOTIATION 100 /* 0x64 */
416 #define MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_EXT 110 /* 0x6E */
417 #define MBEDTLS_SSL_ALERT_MSG_UNRECOGNIZED_NAME 112 /* 0x70 */
418 #define MBEDTLS_SSL_ALERT_MSG_UNKNOWN_PSK_IDENTITY 115 /* 0x73 */
419 #define MBEDTLS_SSL_ALERT_MSG_NO_APPLICATION_PROTOCOL 120 /* 0x78 */
420 
421 #define MBEDTLS_SSL_HS_HELLO_REQUEST 0
422 #define MBEDTLS_SSL_HS_CLIENT_HELLO 1
423 #define MBEDTLS_SSL_HS_SERVER_HELLO 2
424 #define MBEDTLS_SSL_HS_HELLO_VERIFY_REQUEST 3
425 #define MBEDTLS_SSL_HS_NEW_SESSION_TICKET 4
426 #define MBEDTLS_SSL_HS_CERTIFICATE 11
427 #define MBEDTLS_SSL_HS_SERVER_KEY_EXCHANGE 12
428 #define MBEDTLS_SSL_HS_CERTIFICATE_REQUEST 13
429 #define MBEDTLS_SSL_HS_SERVER_HELLO_DONE 14
430 #define MBEDTLS_SSL_HS_CERTIFICATE_VERIFY 15
431 #define MBEDTLS_SSL_HS_CLIENT_KEY_EXCHANGE 16
432 #define MBEDTLS_SSL_HS_FINISHED 20
433 
434 /*
435  * TLS extensions
436  */
437 #define MBEDTLS_TLS_EXT_SERVERNAME 0
438 #define MBEDTLS_TLS_EXT_SERVERNAME_HOSTNAME 0
439 
440 #define MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH 1
441 
442 #define MBEDTLS_TLS_EXT_TRUNCATED_HMAC 4
443 
444 #define MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES 10
445 #define MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS 11
446 
447 #define MBEDTLS_TLS_EXT_SIG_ALG 13
448 
449 #define MBEDTLS_TLS_EXT_ALPN 16
450 
451 #define MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC 22 /* 0x16 */
452 #define MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET 0x0017 /* 23 */
453 
454 #define MBEDTLS_TLS_EXT_SESSION_TICKET 35
455 
456 #define MBEDTLS_TLS_EXT_ECJPAKE_KKPP 256 /* experimental */
457 
458 #define MBEDTLS_TLS_EXT_RENEGOTIATION_INFO 0xFF01
459 
460 /*
461  * Size defines
462  */
463 #if !defined(MBEDTLS_PSK_MAX_LEN)
464 #define MBEDTLS_PSK_MAX_LEN 32 /* 256 bits */
465 #endif
466 
467 /* Dummy type used only for its size */
469 {
470 #if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED)
471  unsigned char _pms_rsa[48]; /* RFC 5246 8.1.1 */
472 #endif
473 #if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED)
474  unsigned char _pms_dhm[MBEDTLS_MPI_MAX_SIZE]; /* RFC 5246 8.1.2 */
475 #endif
476 #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
477  defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \
478  defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \
479  defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)
480  unsigned char _pms_ecdh[MBEDTLS_ECP_MAX_BYTES]; /* RFC 4492 5.10 */
481 #endif
482 #if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED)
483  unsigned char _pms_psk[4 + 2 * MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 2 */
484 #endif
485 #if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED)
486  unsigned char _pms_dhe_psk[4 + MBEDTLS_MPI_MAX_SIZE
487  + MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 3 */
488 #endif
489 #if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED)
490  unsigned char _pms_rsa_psk[52 + MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 4 */
491 #endif
492 #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED)
493  unsigned char _pms_ecdhe_psk[4 + MBEDTLS_ECP_MAX_BYTES
494  + MBEDTLS_PSK_MAX_LEN]; /* RFC 5489 2 */
495 #endif
496 #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
497  unsigned char _pms_ecjpake[32]; /* Thread spec: SHA-256 output */
498 #endif
499 };
500 
501 #define MBEDTLS_PREMASTER_SIZE sizeof( union mbedtls_ssl_premaster_secret )
502 
503 #ifdef __cplusplus
504 extern "C" {
505 #endif
506 
507 /*
508  * SSL state machine
509  */
510 typedef enum
511 {
531 }
533 
551 typedef int mbedtls_ssl_send_t( void *ctx,
552  const unsigned char *buf,
553  size_t len );
554 
575 typedef int mbedtls_ssl_recv_t( void *ctx,
576  unsigned char *buf,
577  size_t len );
578 
601 typedef int mbedtls_ssl_recv_timeout_t( void *ctx,
602  unsigned char *buf,
603  size_t len,
604  uint32_t timeout );
627 typedef void mbedtls_ssl_set_timer_t( void * ctx,
628  uint32_t int_ms,
629  uint32_t fin_ms );
630 
642 typedef int mbedtls_ssl_get_timer_t( void * ctx );
643 
644 /* Defined below */
648 
649 /* Defined in ssl_internal.h */
653 #if defined(MBEDTLS_X509_CRT_PARSE_C)
655 #endif
656 #if defined(MBEDTLS_SSL_PROTO_DTLS)
658 #endif
659 
660 #if defined(MBEDTLS_SSL_ASYNC_PRIVATE)
661 #if defined(MBEDTLS_X509_CRT_PARSE_C)
662 
733 typedef int mbedtls_ssl_async_sign_t( mbedtls_ssl_context *ssl,
734  mbedtls_x509_crt *cert,
735  mbedtls_md_type_t md_alg,
736  const unsigned char *hash,
737  size_t hash_len );
738 
799 typedef int mbedtls_ssl_async_decrypt_t( mbedtls_ssl_context *ssl,
800  mbedtls_x509_crt *cert,
801  const unsigned char *input,
802  size_t input_len );
803 #endif /* MBEDTLS_X509_CRT_PARSE_C */
804 
847 typedef int mbedtls_ssl_async_resume_t( mbedtls_ssl_context *ssl,
848  unsigned char *output,
849  size_t *output_len,
850  size_t output_size );
851 
869 typedef void mbedtls_ssl_async_cancel_t( mbedtls_ssl_context *ssl );
870 #endif /* MBEDTLS_SSL_ASYNC_PRIVATE */
871 
872 /*
873  * This structure is used for storing current session data.
874  */
876 {
877 #if defined(MBEDTLS_HAVE_TIME)
879 #endif
882  size_t id_len;
883  unsigned char id[32];
884  unsigned char master[48];
886 #if defined(MBEDTLS_X509_CRT_PARSE_C)
888 #endif /* MBEDTLS_X509_CRT_PARSE_C */
889  uint32_t verify_result;
891 #if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_CLI_C)
892  unsigned char *ticket;
893  size_t ticket_len;
894  uint32_t ticket_lifetime;
895 #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_CLI_C */
896 
897 #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
898  unsigned char mfl_code;
899 #endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
900 
901 #if defined(MBEDTLS_SSL_TRUNCATED_HMAC)
903 #endif /* MBEDTLS_SSL_TRUNCATED_HMAC */
904 
905 #if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
907 #endif
908 };
909 
914 {
915  /* Group items by size (largest first) to minimize padding overhead */
916 
917  /*
918  * Pointers
919  */
920 
921  const int *ciphersuite_list[4];
924  void (*f_dbg)(void *, int, const char *, int, const char *);
925  void *p_dbg;
928  int (*f_rng)(void *, unsigned char *, size_t);
929  void *p_rng;
932  int (*f_get_cache)(void *, mbedtls_ssl_session *);
934  int (*f_set_cache)(void *, const mbedtls_ssl_session *);
935  void *p_cache;
937 #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
938 
939  int (*f_sni)(void *, mbedtls_ssl_context *, const unsigned char *, size_t);
940  void *p_sni;
941 #endif
942 
943 #if defined(MBEDTLS_X509_CRT_PARSE_C)
944 
945  int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *);
946  void *p_vrfy;
947 #endif
948 
949 #if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED)
950 
951  int (*f_psk)(void *, mbedtls_ssl_context *, const unsigned char *, size_t);
952  void *p_psk;
953 #endif
954 
955 #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C)
956 
957  int (*f_cookie_write)( void *, unsigned char **, unsigned char *,
958  const unsigned char *, size_t );
960  int (*f_cookie_check)( void *, const unsigned char *, size_t,
961  const unsigned char *, size_t );
962  void *p_cookie;
963 #endif
964 
965 #if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_SRV_C)
966 
967  int (*f_ticket_write)( void *, const mbedtls_ssl_session *,
968  unsigned char *, const unsigned char *, size_t *, uint32_t * );
970  int (*f_ticket_parse)( void *, mbedtls_ssl_session *, unsigned char *, size_t);
971  void *p_ticket;
972 #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_SRV_C */
973 
974 #if defined(MBEDTLS_SSL_EXPORT_KEYS)
975 
976  int (*f_export_keys)( void *, const unsigned char *,
977  const unsigned char *, size_t, size_t, size_t );
979 #endif
980 
981 #if defined(MBEDTLS_X509_CRT_PARSE_C)
986 #endif /* MBEDTLS_X509_CRT_PARSE_C */
987 
988 #if defined(MBEDTLS_SSL_ASYNC_PRIVATE)
989 #if defined(MBEDTLS_X509_CRT_PARSE_C)
990  mbedtls_ssl_async_sign_t *f_async_sign_start;
991  mbedtls_ssl_async_decrypt_t *f_async_decrypt_start;
992 #endif /* MBEDTLS_X509_CRT_PARSE_C */
993  mbedtls_ssl_async_resume_t *f_async_resume;
994  mbedtls_ssl_async_cancel_t *f_async_cancel;
995  void *p_async_config_data;
996 #endif /* MBEDTLS_SSL_ASYNC_PRIVATE */
997 
998 #if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED)
999  const int *sig_hashes;
1000 #endif
1001 
1002 #if defined(MBEDTLS_ECP_C)
1004 #endif
1005 
1006 #if defined(MBEDTLS_DHM_C)
1009 #endif
1010 
1011 #if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED)
1012  unsigned char *psk;
1015  size_t psk_len;
1018  unsigned char *psk_identity;
1024 #endif
1025 
1026 #if defined(MBEDTLS_SSL_ALPN)
1027  const char **alpn_list;
1028 #endif
1029 
1030  /*
1031  * Numerical settings (int then char)
1032  */
1033 
1034  uint32_t read_timeout;
1036 #if defined(MBEDTLS_SSL_PROTO_DTLS)
1037  uint32_t hs_timeout_min;
1039  uint32_t hs_timeout_max;
1041 #endif
1042 
1043 #if defined(MBEDTLS_SSL_RENEGOTIATION)
1045  unsigned char renego_period[8];
1047 #endif
1048 
1049 #if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT)
1050  unsigned int badmac_limit;
1051 #endif
1052 
1053 #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C)
1054  unsigned int dhm_min_bitlen;
1055 #endif
1056 
1057  unsigned char max_major_ver;
1058  unsigned char max_minor_ver;
1059  unsigned char min_major_ver;
1060  unsigned char min_minor_ver;
1062  /*
1063  * Flags (bitfields)
1064  */
1065 
1066  unsigned int endpoint : 1;
1067  unsigned int transport : 1;
1068  unsigned int authmode : 2;
1069  /* needed even with renego disabled for LEGACY_BREAK_HANDSHAKE */
1070  unsigned int allow_legacy_renegotiation : 2 ;
1071 #if defined(MBEDTLS_ARC4_C)
1072  unsigned int arc4_disabled : 1;
1073 #endif
1074 #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
1075  unsigned int mfl_code : 3;
1076 #endif
1077 #if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
1078  unsigned int encrypt_then_mac : 1 ;
1079 #endif
1080 #if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET)
1081  unsigned int extended_ms : 1;
1082 #endif
1083 #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)
1084  unsigned int anti_replay : 1;
1085 #endif
1086 #if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING)
1087  unsigned int cbc_record_splitting : 1;
1088 #endif
1089 #if defined(MBEDTLS_SSL_RENEGOTIATION)
1090  unsigned int disable_renegotiation : 1;
1091 #endif
1092 #if defined(MBEDTLS_SSL_TRUNCATED_HMAC)
1093  unsigned int trunc_hmac : 1;
1094 #endif
1095 #if defined(MBEDTLS_SSL_SESSION_TICKETS)
1096  unsigned int session_tickets : 1;
1097 #endif
1098 #if defined(MBEDTLS_SSL_FALLBACK_SCSV) && defined(MBEDTLS_SSL_CLI_C)
1099  unsigned int fallback : 1;
1100 #endif
1101 #if defined(MBEDTLS_SSL_SRV_C)
1102  unsigned int cert_req_ca_list : 1;
1104 #endif
1105 };
1106 
1107 
1109 {
1112  /*
1113  * Miscellaneous
1114  */
1115  int state;
1116 #if defined(MBEDTLS_SSL_RENEGOTIATION)
1121 #endif /* MBEDTLS_SSL_RENEGOTIATION */
1122 
1126 #if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT)
1127  unsigned badmac_seen;
1128 #endif /* MBEDTLS_SSL_DTLS_BADMAC_LIMIT */
1129 
1135  void *p_bio;
1137  /*
1138  * Session layer
1139  */
1148  /*
1149  * Record layer transformations
1150  */
1156  /*
1157  * Timers
1158  */
1159  void *p_timer;
1164  /*
1165  * Record layer (incoming data)
1166  */
1167  unsigned char *in_buf;
1168  unsigned char *in_ctr;
1171  unsigned char *in_hdr;
1172  unsigned char *in_len;
1173  unsigned char *in_iv;
1174  unsigned char *in_msg;
1175  unsigned char *in_offt;
1178  size_t in_msglen;
1179  size_t in_left;
1180 #if defined(MBEDTLS_SSL_PROTO_DTLS)
1181  uint16_t in_epoch;
1184 #endif /* MBEDTLS_SSL_PROTO_DTLS */
1185 #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)
1186  uint64_t in_window_top;
1187  uint64_t in_window;
1188 #endif /* MBEDTLS_SSL_DTLS_ANTI_REPLAY */
1189 
1190  size_t in_hslen;
1192  int nb_zero;
1197 #if defined(MBEDTLS_SSL_PROTO_DTLS)
1200 #endif /* MBEDTLS_SSL_PROTO_DTLS */
1201 
1202  /*
1203  * Record layer (outgoing data)
1204  */
1205  unsigned char *out_buf;
1206  unsigned char *out_ctr;
1207  unsigned char *out_hdr;
1208  unsigned char *out_len;
1209  unsigned char *out_iv;
1210  unsigned char *out_msg;
1213  size_t out_msglen;
1214  size_t out_left;
1216  unsigned char cur_out_ctr[8];
1218 #if defined(MBEDTLS_SSL_PROTO_DTLS)
1219  uint16_t mtu;
1220 #endif /* MBEDTLS_SSL_PROTO_DTLS */
1221 
1222 #if defined(MBEDTLS_ZLIB_SUPPORT)
1223  unsigned char *compress_buf;
1224 #endif /* MBEDTLS_ZLIB_SUPPORT */
1225 #if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING)
1226  signed char split_done;
1227 #endif /* MBEDTLS_SSL_CBC_RECORD_SPLITTING */
1228 
1229  /*
1230  * PKI layer
1231  */
1234  /*
1235  * User settings
1236  */
1237 #if defined(MBEDTLS_X509_CRT_PARSE_C)
1238  char *hostname;
1240 #endif /* MBEDTLS_X509_CRT_PARSE_C */
1241 
1242 #if defined(MBEDTLS_SSL_ALPN)
1243  const char *alpn_chosen;
1244 #endif /* MBEDTLS_SSL_ALPN */
1245 
1246  /*
1247  * Information for DTLS hello verify
1248  */
1249 #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C)
1250  unsigned char *cli_id;
1251  size_t cli_id_len;
1252 #endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY && MBEDTLS_SSL_SRV_C */
1253 
1254  /*
1255  * Secure renegotiation
1256  */
1257  /* needed to know when to send extension on server */
1260 #if defined(MBEDTLS_SSL_RENEGOTIATION)
1264 #endif /* MBEDTLS_SSL_RENEGOTIATION */
1265 };
1266 
1267 #if defined(MBEDTLS_SSL_HW_RECORD_ACCEL)
1268 
1269 #define MBEDTLS_SSL_CHANNEL_OUTBOUND 0
1270 #define MBEDTLS_SSL_CHANNEL_INBOUND 1
1271 
1272 extern int (*mbedtls_ssl_hw_record_init)(mbedtls_ssl_context *ssl,
1273  const unsigned char *key_enc, const unsigned char *key_dec,
1274  size_t keylen,
1275  const unsigned char *iv_enc, const unsigned char *iv_dec,
1276  size_t ivlen,
1277  const unsigned char *mac_enc, const unsigned char *mac_dec,
1278  size_t maclen);
1279 extern int (*mbedtls_ssl_hw_record_activate)(mbedtls_ssl_context *ssl, int direction);
1280 extern int (*mbedtls_ssl_hw_record_reset)(mbedtls_ssl_context *ssl);
1281 extern int (*mbedtls_ssl_hw_record_write)(mbedtls_ssl_context *ssl);
1282 extern int (*mbedtls_ssl_hw_record_read)(mbedtls_ssl_context *ssl);
1283 extern int (*mbedtls_ssl_hw_record_finish)(mbedtls_ssl_context *ssl);
1284 #endif /* MBEDTLS_SSL_HW_RECORD_ACCEL */
1285 
1294 const char *mbedtls_ssl_get_ciphersuite_name( const int ciphersuite_id );
1295 
1304 int mbedtls_ssl_get_ciphersuite_id( const char *ciphersuite_name );
1305 
1314 
1336  const mbedtls_ssl_config *conf );
1337 
1349 
1356 void mbedtls_ssl_conf_endpoint( mbedtls_ssl_config *conf, int endpoint );
1357 
1372 void mbedtls_ssl_conf_transport( mbedtls_ssl_config *conf, int transport );
1373 
1400 void mbedtls_ssl_conf_authmode( mbedtls_ssl_config *conf, int authmode );
1401 
1402 #if defined(MBEDTLS_X509_CRT_PARSE_C)
1403 
1415  int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *),
1416  void *p_vrfy );
1417 #endif /* MBEDTLS_X509_CRT_PARSE_C */
1418 
1427  int (*f_rng)(void *, unsigned char *, size_t),
1428  void *p_rng );
1429 
1445  void (*f_dbg)(void *, int, const char *, int, const char *),
1446  void *p_dbg );
1447 
1479  void *p_bio,
1480  mbedtls_ssl_send_t *f_send,
1481  mbedtls_ssl_recv_t *f_recv,
1482  mbedtls_ssl_recv_timeout_t *f_recv_timeout );
1483 
1484 #if defined(MBEDTLS_SSL_PROTO_DTLS)
1485 
1527 void mbedtls_ssl_set_mtu( mbedtls_ssl_context *ssl, uint16_t mtu );
1528 #endif /* MBEDTLS_SSL_PROTO_DTLS */
1529 
1546 void mbedtls_ssl_conf_read_timeout( mbedtls_ssl_config *conf, uint32_t timeout );
1547 
1569  void *p_timer,
1570  mbedtls_ssl_set_timer_t *f_set_timer,
1571  mbedtls_ssl_get_timer_t *f_get_timer );
1572 
1592 typedef int mbedtls_ssl_ticket_write_t( void *p_ticket,
1593  const mbedtls_ssl_session *session,
1594  unsigned char *start,
1595  const unsigned char *end,
1596  size_t *tlen,
1597  uint32_t *lifetime );
1598 
1599 #if defined(MBEDTLS_SSL_EXPORT_KEYS)
1600 
1620 typedef int mbedtls_ssl_export_keys_t( void *p_expkey,
1621  const unsigned char *ms,
1622  const unsigned char *kb,
1623  size_t maclen,
1624  size_t keylen,
1625  size_t ivlen );
1626 #endif /* MBEDTLS_SSL_EXPORT_KEYS */
1627 
1651 typedef int mbedtls_ssl_ticket_parse_t( void *p_ticket,
1652  mbedtls_ssl_session *session,
1653  unsigned char *buf,
1654  size_t len );
1655 
1656 #if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_SRV_C)
1657 
1672  mbedtls_ssl_ticket_write_t *f_ticket_write,
1673  mbedtls_ssl_ticket_parse_t *f_ticket_parse,
1674  void *p_ticket );
1675 #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_SRV_C */
1676 
1677 #if defined(MBEDTLS_SSL_EXPORT_KEYS)
1678 
1689  mbedtls_ssl_export_keys_t *f_export_keys,
1690  void *p_export_keys );
1691 #endif /* MBEDTLS_SSL_EXPORT_KEYS */
1692 
1693 #if defined(MBEDTLS_SSL_ASYNC_PRIVATE)
1694 
1724 void mbedtls_ssl_conf_async_private_cb( mbedtls_ssl_config *conf,
1725  mbedtls_ssl_async_sign_t *f_async_sign,
1726  mbedtls_ssl_async_decrypt_t *f_async_decrypt,
1727  mbedtls_ssl_async_resume_t *f_async_resume,
1728  mbedtls_ssl_async_cancel_t *f_async_cancel,
1729  void *config_data );
1730 
1739 void *mbedtls_ssl_conf_get_async_config_data( const mbedtls_ssl_config *conf );
1740 
1755 void *mbedtls_ssl_get_async_operation_data( const mbedtls_ssl_context *ssl );
1756 
1768 void mbedtls_ssl_set_async_operation_data( mbedtls_ssl_context *ssl,
1769  void *ctx );
1770 #endif /* MBEDTLS_SSL_ASYNC_PRIVATE */
1771 
1786 typedef int mbedtls_ssl_cookie_write_t( void *ctx,
1787  unsigned char **p, unsigned char *end,
1788  const unsigned char *info, size_t ilen );
1789 
1803 typedef int mbedtls_ssl_cookie_check_t( void *ctx,
1804  const unsigned char *cookie, size_t clen,
1805  const unsigned char *info, size_t ilen );
1806 
1807 #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C)
1808 
1837  mbedtls_ssl_cookie_write_t *f_cookie_write,
1838  mbedtls_ssl_cookie_check_t *f_cookie_check,
1839  void *p_cookie );
1840 
1861  const unsigned char *info,
1862  size_t ilen );
1863 
1864 #endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY && MBEDTLS_SSL_SRV_C */
1865 
1866 #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)
1867 
1882 void mbedtls_ssl_conf_dtls_anti_replay( mbedtls_ssl_config *conf, char mode );
1883 #endif /* MBEDTLS_SSL_DTLS_ANTI_REPLAY */
1884 
1885 #if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT)
1886 
1909 void mbedtls_ssl_conf_dtls_badmac_limit( mbedtls_ssl_config *conf, unsigned limit );
1910 #endif /* MBEDTLS_SSL_DTLS_BADMAC_LIMIT */
1911 
1912 #if defined(MBEDTLS_SSL_PROTO_DTLS)
1913 
1943  unsigned allow_packing );
1944 
1976 void mbedtls_ssl_conf_handshake_timeout( mbedtls_ssl_config *conf, uint32_t min, uint32_t max );
1977 #endif /* MBEDTLS_SSL_PROTO_DTLS */
1978 
1979 #if defined(MBEDTLS_SSL_SRV_C)
1980 
2018  void *p_cache,
2019  int (*f_get_cache)(void *, mbedtls_ssl_session *),
2020  int (*f_set_cache)(void *, const mbedtls_ssl_session *) );
2021 #endif /* MBEDTLS_SSL_SRV_C */
2022 
2023 #if defined(MBEDTLS_SSL_CLI_C)
2024 
2039 #endif /* MBEDTLS_SSL_CLI_C */
2040 
2057  const int *ciphersuites );
2058 
2079  const int *ciphersuites,
2080  int major, int minor );
2081 
2082 #if defined(MBEDTLS_X509_CRT_PARSE_C)
2083 
2094  const mbedtls_x509_crt_profile *profile );
2095 
2108  mbedtls_x509_crt *ca_chain,
2109  mbedtls_x509_crl *ca_crl );
2110 
2148  mbedtls_x509_crt *own_cert,
2149  mbedtls_pk_context *pk_key );
2150 #endif /* MBEDTLS_X509_CRT_PARSE_C */
2151 
2152 #if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED)
2153 
2174  const unsigned char *psk, size_t psk_len,
2175  const unsigned char *psk_identity, size_t psk_identity_len );
2176 
2177 
2191  const unsigned char *psk, size_t psk_len );
2192 
2218  int (*f_psk)(void *, mbedtls_ssl_context *, const unsigned char *,
2219  size_t),
2220  void *p_psk );
2221 #endif /* MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED */
2222 
2223 #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_SRV_C)
2224 
2225 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
2226 
2227 #if defined(MBEDTLS_DEPRECATED_WARNING)
2228 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
2229 #else
2230 #define MBEDTLS_DEPRECATED
2231 #endif
2232 
2247  const char *dhm_P,
2248  const char *dhm_G );
2249 
2250 #endif /* MBEDTLS_DEPRECATED_REMOVED */
2251 
2266  const unsigned char *dhm_P, size_t P_len,
2267  const unsigned char *dhm_G, size_t G_len );
2268 
2279 #endif /* MBEDTLS_DHM_C && defined(MBEDTLS_SSL_SRV_C) */
2280 
2281 #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C)
2282 
2291  unsigned int bitlen );
2292 #endif /* MBEDTLS_DHM_C && MBEDTLS_SSL_CLI_C */
2293 
2294 #if defined(MBEDTLS_ECP_C)
2295 
2323  const mbedtls_ecp_group_id *curves );
2324 #endif /* MBEDTLS_ECP_C */
2325 
2326 #if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED)
2327 
2348  const int *hashes );
2349 #endif /* MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */
2350 
2351 #if defined(MBEDTLS_X509_CRT_PARSE_C)
2352 
2370 int mbedtls_ssl_set_hostname( mbedtls_ssl_context *ssl, const char *hostname );
2371 #endif /* MBEDTLS_X509_CRT_PARSE_C */
2372 
2373 #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
2374 
2387  mbedtls_x509_crt *own_cert,
2388  mbedtls_pk_context *pk_key );
2389 
2402  mbedtls_x509_crt *ca_chain,
2403  mbedtls_x509_crl *ca_crl );
2404 
2416  int authmode );
2417 
2442  int (*f_sni)(void *, mbedtls_ssl_context *, const unsigned char *,
2443  size_t),
2444  void *p_sni );
2445 #endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */
2446 
2447 #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
2448 
2465 int mbedtls_ssl_set_hs_ecjpake_password( mbedtls_ssl_context *ssl,
2466  const unsigned char *pw,
2467  size_t pw_len );
2468 #endif /*MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */
2469 
2470 #if defined(MBEDTLS_SSL_ALPN)
2471 
2483 int mbedtls_ssl_conf_alpn_protocols( mbedtls_ssl_config *conf, const char **protos );
2484 
2494 const char *mbedtls_ssl_get_alpn_protocol( const mbedtls_ssl_context *ssl );
2495 #endif /* MBEDTLS_SSL_ALPN */
2496 
2513 void mbedtls_ssl_conf_max_version( mbedtls_ssl_config *conf, int major, int minor );
2514 
2533 void mbedtls_ssl_conf_min_version( mbedtls_ssl_config *conf, int major, int minor );
2534 
2535 #if defined(MBEDTLS_SSL_FALLBACK_SCSV) && defined(MBEDTLS_SSL_CLI_C)
2536 
2555 void mbedtls_ssl_conf_fallback( mbedtls_ssl_config *conf, char fallback );
2556 #endif /* MBEDTLS_SSL_FALLBACK_SCSV && MBEDTLS_SSL_CLI_C */
2557 
2558 #if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
2559 
2571 #endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */
2572 
2573 #if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET)
2574 
2586 #endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */
2587 
2588 #if defined(MBEDTLS_ARC4_C)
2589 
2604 void mbedtls_ssl_conf_arc4_support( mbedtls_ssl_config *conf, char arc4 );
2605 #endif /* MBEDTLS_ARC4_C */
2606 
2607 #if defined(MBEDTLS_SSL_SRV_C)
2608 
2618  char cert_req_ca_list );
2619 #endif /* MBEDTLS_SSL_SRV_C */
2620 
2621 #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
2622 
2656 int mbedtls_ssl_conf_max_frag_len( mbedtls_ssl_config *conf, unsigned char mfl_code );
2657 #endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
2658 
2659 #if defined(MBEDTLS_SSL_TRUNCATED_HMAC)
2660 
2668 void mbedtls_ssl_conf_truncated_hmac( mbedtls_ssl_config *conf, int truncate );
2669 #endif /* MBEDTLS_SSL_TRUNCATED_HMAC */
2670 
2671 #if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING)
2672 
2684 #endif /* MBEDTLS_SSL_CBC_RECORD_SPLITTING */
2685 
2686 #if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_CLI_C)
2687 
2697 void mbedtls_ssl_conf_session_tickets( mbedtls_ssl_config *conf, int use_tickets );
2698 #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_CLI_C */
2699 
2700 #if defined(MBEDTLS_SSL_RENEGOTIATION)
2701 
2718 void mbedtls_ssl_conf_renegotiation( mbedtls_ssl_config *conf, int renegotiation );
2719 #endif /* MBEDTLS_SSL_RENEGOTIATION */
2720 
2748 void mbedtls_ssl_conf_legacy_renegotiation( mbedtls_ssl_config *conf, int allow_legacy );
2749 
2750 #if defined(MBEDTLS_SSL_RENEGOTIATION)
2751 
2788 void mbedtls_ssl_conf_renegotiation_enforced( mbedtls_ssl_config *conf, int max_records );
2789 
2816  const unsigned char period[8] );
2817 #endif /* MBEDTLS_SSL_RENEGOTIATION */
2818 
2858 
2875 
2888 uint32_t mbedtls_ssl_get_verify_result( const mbedtls_ssl_context *ssl );
2889 
2897 const char *mbedtls_ssl_get_ciphersuite( const mbedtls_ssl_context *ssl );
2898 
2906 const char *mbedtls_ssl_get_version( const mbedtls_ssl_context *ssl );
2907 
2922 
2923 #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
2924 
2937 #endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
2938 
2966 
2967 #if defined(MBEDTLS_X509_CRT_PARSE_C)
2968 
2983 #endif /* MBEDTLS_X509_CRT_PARSE_C */
2984 
2985 #if defined(MBEDTLS_SSL_CLI_C)
2986 
3013 #endif /* MBEDTLS_SSL_CLI_C */
3014 
3066 
3088 
3089 #if defined(MBEDTLS_SSL_RENEGOTIATION)
3090 
3114 #endif /* MBEDTLS_SSL_RENEGOTIATION */
3115 
3186 int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len );
3187 
3248 int mbedtls_ssl_write( mbedtls_ssl_context *ssl, const unsigned char *buf, size_t len );
3249 
3267  unsigned char level,
3268  unsigned char message );
3283 
3290 
3302 
3319  int endpoint, int transport, int preset );
3320 
3327 
3334 
3345 
3346 #ifdef __cplusplus
3347 }
3348 #endif
3349 
3350 #endif /* ssl.h */
uint64_t in_window_top
Definition: ssl.h:1186
mbedtls_ssl_send_t * f_send
Definition: ssl.h:1130
void * p_rng
Definition: ssl.h:929
const char ** alpn_list
Definition: ssl.h:1027
unsigned int transport
Definition: ssl.h:1067
unsigned char * in_ctr
Definition: ssl.h:1168
mbedtls_x509_crt * peer_cert
Definition: ssl.h:887
unsigned char * out_msg
Definition: ssl.h:1210
unsigned char master[48]
Definition: ssl.h:884
unsigned int trunc_hmac
Definition: ssl.h:1093
unsigned char * in_len
Definition: ssl.h:1172
unsigned char * in_buf
Definition: ssl.h:1167
unsigned int endpoint
Definition: ssl.h:1066
Public key container.
Definition: pk.h:170
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:1651
mbedtls_mpi dhm_P
Definition: ssl.h:1007
char peer_verify_data[MBEDTLS_SSL_VERIFY_DATA_MAX_LEN]
Definition: ssl.h:1263
unsigned char max_minor_ver
Definition: ssl.h:1058
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:1060
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:1786
unsigned char * in_hdr
Definition: ssl.h:1171
size_t psk_identity_len
Definition: ssl.h:1021
unsigned int dhm_min_bitlen
Definition: ssl.h:1054
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:1803
void * p_sni
Definition: ssl.h:940
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:892
struct mbedtls_ssl_sig_hash_set_t mbedtls_ssl_sig_hash_set_t
Definition: ssl.h:652
size_t ticket_len
Definition: ssl.h:893
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:1209
mbedtls_ssl_transform * transform_in
Definition: ssl.h:1151
size_t in_left
Definition: ssl.h:1179
unsigned int authmode
Definition: ssl.h:1068
int mbedtls_ssl_send_t(void *ctx, const unsigned char *buf, size_t len)
Callback type: send data on the network.
Definition: ssl.h:551
unsigned int badmac_limit
Definition: ssl.h:1050
void * p_psk
Definition: ssl.h:952
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:1084
int mbedtls_ssl_recv_t(void *ctx, unsigned char *buf, size_t len)
Callback type: receive data from the network.
Definition: ssl.h:575
unsigned int fallback
Definition: ssl.h:1099
const mbedtls_ecp_group_id * curve_list
Definition: ssl.h:1003
This file provides an API for Elliptic Curves over GF(P) (ECP).
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) ...
int(* f_cookie_write)(void *, unsigned char **, unsigned char *, const unsigned char *, size_t)
Definition: ssl.h:957
int(* f_export_keys)(void *, const unsigned char *, const unsigned char *, size_t, size_t, size_t)
Definition: ssl.h:976
int(* f_get_cache)(void *, mbedtls_ssl_session *)
Definition: ssl.h:932
unsigned char _pms_dhm[MBEDTLS_MPI_MAX_SIZE]
Definition: ssl.h:474
void(* f_dbg)(void *, int, const char *, int, const char *)
Definition: ssl.h:924
void * p_cache
Definition: ssl.h:935
int(* f_sni)(void *, mbedtls_ssl_context *, const unsigned char *, size_t)
Definition: ssl.h:939
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:1102
unsigned char _pms_rsa[48]
Definition: ssl.h:471
unsigned char _pms_ecdh[MBEDTLS_ECP_MAX_BYTES]
Definition: ssl.h:480
unsigned char renego_period[8]
Definition: ssl.h:1045
uint32_t ticket_lifetime
Definition: ssl.h:894
int mbedtls_ssl_get_max_out_record_payload(const mbedtls_ssl_context *ssl)
Return the current maximum outgoing record payload in bytes. This takes into account the config...
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:1140
uint8_t disable_datagram_packing
Definition: ssl.h:1198
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:1127
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:1162
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:985
int mbedtls_ssl_check_pending(const mbedtls_ssl_context *ssl)
Check if there is data already read from the underlying transport but not yet processed.
mbedtls_ssl_session * session_out
Definition: ssl.h:1141
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:601
uint16_t mtu
Definition: ssl.h:1219
SSL Ciphersuites for mbed TLS.
int(* f_ticket_write)(void *, const mbedtls_ssl_session *, unsigned char *, const unsigned char *, size_t *, uint32_t *)
Definition: ssl.h:967
mbedtls_ssl_transform * transform_out
Definition: ssl.h:1152
unsigned char mfl_code
Definition: ssl.h:898
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:1075
int(* f_set_cache)(void *, const mbedtls_ssl_session *)
Definition: ssl.h:934
Multi-precision integer library.
int encrypt_then_mac
Definition: ssl.h:906
size_t in_hslen
Definition: ssl.h:1190
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. (Typical: the smaller of MBEDTLS_SSL_IN_CON...
time_t mbedtls_time_t
Definition: platform_time.h:78
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)
int(* f_cookie_check)(void *, const unsigned char *, size_t, const unsigned char *, size_t)
Definition: ssl.h:960
uint64_t in_window
Definition: ssl.h:1187
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:657
void * p_cookie
Definition: ssl.h:962
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:1153
uint32_t hs_timeout_min
Definition: ssl.h:1037
mbedtls_ssl_handshake_params * handshake
Definition: ssl.h:1145
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:1214
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:1174
void mbedtls_ssl_conf_sig_hashes(mbedtls_ssl_config *conf, const int *hashes)
Set the allowed hashes for signatures during the handshake. (Default: all SHA-2 hashes, largest first. Also SHA-1 if the compile-time option MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE is enabled.)
unsigned char min_major_ver
Definition: ssl.h:1059
struct mbedtls_ssl_transform mbedtls_ssl_transform
Definition: ssl.h:650
mbedtls_ssl_set_timer_t * f_set_timer
Definition: ssl.h:1161
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...
const int * ciphersuite_list[4]
Definition: ssl.h:921
int(* f_rng)(void *, unsigned char *, size_t)
Definition: ssl.h:928
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:983
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:1131
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:1143
mbedtls_ssl_states
Definition: ssl.h:510
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:999
void mbedtls_ssl_conf_renegotiation_enforced(mbedtls_ssl_config *conf, int max_records)
Enforce renegotiation requests. (Default: enforced, max_records = 16)
void mbedtls_ssl_set_mtu(mbedtls_ssl_context *ssl, uint16_t mtu)
Set the Maximum Tranport Unit (MTU). Special value: 0 means unset (no limit). This represents the max...
#define MBEDTLS_DEPRECATED
Definition: ssl.h:2230
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:882
unsigned int encrypt_then_mac
Definition: ssl.h:1078
void * p_bio
Definition: ssl.h:1135
unsigned int cbc_record_splitting
Definition: ssl.h:1087
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 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:494
void * p_vrfy
Definition: ssl.h:946
const mbedtls_x509_crt_profile * cert_profile
Definition: ssl.h:982
void * p_timer
Definition: ssl.h:1159
This file contains Diffie-Hellman-Merkle (DHM) key exchange definitions and functions.
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:464
unsigned int session_tickets
Definition: ssl.h:1096
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:1142
unsigned char * in_iv
Definition: ssl.h:1173
char own_verify_data[MBEDTLS_SSL_VERIFY_DATA_MAX_LEN]
Definition: ssl.h:1262
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:1154
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:112
unsigned char * out_ctr
Definition: ssl.h:1206
int secure_renegotiation
Definition: ssl.h:1258
int mbedtls_ssl_get_timer_t(void *ctx)
Callback type: get status of timers/delays.
Definition: ssl.h:642
The DHM context structure.
Definition: dhm.h:138
const mbedtls_ssl_config * conf
Definition: ssl.h:1110
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.
int(* f_psk)(void *, mbedtls_ssl_context *, const unsigned char *, size_t)
Definition: ssl.h:951
unsigned char * in_offt
Definition: ssl.h:1175
unsigned int extended_ms
Definition: ssl.h:1081
unsigned char max_major_ver
Definition: ssl.h:1057
unsigned char * psk
Definition: ssl.h:1012
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:1243
This file contains ECDH definitions and functions.
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:1008
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:115
unsigned int disable_renegotiation
Definition: ssl.h:1090
void * p_export_keys
Definition: ssl.h:978
char * hostname
Definition: ssl.h:1238
void mbedtls_ssl_set_datagram_packing(mbedtls_ssl_context *ssl, unsigned allow_packing)
Allow or disallow packing of multiple handshake records within a single datagram. ...
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:1213
uint32_t read_timeout
Definition: ssl.h:1034
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:490
int mbedtls_ssl_renegotiate(mbedtls_ssl_context *ssl)
Initiate an SSL renegotiation on the running connection. Client: perform the renegotiation right now...
int(* f_ticket_parse)(void *, mbedtls_ssl_session *, unsigned char *, size_t)
Definition: ssl.h:970
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:1620
unsigned char * out_len
Definition: ssl.h:1208
int(* f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *)
Definition: ssl.h:945
unsigned int arc4_disabled
Definition: ssl.h:1072
uint32_t hs_timeout_max
Definition: ssl.h:1039
MPI structure.
Definition: bignum.h:218
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:1250
int renego_max_records
Definition: ssl.h:1044
mbedtls_ssl_recv_timeout_t * f_recv_timeout
Definition: ssl.h:1132
mbedtls_x509_crt * ca_chain
Definition: ssl.h:984
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:1261
void mbedtls_ssl_config_free(mbedtls_ssl_config *conf)
Free an SSL configuration context.
unsigned char * psk_identity
Definition: ssl.h:1018
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:654
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:627
size_t mbedtls_ssl_get_bytes_avail(const mbedtls_ssl_context *ssl)
Return the number of application data bytes remaining to be read from the current record...
unsigned char _pms_dhe_psk[4+MBEDTLS_MPI_MAX_SIZE+MBEDTLS_PSK_MAX_LEN]
Definition: ssl.h:487
size_t next_record_offset
Definition: ssl.h:1182
unsigned char * out_buf
Definition: ssl.h:1205
size_t psk_len
Definition: ssl.h:1015
void mbedtls_ssl_session_init(mbedtls_ssl_session *session)
Initialize SSL session structure.
void * p_dbg
Definition: ssl.h:925
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:1592
size_t cli_id_len
Definition: ssl.h:1251
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 in order of decreasing si...
int renego_records_seen
Definition: ssl.h:1118
unsigned char * out_hdr
Definition: ssl.h:1207
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:483
uint32_t verify_result
Definition: ssl.h:889
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:1070
mbedtls_md_type_t
Supported message digests.
Definition: md.h:88
int keep_current_message
Definition: ssl.h:1194
signed char split_done
Definition: ssl.h:1226
int mbedtls_ssl_handshake_step(mbedtls_ssl_context *ssl)
Perform a single step of the SSL handshake.
unsigned char cur_out_ctr[8]
Definition: ssl.h:1216
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:651
#define MBEDTLS_ECP_MAX_BYTES
Definition: ecp.h:288
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:971
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:348
mbedtls_time_t start
Definition: ssl.h:878
size_t in_msglen
Definition: ssl.h:1178
uint16_t in_epoch
Definition: ssl.h:1181