Mbed TLS v2.28.5
ssl.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright The Mbed TLS Contributors
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 #ifndef MBEDTLS_SSL_H
23 #define MBEDTLS_SSL_H
24 
25 #if !defined(MBEDTLS_CONFIG_FILE)
26 #include "mbedtls/config.h"
27 #else
28 #include MBEDTLS_CONFIG_FILE
29 #endif
30 
31 #include "mbedtls/bignum.h"
32 #include "mbedtls/ecp.h"
33 
35 
36 #if defined(MBEDTLS_X509_CRT_PARSE_C)
37 #include "mbedtls/x509_crt.h"
38 #include "mbedtls/x509_crl.h"
39 #endif
40 
41 #if defined(MBEDTLS_DHM_C)
42 #include "mbedtls/dhm.h"
43 #endif
44 
45 /* Adding guard for MBEDTLS_ECDSA_C to ensure no compile errors due
46  * to guards also being in ssl_srv.c and ssl_cli.c. There is a gap
47  * in functionality that access to ecdh_ctx structure is needed for
48  * MBEDTLS_ECDSA_C which does not seem correct.
49  */
50 #if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C)
51 #include "mbedtls/ecdh.h"
52 #endif
53 
54 #if defined(MBEDTLS_ZLIB_SUPPORT)
55 
56 #if defined(MBEDTLS_DEPRECATED_WARNING)
57 #warning \
58  "Record compression support via MBEDTLS_ZLIB_SUPPORT is deprecated and will be removed in the next major revision of the library"
59 #endif
60 
61 #if defined(MBEDTLS_DEPRECATED_REMOVED)
62 #error \
63  "Record compression support via MBEDTLS_ZLIB_SUPPORT is deprecated and cannot be used if MBEDTLS_DEPRECATED_REMOVED is set"
64 #endif
65 
66 #include "zlib.h"
67 #endif
68 
69 #if defined(MBEDTLS_HAVE_TIME)
70 #include "mbedtls/platform_time.h"
71 #endif
72 
73 #if defined(MBEDTLS_USE_PSA_CRYPTO)
74 #include "psa/crypto.h"
75 #endif /* MBEDTLS_USE_PSA_CRYPTO */
76 
77 /*
78  * SSL Error codes
79  */
81 #define MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE -0x7080
82 
83 #define MBEDTLS_ERR_SSL_BAD_INPUT_DATA -0x7100
84 
85 #define MBEDTLS_ERR_SSL_INVALID_MAC -0x7180
86 
87 #define MBEDTLS_ERR_SSL_INVALID_RECORD -0x7200
88 
89 #define MBEDTLS_ERR_SSL_CONN_EOF -0x7280
90 
91 #define MBEDTLS_ERR_SSL_UNKNOWN_CIPHER -0x7300
92 
93 #define MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN -0x7380
94 
95 #define MBEDTLS_ERR_SSL_NO_RNG -0x7400
96 
97 #define MBEDTLS_ERR_SSL_NO_CLIENT_CERTIFICATE -0x7480
98 
99 #define MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE -0x7500
100 
101 #define MBEDTLS_ERR_SSL_CERTIFICATE_REQUIRED -0x7580
102 
103 #define MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED -0x7600
104 
105 #define MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED -0x7680
106 
107 #define MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE -0x7700
108 
109 #define MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE -0x7780
110 
111 #define MBEDTLS_ERR_SSL_PEER_VERIFY_FAILED -0x7800
112 
113 #define MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY -0x7880
114 
115 #define MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO -0x7900
116 
117 #define MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO -0x7980
118 
119 #define MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE -0x7A00
120 
121 #define MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST -0x7A80
122 
123 #define MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE -0x7B00
124 
125 #define MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO_DONE -0x7B80
126 
127 #define MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE -0x7C00
128 
129 #define MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP -0x7C80
130 
131 #define MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS -0x7D00
132 
133 #define MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY -0x7D80
134 
135 #define MBEDTLS_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC -0x7E00
136 
137 #define MBEDTLS_ERR_SSL_BAD_HS_FINISHED -0x7E80
138 
139 #define MBEDTLS_ERR_SSL_ALLOC_FAILED -0x7F00
140 
141 #define MBEDTLS_ERR_SSL_HW_ACCEL_FAILED -0x7F80
142 
143 #define MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH -0x6F80
144 
145 #define MBEDTLS_ERR_SSL_COMPRESSION_FAILED -0x6F00
146 
147 #define MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION -0x6E80
148 
149 #define MBEDTLS_ERR_SSL_BAD_HS_NEW_SESSION_TICKET -0x6E00
150 
151 #define MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED -0x6D80
152 
153 #define MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH -0x6D00
154 
155 #define MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY -0x6C80
156 
157 #define MBEDTLS_ERR_SSL_INTERNAL_ERROR -0x6C00
158 
159 #define MBEDTLS_ERR_SSL_COUNTER_WRAPPING -0x6B80
160 
161 #define MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO -0x6B00
162 
163 #define MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED -0x6A80
164 
165 #define MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL -0x6A00
166 
167 #define MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE -0x6980
168 
169 #define MBEDTLS_ERR_SSL_WANT_READ -0x6900
170 
171 #define MBEDTLS_ERR_SSL_WANT_WRITE -0x6880
172 
173 #define MBEDTLS_ERR_SSL_TIMEOUT -0x6800
174 
175 #define MBEDTLS_ERR_SSL_CLIENT_RECONNECT -0x6780
176 
177 #define MBEDTLS_ERR_SSL_UNEXPECTED_RECORD -0x6700
178 
179 #define MBEDTLS_ERR_SSL_NON_FATAL -0x6680
180 
181 #define MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH -0x6600
182 
183 #define MBEDTLS_ERR_SSL_CONTINUE_PROCESSING -0x6580
184 
185 #define MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS -0x6500
186 
187 #define MBEDTLS_ERR_SSL_EARLY_MESSAGE -0x6480
188 
189 #define MBEDTLS_ERR_SSL_UNEXPECTED_CID -0x6000
190 
191 #define MBEDTLS_ERR_SSL_VERSION_MISMATCH -0x5F00
192 
193 #define MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS -0x7000
194 
195 #define MBEDTLS_ERR_SSL_BAD_CONFIG -0x5E80
196 
197 #define MBEDTLS_ERR_SSL_CACHE_ENTRY_NOT_FOUND -0x5E00
198 
199 /*
200  * Various constants
201  */
202 #define MBEDTLS_SSL_MAJOR_VERSION_3 3
203 #define MBEDTLS_SSL_MINOR_VERSION_0 0
204 #define MBEDTLS_SSL_MINOR_VERSION_1 1
205 #define MBEDTLS_SSL_MINOR_VERSION_2 2
206 #define MBEDTLS_SSL_MINOR_VERSION_3 3
207 #define MBEDTLS_SSL_MINOR_VERSION_4 4
209 #define MBEDTLS_SSL_TRANSPORT_STREAM 0
210 #define MBEDTLS_SSL_TRANSPORT_DATAGRAM 1
212 #define MBEDTLS_SSL_MAX_HOST_NAME_LEN 255
213 #define MBEDTLS_SSL_MAX_ALPN_NAME_LEN 255
215 #define MBEDTLS_SSL_MAX_ALPN_LIST_LEN 65535
217 /* RFC 6066 section 4, see also mfl_code_to_length in ssl_tls.c
218  * NONE must be zero so that memset()ing structure to zero works */
219 #define MBEDTLS_SSL_MAX_FRAG_LEN_NONE 0
220 #define MBEDTLS_SSL_MAX_FRAG_LEN_512 1
221 #define MBEDTLS_SSL_MAX_FRAG_LEN_1024 2
222 #define MBEDTLS_SSL_MAX_FRAG_LEN_2048 3
223 #define MBEDTLS_SSL_MAX_FRAG_LEN_4096 4
224 #define MBEDTLS_SSL_MAX_FRAG_LEN_INVALID 5
226 #define MBEDTLS_SSL_IS_CLIENT 0
227 #define MBEDTLS_SSL_IS_SERVER 1
228 
229 #define MBEDTLS_SSL_IS_NOT_FALLBACK 0
230 #define MBEDTLS_SSL_IS_FALLBACK 1
231 
232 #define MBEDTLS_SSL_EXTENDED_MS_DISABLED 0
233 #define MBEDTLS_SSL_EXTENDED_MS_ENABLED 1
234 
235 #define MBEDTLS_SSL_CID_DISABLED 0
236 #define MBEDTLS_SSL_CID_ENABLED 1
237 
238 #define MBEDTLS_SSL_ETM_DISABLED 0
239 #define MBEDTLS_SSL_ETM_ENABLED 1
240 
241 #define MBEDTLS_SSL_COMPRESS_NULL 0
242 #define MBEDTLS_SSL_COMPRESS_DEFLATE 1
243 
244 #define MBEDTLS_SSL_VERIFY_NONE 0
245 #define MBEDTLS_SSL_VERIFY_OPTIONAL 1
246 #define MBEDTLS_SSL_VERIFY_REQUIRED 2
247 #define MBEDTLS_SSL_VERIFY_UNSET 3 /* Used only for sni_authmode */
248 
249 #define MBEDTLS_SSL_LEGACY_RENEGOTIATION 0
250 #define MBEDTLS_SSL_SECURE_RENEGOTIATION 1
251 
252 #define MBEDTLS_SSL_RENEGOTIATION_DISABLED 0
253 #define MBEDTLS_SSL_RENEGOTIATION_ENABLED 1
254 
255 #define MBEDTLS_SSL_ANTI_REPLAY_DISABLED 0
256 #define MBEDTLS_SSL_ANTI_REPLAY_ENABLED 1
257 
258 #define MBEDTLS_SSL_RENEGOTIATION_NOT_ENFORCED -1
259 #define MBEDTLS_SSL_RENEGO_MAX_RECORDS_DEFAULT 16
260 
261 #define MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION 0
262 #define MBEDTLS_SSL_LEGACY_ALLOW_RENEGOTIATION 1
263 #define MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE 2
264 
265 #define MBEDTLS_SSL_TRUNC_HMAC_DISABLED 0
266 #define MBEDTLS_SSL_TRUNC_HMAC_ENABLED 1
267 #define MBEDTLS_SSL_TRUNCATED_HMAC_LEN 10 /* 80 bits, rfc 6066 section 7 */
268 
269 #define MBEDTLS_SSL_SESSION_TICKETS_DISABLED 0
270 #define MBEDTLS_SSL_SESSION_TICKETS_ENABLED 1
271 
272 #define MBEDTLS_SSL_CBC_RECORD_SPLITTING_DISABLED 0
273 #define MBEDTLS_SSL_CBC_RECORD_SPLITTING_ENABLED 1
274 
275 #define MBEDTLS_SSL_ARC4_ENABLED 0
276 #define MBEDTLS_SSL_ARC4_DISABLED 1
277 
278 #define MBEDTLS_SSL_PRESET_DEFAULT 0
279 #define MBEDTLS_SSL_PRESET_SUITEB 2
280 
281 #define MBEDTLS_SSL_CERT_REQ_CA_LIST_ENABLED 1
282 #define MBEDTLS_SSL_CERT_REQ_CA_LIST_DISABLED 0
283 
284 #define MBEDTLS_SSL_DTLS_SRTP_MKI_UNSUPPORTED 0
285 #define MBEDTLS_SSL_DTLS_SRTP_MKI_SUPPORTED 1
286 
287 /*
288  * Default range for DTLS retransmission timer value, in milliseconds.
289  * RFC 6347 4.2.4.1 says from 1 second to 60 seconds.
290  */
291 #define MBEDTLS_SSL_DTLS_TIMEOUT_DFL_MIN 1000
292 #define MBEDTLS_SSL_DTLS_TIMEOUT_DFL_MAX 60000
293 
302 #if !defined(MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME)
303 #define MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME 86400
304 #endif
305 
306 /*
307  * Maximum fragment length in bytes,
308  * determines the size of each of the two internal I/O buffers.
309  *
310  * Note: the RFC defines the default size of SSL / TLS messages. If you
311  * change the value here, other clients / servers may not be able to
312  * communicate with you anymore. Only change this value if you control
313  * both sides of the connection and have it reduced at both sides, or
314  * if you're using the Max Fragment Length extension and you know all your
315  * peers are using it too!
316  */
317 #if !defined(MBEDTLS_SSL_MAX_CONTENT_LEN)
318 #define MBEDTLS_SSL_MAX_CONTENT_LEN 16384
319 #endif
320 
321 #if !defined(MBEDTLS_SSL_IN_CONTENT_LEN)
322 #define MBEDTLS_SSL_IN_CONTENT_LEN MBEDTLS_SSL_MAX_CONTENT_LEN
323 #endif
324 
325 #if !defined(MBEDTLS_SSL_OUT_CONTENT_LEN)
326 #define MBEDTLS_SSL_OUT_CONTENT_LEN MBEDTLS_SSL_MAX_CONTENT_LEN
327 #endif
328 
329 /*
330  * Maximum number of heap-allocated bytes for the purpose of
331  * DTLS handshake message reassembly and future message buffering.
332  */
333 #if !defined(MBEDTLS_SSL_DTLS_MAX_BUFFERING)
334 #define MBEDTLS_SSL_DTLS_MAX_BUFFERING 32768
335 #endif
336 
337 /*
338  * Maximum length of CIDs for incoming and outgoing messages.
339  */
340 #if !defined(MBEDTLS_SSL_CID_IN_LEN_MAX)
341 #define MBEDTLS_SSL_CID_IN_LEN_MAX 32
342 #endif
343 
344 #if !defined(MBEDTLS_SSL_CID_OUT_LEN_MAX)
345 #define MBEDTLS_SSL_CID_OUT_LEN_MAX 32
346 #endif
347 
348 #if !defined(MBEDTLS_SSL_CID_PADDING_GRANULARITY)
349 #define MBEDTLS_SSL_CID_PADDING_GRANULARITY 16
350 #endif
351 
352 #if !defined(MBEDTLS_SSL_TLS1_3_PADDING_GRANULARITY)
353 #define MBEDTLS_SSL_TLS1_3_PADDING_GRANULARITY 1
354 #endif
355 
358 /*
359  * Length of the verify data for secure renegotiation
360  */
361 #if defined(MBEDTLS_SSL_PROTO_SSL3)
362 #define MBEDTLS_SSL_VERIFY_DATA_MAX_LEN 36
363 #else
364 #define MBEDTLS_SSL_VERIFY_DATA_MAX_LEN 12
365 #endif
366 
367 /*
368  * Signaling ciphersuite values (SCSV)
369  */
370 #define MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO 0xFF
371 #define MBEDTLS_SSL_FALLBACK_SCSV_VALUE 0x5600
373 /*
374  * Supported Signature and Hash algorithms (For TLS 1.2)
375  * RFC 5246 section 7.4.1.4.1
376  */
377 #define MBEDTLS_SSL_HASH_NONE 0
378 #define MBEDTLS_SSL_HASH_MD5 1
379 #define MBEDTLS_SSL_HASH_SHA1 2
380 #define MBEDTLS_SSL_HASH_SHA224 3
381 #define MBEDTLS_SSL_HASH_SHA256 4
382 #define MBEDTLS_SSL_HASH_SHA384 5
383 #define MBEDTLS_SSL_HASH_SHA512 6
384 
385 #define MBEDTLS_SSL_SIG_ANON 0
386 #define MBEDTLS_SSL_SIG_RSA 1
387 #define MBEDTLS_SSL_SIG_ECDSA 3
388 
389 /*
390  * Client Certificate Types
391  * RFC 5246 section 7.4.4 plus RFC 4492 section 5.5
392  */
393 #define MBEDTLS_SSL_CERT_TYPE_RSA_SIGN 1
394 #define MBEDTLS_SSL_CERT_TYPE_ECDSA_SIGN 64
395 
396 /*
397  * Message, alert and handshake types
398  */
399 #define MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC 20
400 #define MBEDTLS_SSL_MSG_ALERT 21
401 #define MBEDTLS_SSL_MSG_HANDSHAKE 22
402 #define MBEDTLS_SSL_MSG_APPLICATION_DATA 23
403 #define MBEDTLS_SSL_MSG_CID 25
404 
405 #define MBEDTLS_SSL_ALERT_LEVEL_WARNING 1
406 #define MBEDTLS_SSL_ALERT_LEVEL_FATAL 2
407 
408 #define MBEDTLS_SSL_ALERT_MSG_CLOSE_NOTIFY 0 /* 0x00 */
409 #define MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE 10 /* 0x0A */
410 #define MBEDTLS_SSL_ALERT_MSG_BAD_RECORD_MAC 20 /* 0x14 */
411 #define MBEDTLS_SSL_ALERT_MSG_DECRYPTION_FAILED 21 /* 0x15 */
412 #define MBEDTLS_SSL_ALERT_MSG_RECORD_OVERFLOW 22 /* 0x16 */
413 #define MBEDTLS_SSL_ALERT_MSG_DECOMPRESSION_FAILURE 30 /* 0x1E */
414 #define MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE 40 /* 0x28 */
415 #define MBEDTLS_SSL_ALERT_MSG_NO_CERT 41 /* 0x29 */
416 #define MBEDTLS_SSL_ALERT_MSG_BAD_CERT 42 /* 0x2A */
417 #define MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT 43 /* 0x2B */
418 #define MBEDTLS_SSL_ALERT_MSG_CERT_REVOKED 44 /* 0x2C */
419 #define MBEDTLS_SSL_ALERT_MSG_CERT_EXPIRED 45 /* 0x2D */
420 #define MBEDTLS_SSL_ALERT_MSG_CERT_UNKNOWN 46 /* 0x2E */
421 #define MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER 47 /* 0x2F */
422 #define MBEDTLS_SSL_ALERT_MSG_UNKNOWN_CA 48 /* 0x30 */
423 #define MBEDTLS_SSL_ALERT_MSG_ACCESS_DENIED 49 /* 0x31 */
424 #define MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR 50 /* 0x32 */
425 #define MBEDTLS_SSL_ALERT_MSG_DECRYPT_ERROR 51 /* 0x33 */
426 #define MBEDTLS_SSL_ALERT_MSG_EXPORT_RESTRICTION 60 /* 0x3C */
427 #define MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION 70 /* 0x46 */
428 #define MBEDTLS_SSL_ALERT_MSG_INSUFFICIENT_SECURITY 71 /* 0x47 */
429 #define MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR 80 /* 0x50 */
430 #define MBEDTLS_SSL_ALERT_MSG_INAPROPRIATE_FALLBACK 86 /* 0x56 */
431 #define MBEDTLS_SSL_ALERT_MSG_USER_CANCELED 90 /* 0x5A */
432 #define MBEDTLS_SSL_ALERT_MSG_NO_RENEGOTIATION 100 /* 0x64 */
433 #define MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_EXT 110 /* 0x6E */
434 #define MBEDTLS_SSL_ALERT_MSG_UNRECOGNIZED_NAME 112 /* 0x70 */
435 #define MBEDTLS_SSL_ALERT_MSG_UNKNOWN_PSK_IDENTITY 115 /* 0x73 */
436 #define MBEDTLS_SSL_ALERT_MSG_NO_APPLICATION_PROTOCOL 120 /* 0x78 */
437 
438 #define MBEDTLS_SSL_HS_HELLO_REQUEST 0
439 #define MBEDTLS_SSL_HS_CLIENT_HELLO 1
440 #define MBEDTLS_SSL_HS_SERVER_HELLO 2
441 #define MBEDTLS_SSL_HS_HELLO_VERIFY_REQUEST 3
442 #define MBEDTLS_SSL_HS_NEW_SESSION_TICKET 4
443 #define MBEDTLS_SSL_HS_CERTIFICATE 11
444 #define MBEDTLS_SSL_HS_SERVER_KEY_EXCHANGE 12
445 #define MBEDTLS_SSL_HS_CERTIFICATE_REQUEST 13
446 #define MBEDTLS_SSL_HS_SERVER_HELLO_DONE 14
447 #define MBEDTLS_SSL_HS_CERTIFICATE_VERIFY 15
448 #define MBEDTLS_SSL_HS_CLIENT_KEY_EXCHANGE 16
449 #define MBEDTLS_SSL_HS_FINISHED 20
450 
451 /*
452  * TLS extensions
453  */
454 #define MBEDTLS_TLS_EXT_SERVERNAME 0
455 #define MBEDTLS_TLS_EXT_SERVERNAME_HOSTNAME 0
456 
457 #define MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH 1
458 
459 #define MBEDTLS_TLS_EXT_TRUNCATED_HMAC 4
460 
461 #define MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES 10
462 #define MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS 11
463 
464 #define MBEDTLS_TLS_EXT_SIG_ALG 13
465 
466 #define MBEDTLS_TLS_EXT_USE_SRTP 14
467 
468 #define MBEDTLS_TLS_EXT_ALPN 16
469 
470 #define MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC 22 /* 0x16 */
471 #define MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET 0x0017 /* 23 */
472 
473 #define MBEDTLS_TLS_EXT_SESSION_TICKET 35
474 
475 /* The value of the CID extension is still TBD as of
476  * draft-ietf-tls-dtls-connection-id-05
477  * (https://tools.ietf.org/html/draft-ietf-tls-dtls-connection-id-05).
478  *
479  * A future minor revision of Mbed TLS may change the default value of
480  * this option to match evolving standards and usage.
481  */
482 #if !defined(MBEDTLS_TLS_EXT_CID)
483 #define MBEDTLS_TLS_EXT_CID 254 /* TBD */
484 #endif
485 
486 #define MBEDTLS_TLS_EXT_ECJPAKE_KKPP 256 /* experimental */
487 
488 #define MBEDTLS_TLS_EXT_RENEGOTIATION_INFO 0xFF01
489 
490 /*
491  * Size defines
492  */
493 #if !defined(MBEDTLS_PSK_MAX_LEN)
494 #define MBEDTLS_PSK_MAX_LEN 32 /* 256 bits */
495 #endif
496 
497 /* Dummy type used only for its size */
499  unsigned char dummy; /* Make the union non-empty even with SSL disabled */
500 #if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED)
501  unsigned char _pms_rsa[48]; /* RFC 5246 8.1.1 */
502 #endif
503 #if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED)
504  unsigned char _pms_dhm[MBEDTLS_MPI_MAX_SIZE]; /* RFC 5246 8.1.2 */
505 #endif
506 #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
507  defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \
508  defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \
509  defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)
510  unsigned char _pms_ecdh[MBEDTLS_ECP_MAX_BYTES]; /* RFC 4492 5.10 */
511 #endif
512 #if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED)
513  unsigned char _pms_psk[4 + 2 * MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 2 */
514 #endif
515 #if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED)
516  unsigned char _pms_dhe_psk[4 + MBEDTLS_MPI_MAX_SIZE
517  + MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 3 */
518 #endif
519 #if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED)
520  unsigned char _pms_rsa_psk[52 + MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 4 */
521 #endif
522 #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED)
523  unsigned char _pms_ecdhe_psk[4 + MBEDTLS_ECP_MAX_BYTES
524  + MBEDTLS_PSK_MAX_LEN]; /* RFC 5489 2 */
525 #endif
526 #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
527  unsigned char _pms_ecjpake[32]; /* Thread spec: SHA-256 output */
528 #endif
529 };
530 
531 #define MBEDTLS_PREMASTER_SIZE sizeof(union mbedtls_ssl_premaster_secret)
532 
533 #ifdef __cplusplus
534 extern "C" {
535 #endif
536 
537 /*
538  * SSL state machine
539  */
540 typedef enum {
560 }
562 
563 /*
564  * The tls_prf function types.
565  */
566 typedef enum {
572 }
591 typedef int mbedtls_ssl_send_t(void *ctx,
592  const unsigned char *buf,
593  size_t len);
594 
615 typedef int mbedtls_ssl_recv_t(void *ctx,
616  unsigned char *buf,
617  size_t len);
618 
641 typedef int mbedtls_ssl_recv_timeout_t(void *ctx,
642  unsigned char *buf,
643  size_t len,
644  uint32_t timeout);
667 typedef void mbedtls_ssl_set_timer_t(void *ctx,
668  uint32_t int_ms,
669  uint32_t fin_ms);
670 
682 typedef int mbedtls_ssl_get_timer_t(void *ctx);
683 
684 /* Defined below */
688 
689 /* Defined in ssl_internal.h */
693 #if defined(MBEDTLS_X509_CRT_PARSE_C)
695 #endif
696 #if defined(MBEDTLS_SSL_PROTO_DTLS)
698 #endif
699 
700 #if defined(MBEDTLS_SSL_ASYNC_PRIVATE)
701 #if defined(MBEDTLS_X509_CRT_PARSE_C)
702 
773 typedef int mbedtls_ssl_async_sign_t(mbedtls_ssl_context *ssl,
774  mbedtls_x509_crt *cert,
775  mbedtls_md_type_t md_alg,
776  const unsigned char *hash,
777  size_t hash_len);
778 
839 typedef int mbedtls_ssl_async_decrypt_t(mbedtls_ssl_context *ssl,
840  mbedtls_x509_crt *cert,
841  const unsigned char *input,
842  size_t input_len);
843 #endif /* MBEDTLS_X509_CRT_PARSE_C */
844 
887 typedef int mbedtls_ssl_async_resume_t(mbedtls_ssl_context *ssl,
888  unsigned char *output,
889  size_t *output_len,
890  size_t output_size);
891 
909 typedef void mbedtls_ssl_async_cancel_t(mbedtls_ssl_context *ssl);
910 #endif /* MBEDTLS_SSL_ASYNC_PRIVATE */
911 
912 #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) && \
913  !defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE)
914 #define MBEDTLS_SSL_PEER_CERT_DIGEST_MAX_LEN 48
915 #if defined(MBEDTLS_SHA256_C)
916 #define MBEDTLS_SSL_PEER_CERT_DIGEST_DFL_TYPE MBEDTLS_MD_SHA256
917 #define MBEDTLS_SSL_PEER_CERT_DIGEST_DFL_LEN 32
918 #elif defined(MBEDTLS_SHA512_C)
919 #define MBEDTLS_SSL_PEER_CERT_DIGEST_DFL_TYPE MBEDTLS_MD_SHA384
920 #define MBEDTLS_SSL_PEER_CERT_DIGEST_DFL_LEN 48
921 #elif defined(MBEDTLS_SHA1_C)
922 #define MBEDTLS_SSL_PEER_CERT_DIGEST_DFL_TYPE MBEDTLS_MD_SHA1
923 #define MBEDTLS_SSL_PEER_CERT_DIGEST_DFL_LEN 20
924 #else
925 /* This is already checked in check_config.h, but be sure. */
926 #error "Bad configuration - need SHA-1, SHA-256 or SHA-512 enabled to compute digest of peer CRT."
927 #endif
928 #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED &&
929  !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE */
930 
931 #if defined(MBEDTLS_SSL_DTLS_SRTP)
932 
933 #define MBEDTLS_TLS_SRTP_MAX_MKI_LENGTH 255
934 #define MBEDTLS_TLS_SRTP_MAX_PROFILE_LIST_LENGTH 4
935 /*
936  * For code readability use a typedef for DTLS-SRTP profiles
937  *
938  * Use_srtp extension protection profiles values as defined in
939  * http://www.iana.org/assignments/srtp-protection/srtp-protection.xhtml
940  *
941  * Reminder: if this list is expanded mbedtls_ssl_check_srtp_profile_value
942  * must be updated too.
943  */
944 #define MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_80 ((uint16_t) 0x0001)
945 #define MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32 ((uint16_t) 0x0002)
946 #define MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_80 ((uint16_t) 0x0005)
947 #define MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_32 ((uint16_t) 0x0006)
948 /* This one is not iana defined, but for code readability. */
949 #define MBEDTLS_TLS_SRTP_UNSET ((uint16_t) 0x0000)
950 
951 typedef uint16_t mbedtls_ssl_srtp_profile;
952 
953 typedef struct mbedtls_dtls_srtp_info_t {
955  mbedtls_ssl_srtp_profile chosen_dtls_srtp_profile;
957  uint16_t mki_len;
959  unsigned char mki_value[MBEDTLS_TLS_SRTP_MAX_MKI_LENGTH];
960 }
961 mbedtls_dtls_srtp_info;
962 
963 #endif /* MBEDTLS_SSL_DTLS_SRTP */
964 
965 /*
966  * This structure is used for storing current session data.
967  *
968  * Note: when changing this definition, we need to check and update:
969  * - in tests/suites/test_suite_ssl.function:
970  * ssl_populate_session() and ssl_serialize_session_save_load()
971  * - in library/ssl_tls.c:
972  * mbedtls_ssl_session_init() and mbedtls_ssl_session_free()
973  * mbedtls_ssl_session_save() and ssl_session_load()
974  * ssl_session_copy()
975  */
977 #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
978  unsigned char mfl_code;
979 #endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
980 
981 #if defined(MBEDTLS_HAVE_TIME)
983 #endif
986  size_t id_len;
987  unsigned char id[32];
988  unsigned char master[48];
990 #if defined(MBEDTLS_X509_CRT_PARSE_C)
991 #if defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE)
993 #else /* MBEDTLS_SSL_KEEP_PEER_CERTIFICATE */
994 
996  unsigned char *peer_cert_digest;
997  size_t peer_cert_digest_len;
998  mbedtls_md_type_t peer_cert_digest_type;
999 #endif /* !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE */
1000 #endif /* MBEDTLS_X509_CRT_PARSE_C */
1001  uint32_t verify_result;
1003 #if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_CLI_C)
1004  unsigned char *ticket;
1005  size_t ticket_len;
1006  uint32_t ticket_lifetime;
1007 #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_CLI_C */
1008 
1009 #if defined(MBEDTLS_SSL_TRUNCATED_HMAC)
1011 #endif /* MBEDTLS_SSL_TRUNCATED_HMAC */
1012 
1013 #if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
1015 #endif
1016 };
1017 
1022  /* Group items by size and reorder them to maximize usage of immediate offset access. */
1023 
1024  /*
1025  * Numerical settings (char)
1026  */
1027 
1028  unsigned char max_major_ver;
1029  unsigned char max_minor_ver;
1030  unsigned char min_major_ver;
1031  unsigned char min_minor_ver;
1033  /*
1034  * Flags (could be bit-fields to save RAM, but separate bytes make
1035  * the code smaller on architectures with an instruction for direct
1036  * byte access).
1037  */
1038 
1039  uint8_t endpoint /*bool*/;
1040  uint8_t transport /*bool*/;
1041  uint8_t authmode /*2 bits*/;
1042  /* needed even with renego disabled for LEGACY_BREAK_HANDSHAKE */
1043  uint8_t allow_legacy_renegotiation /*2 bits*/;
1044 #if defined(MBEDTLS_ARC4_C)
1045  uint8_t arc4_disabled /*bool*/;
1046 #endif
1047 #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
1048  uint8_t mfl_code /*3 bits*/;
1049 #endif
1050 #if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
1051  uint8_t encrypt_then_mac /*bool*/;
1052 #endif
1053 #if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET)
1054  uint8_t extended_ms /*bool*/;
1055 #endif
1056 #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)
1057  uint8_t anti_replay /*bool*/;
1058 #endif
1059 #if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING)
1060  uint8_t cbc_record_splitting /*bool*/;
1061 #endif
1062 #if defined(MBEDTLS_SSL_RENEGOTIATION)
1063  uint8_t disable_renegotiation /*bool*/;
1064 #endif
1065 #if defined(MBEDTLS_SSL_TRUNCATED_HMAC)
1066  uint8_t trunc_hmac /*bool*/;
1067 #endif
1068 #if defined(MBEDTLS_SSL_SESSION_TICKETS)
1069  uint8_t session_tickets /*bool*/;
1070 #endif
1071 #if defined(MBEDTLS_SSL_FALLBACK_SCSV) && defined(MBEDTLS_SSL_CLI_C)
1072  uint8_t fallback /*bool*/;
1073 #endif
1074 #if defined(MBEDTLS_SSL_SRV_C)
1075  uint8_t cert_req_ca_list /*bool*/;
1077 #endif
1078 #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
1079  uint8_t ignore_unexpected_cid /*bool*/;
1082 #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
1083 #if defined(MBEDTLS_SSL_DTLS_SRTP)
1084  uint8_t dtls_srtp_mki_support /*bool*/;
1086 #endif
1087 
1088  /*
1089  * Numerical settings (int or larger)
1090  */
1091 
1092  uint32_t read_timeout;
1094 #if defined(MBEDTLS_SSL_PROTO_DTLS)
1095  uint32_t hs_timeout_min;
1097  uint32_t hs_timeout_max;
1099 #endif
1100 
1101 #if defined(MBEDTLS_SSL_RENEGOTIATION)
1103  unsigned char renego_period[8];
1105 #endif
1106 
1107 #if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT)
1108  unsigned int badmac_limit;
1109 #endif
1110 
1111 #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C)
1112  unsigned int dhm_min_bitlen;
1113 #endif
1114 
1115  /*
1116  * Pointers
1117  */
1118 
1119  const int *ciphersuite_list[4];
1122  void (*f_dbg)(void *, int, const char *, int, const char *);
1123  void *p_dbg;
1126  int (*f_rng)(void *, unsigned char *, size_t);
1127  void *p_rng;
1132  int (*f_set_cache)(void *, const mbedtls_ssl_session *);
1133  void *p_cache;
1135 #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
1136 
1137  int (*f_sni)(void *, mbedtls_ssl_context *, const unsigned char *, size_t);
1138  void *p_sni;
1139 #endif
1140 
1141 #if defined(MBEDTLS_X509_CRT_PARSE_C)
1142 
1143  int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *);
1144  void *p_vrfy;
1145 #endif
1146 
1147 #if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
1148 
1149  int (*f_psk)(void *, mbedtls_ssl_context *, const unsigned char *, size_t);
1150  void *p_psk;
1151 #endif
1152 
1153 #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C)
1154 
1155  int (*f_cookie_write)(void *, unsigned char **, unsigned char *,
1156  const unsigned char *, size_t);
1158  int (*f_cookie_check)(void *, const unsigned char *, size_t,
1159  const unsigned char *, size_t);
1160  void *p_cookie;
1161 #endif
1162 
1163 #if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_SRV_C)
1164 
1165  int (*f_ticket_write)(void *, const mbedtls_ssl_session *,
1166  unsigned char *, const unsigned char *, size_t *, uint32_t *);
1168  int (*f_ticket_parse)(void *, mbedtls_ssl_session *, unsigned char *, size_t);
1169  void *p_ticket;
1170 #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_SRV_C */
1171 
1172 #if defined(MBEDTLS_SSL_EXPORT_KEYS)
1173 
1174  int (*f_export_keys)(void *, const unsigned char *,
1175  const unsigned char *, size_t, size_t, size_t);
1178  int (*f_export_keys_ext)(void *, const unsigned char *,
1179  const unsigned char *, size_t, size_t, size_t,
1180  const unsigned char[32], const unsigned char[32],
1183 #endif
1184 
1185 #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
1186  size_t cid_len;
1187 #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
1188 
1189 #if defined(MBEDTLS_X509_CRT_PARSE_C)
1194 #if defined(MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK)
1195  mbedtls_x509_crt_ca_cb_t f_ca_cb;
1196  void *p_ca_cb;
1197 #endif /* MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK */
1198 #endif /* MBEDTLS_X509_CRT_PARSE_C */
1199 
1200 #if defined(MBEDTLS_SSL_ASYNC_PRIVATE)
1201 #if defined(MBEDTLS_X509_CRT_PARSE_C)
1202  mbedtls_ssl_async_sign_t *f_async_sign_start;
1203  mbedtls_ssl_async_decrypt_t *f_async_decrypt_start;
1204 #endif /* MBEDTLS_X509_CRT_PARSE_C */
1205  mbedtls_ssl_async_resume_t *f_async_resume;
1206  mbedtls_ssl_async_cancel_t *f_async_cancel;
1207  void *p_async_config_data;
1208 #endif /* MBEDTLS_SSL_ASYNC_PRIVATE */
1209 
1210 #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED)
1211  const int *sig_hashes;
1212 #endif
1213 
1214 #if defined(MBEDTLS_ECP_C)
1216 #endif
1217 
1218 #if defined(MBEDTLS_DHM_C)
1221 #endif
1222 
1223 #if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
1224 
1225 #if defined(MBEDTLS_USE_PSA_CRYPTO)
1226  psa_key_id_t psk_opaque;
1232 #endif /* MBEDTLS_USE_PSA_CRYPTO */
1233 
1234  unsigned char *psk;
1238  size_t psk_len;
1244  unsigned char *psk_identity;
1255 #endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED */
1256 
1257 #if defined(MBEDTLS_SSL_ALPN)
1258  const char **alpn_list;
1259 #endif
1260 
1261 #if defined(MBEDTLS_SSL_DTLS_SRTP)
1262 
1263  const mbedtls_ssl_srtp_profile *dtls_srtp_profile_list;
1265  size_t dtls_srtp_profile_list_len;
1266 #endif /* MBEDTLS_SSL_DTLS_SRTP */
1267 };
1268 
1272  /*
1273  * Miscellaneous
1274  */
1275  int state;
1276 #if defined(MBEDTLS_SSL_RENEGOTIATION)
1281 #endif /* MBEDTLS_SSL_RENEGOTIATION */
1282 
1286 #if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT)
1287  unsigned badmac_seen;
1288 #endif /* MBEDTLS_SSL_DTLS_BADMAC_LIMIT */
1289 
1290 #if defined(MBEDTLS_X509_CRT_PARSE_C)
1291 
1292  int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *);
1293  void *p_vrfy;
1294 #endif
1295 
1301  void *p_bio;
1303  /*
1304  * Session layer
1305  */
1314  /*
1315  * Record layer transformations
1316  */
1322  /*
1323  * Timers
1324  */
1325  void *p_timer;
1330  /*
1331  * Record layer (incoming data)
1332  */
1333  unsigned char *in_buf;
1334  unsigned char *in_ctr;
1337  unsigned char *in_hdr;
1338 #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
1339  unsigned char *in_cid;
1341 #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
1342  unsigned char *in_len;
1343  unsigned char *in_iv;
1344  unsigned char *in_msg;
1345  unsigned char *in_offt;
1348  size_t in_msglen;
1349  size_t in_left;
1350 #if defined(MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH)
1351  size_t in_buf_len;
1352 #endif
1353 #if defined(MBEDTLS_SSL_PROTO_DTLS)
1354  uint16_t in_epoch;
1357 #endif /* MBEDTLS_SSL_PROTO_DTLS */
1358 #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)
1359  uint64_t in_window_top;
1360  uint64_t in_window;
1361 #endif /* MBEDTLS_SSL_DTLS_ANTI_REPLAY */
1362 
1363  size_t in_hslen;
1365  int nb_zero;
1370 #if defined(MBEDTLS_SSL_PROTO_DTLS)
1373 #endif /* MBEDTLS_SSL_PROTO_DTLS */
1374 
1375  /*
1376  * Record layer (outgoing data)
1377  */
1378  unsigned char *out_buf;
1379  unsigned char *out_ctr;
1380  unsigned char *out_hdr;
1381 #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
1382  unsigned char *out_cid;
1384 #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
1385  unsigned char *out_len;
1386  unsigned char *out_iv;
1387  unsigned char *out_msg;
1390  size_t out_msglen;
1391  size_t out_left;
1392 #if defined(MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH)
1393  size_t out_buf_len;
1394 #endif
1395 
1396  unsigned char cur_out_ctr[8];
1398 #if defined(MBEDTLS_SSL_PROTO_DTLS)
1399  uint16_t mtu;
1400 #endif /* MBEDTLS_SSL_PROTO_DTLS */
1401 
1402 #if defined(MBEDTLS_ZLIB_SUPPORT)
1403  unsigned char *compress_buf;
1404 #endif /* MBEDTLS_ZLIB_SUPPORT */
1405 #if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING)
1406  signed char split_done;
1407 #endif /* MBEDTLS_SSL_CBC_RECORD_SPLITTING */
1408 
1409  /*
1410  * PKI layer
1411  */
1414  /*
1415  * User settings
1416  */
1417 #if defined(MBEDTLS_X509_CRT_PARSE_C)
1418  char *hostname;
1420 #endif /* MBEDTLS_X509_CRT_PARSE_C */
1421 
1422 #if defined(MBEDTLS_SSL_ALPN)
1423  const char *alpn_chosen;
1424 #endif /* MBEDTLS_SSL_ALPN */
1425 
1426 #if defined(MBEDTLS_SSL_DTLS_SRTP)
1427  /*
1428  * use_srtp extension
1429  */
1430  mbedtls_dtls_srtp_info dtls_srtp_info;
1431 #endif /* MBEDTLS_SSL_DTLS_SRTP */
1432 
1433  /*
1434  * Information for DTLS hello verify
1435  */
1436 #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C)
1437  unsigned char *cli_id;
1438  size_t cli_id_len;
1439 #endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY && MBEDTLS_SSL_SRV_C */
1440 
1441  /*
1442  * Secure renegotiation
1443  */
1444  /* needed to know when to send extension on server */
1447 #if defined(MBEDTLS_SSL_RENEGOTIATION)
1451 #endif /* MBEDTLS_SSL_RENEGOTIATION */
1452 
1453 #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
1454  /* CID configuration to use in subsequent handshakes. */
1455 
1460  unsigned char own_cid[MBEDTLS_SSL_CID_IN_LEN_MAX];
1461  uint8_t own_cid_len;
1462  uint8_t negotiate_cid;
1466 #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
1467 };
1468 
1469 #if defined(MBEDTLS_SSL_HW_RECORD_ACCEL)
1470 
1471 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
1472 
1473 #define MBEDTLS_SSL_CHANNEL_OUTBOUND MBEDTLS_DEPRECATED_NUMERIC_CONSTANT(0)
1474 #define MBEDTLS_SSL_CHANNEL_INBOUND MBEDTLS_DEPRECATED_NUMERIC_CONSTANT(1)
1475 
1476 #if defined(MBEDTLS_DEPRECATED_WARNING)
1477 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
1478 #else
1479 #define MBEDTLS_DEPRECATED
1480 #endif /* MBEDTLS_DEPRECATED_WARNING */
1481 
1482 MBEDTLS_DEPRECATED extern int (*mbedtls_ssl_hw_record_init)(
1483  mbedtls_ssl_context *ssl,
1484  const unsigned char *key_enc, const unsigned char *key_dec,
1485  size_t keylen,
1486  const unsigned char *iv_enc, const unsigned char *iv_dec,
1487  size_t ivlen,
1488  const unsigned char *mac_enc, const unsigned char *mac_dec,
1489  size_t maclen);
1490 MBEDTLS_DEPRECATED extern int (*mbedtls_ssl_hw_record_activate)(
1491  mbedtls_ssl_context *ssl,
1492  int direction);
1493 MBEDTLS_DEPRECATED extern int (*mbedtls_ssl_hw_record_reset)(
1494  mbedtls_ssl_context *ssl);
1495 MBEDTLS_DEPRECATED extern int (*mbedtls_ssl_hw_record_write)(
1496  mbedtls_ssl_context *ssl);
1497 MBEDTLS_DEPRECATED extern int (*mbedtls_ssl_hw_record_read)(
1498  mbedtls_ssl_context *ssl);
1499 MBEDTLS_DEPRECATED extern int (*mbedtls_ssl_hw_record_finish)(
1500  mbedtls_ssl_context *ssl);
1501 
1502 #undef MBEDTLS_DEPRECATED
1503 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
1504 
1505 #endif /* MBEDTLS_SSL_HW_RECORD_ACCEL */
1506 
1515 const char *mbedtls_ssl_get_ciphersuite_name(const int ciphersuite_id);
1516 
1525 int mbedtls_ssl_get_ciphersuite_id(const char *ciphersuite_name);
1526 
1535 
1561  const mbedtls_ssl_config *conf);
1562 
1574 
1581 void mbedtls_ssl_conf_endpoint(mbedtls_ssl_config *conf, int endpoint);
1582 
1597 void mbedtls_ssl_conf_transport(mbedtls_ssl_config *conf, int transport);
1598 
1625 void mbedtls_ssl_conf_authmode(mbedtls_ssl_config *conf, int authmode);
1626 
1627 #if defined(MBEDTLS_X509_CRT_PARSE_C)
1628 
1644  int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *),
1645  void *p_vrfy);
1646 #endif /* MBEDTLS_X509_CRT_PARSE_C */
1647 
1656  int (*f_rng)(void *, unsigned char *, size_t),
1657  void *p_rng);
1658 
1674  void (*f_dbg)(void *, int, const char *, int, const char *),
1675  void *p_dbg);
1676 
1708  void *p_bio,
1709  mbedtls_ssl_send_t *f_send,
1710  mbedtls_ssl_recv_t *f_recv,
1711  mbedtls_ssl_recv_timeout_t *f_recv_timeout);
1712 
1713 #if defined(MBEDTLS_SSL_PROTO_DTLS)
1714 
1715 #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
1716 
1717 
1801 int mbedtls_ssl_set_cid(mbedtls_ssl_context *ssl,
1802  int enable,
1803  unsigned char const *own_cid,
1804  size_t own_cid_len);
1805 
1843 int mbedtls_ssl_get_peer_cid(mbedtls_ssl_context *ssl,
1844  int *enabled,
1845  unsigned char peer_cid[MBEDTLS_SSL_CID_OUT_LEN_MAX],
1846  size_t *peer_cid_len);
1847 
1848 #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
1849 
1892 void mbedtls_ssl_set_mtu(mbedtls_ssl_context *ssl, uint16_t mtu);
1893 #endif /* MBEDTLS_SSL_PROTO_DTLS */
1894 
1895 #if defined(MBEDTLS_X509_CRT_PARSE_C)
1896 
1915  int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *),
1916  void *p_vrfy);
1917 #endif /* MBEDTLS_X509_CRT_PARSE_C */
1918 
1935 void mbedtls_ssl_conf_read_timeout(mbedtls_ssl_config *conf, uint32_t timeout);
1936 
1937 #if defined(MBEDTLS_SSL_RECORD_CHECKING)
1938 
1983  unsigned char *buf,
1984  size_t buflen);
1985 #endif /* MBEDTLS_SSL_RECORD_CHECKING */
1986 
2008  void *p_timer,
2009  mbedtls_ssl_set_timer_t *f_set_timer,
2010  mbedtls_ssl_get_timer_t *f_get_timer);
2011 
2031 typedef int mbedtls_ssl_ticket_write_t(void *p_ticket,
2032  const mbedtls_ssl_session *session,
2033  unsigned char *start,
2034  const unsigned char *end,
2035  size_t *tlen,
2036  uint32_t *lifetime);
2037 
2038 #if defined(MBEDTLS_SSL_EXPORT_KEYS)
2039 
2059 typedef int mbedtls_ssl_export_keys_t(void *p_expkey,
2060  const unsigned char *ms,
2061  const unsigned char *kb,
2062  size_t maclen,
2063  size_t keylen,
2064  size_t ivlen);
2065 
2091 typedef int mbedtls_ssl_export_keys_ext_t(void *p_expkey,
2092  const unsigned char *ms,
2093  const unsigned char *kb,
2094  size_t maclen,
2095  size_t keylen,
2096  size_t ivlen,
2097  const unsigned char client_random[32],
2098  const unsigned char server_random[32],
2099  mbedtls_tls_prf_types tls_prf_type);
2100 #endif /* MBEDTLS_SSL_EXPORT_KEYS */
2101 
2125 typedef int mbedtls_ssl_ticket_parse_t(void *p_ticket,
2126  mbedtls_ssl_session *session,
2127  unsigned char *buf,
2128  size_t len);
2129 
2130 #if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_SRV_C)
2131 
2146  mbedtls_ssl_ticket_write_t *f_ticket_write,
2147  mbedtls_ssl_ticket_parse_t *f_ticket_parse,
2148  void *p_ticket);
2149 #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_SRV_C */
2150 
2151 #if defined(MBEDTLS_SSL_EXPORT_KEYS)
2152 
2163  mbedtls_ssl_export_keys_t *f_export_keys,
2164  void *p_export_keys);
2165 
2179  mbedtls_ssl_export_keys_ext_t *f_export_keys_ext,
2180  void *p_export_keys);
2181 #endif /* MBEDTLS_SSL_EXPORT_KEYS */
2182 
2183 #if defined(MBEDTLS_SSL_ASYNC_PRIVATE)
2184 
2214 void mbedtls_ssl_conf_async_private_cb(mbedtls_ssl_config *conf,
2215  mbedtls_ssl_async_sign_t *f_async_sign,
2216  mbedtls_ssl_async_decrypt_t *f_async_decrypt,
2217  mbedtls_ssl_async_resume_t *f_async_resume,
2218  mbedtls_ssl_async_cancel_t *f_async_cancel,
2219  void *config_data);
2220 
2229 void *mbedtls_ssl_conf_get_async_config_data(const mbedtls_ssl_config *conf);
2230 
2245 void *mbedtls_ssl_get_async_operation_data(const mbedtls_ssl_context *ssl);
2246 
2258 void mbedtls_ssl_set_async_operation_data(mbedtls_ssl_context *ssl,
2259  void *ctx);
2260 #endif /* MBEDTLS_SSL_ASYNC_PRIVATE */
2261 
2276 typedef int mbedtls_ssl_cookie_write_t(void *ctx,
2277  unsigned char **p, unsigned char *end,
2278  const unsigned char *info, size_t ilen);
2279 
2293 typedef int mbedtls_ssl_cookie_check_t(void *ctx,
2294  const unsigned char *cookie, size_t clen,
2295  const unsigned char *info, size_t ilen);
2296 
2297 #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C)
2298 
2327  mbedtls_ssl_cookie_write_t *f_cookie_write,
2328  mbedtls_ssl_cookie_check_t *f_cookie_check,
2329  void *p_cookie);
2330 
2351  const unsigned char *info,
2352  size_t ilen);
2353 
2354 #endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY && MBEDTLS_SSL_SRV_C */
2355 
2356 #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)
2357 
2373 #endif /* MBEDTLS_SSL_DTLS_ANTI_REPLAY */
2374 
2375 #if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT)
2376 
2399 void mbedtls_ssl_conf_dtls_badmac_limit(mbedtls_ssl_config *conf, unsigned limit);
2400 #endif /* MBEDTLS_SSL_DTLS_BADMAC_LIMIT */
2401 
2402 #if defined(MBEDTLS_SSL_PROTO_DTLS)
2403 
2433  unsigned allow_packing);
2434 
2466 void mbedtls_ssl_conf_handshake_timeout(mbedtls_ssl_config *conf, uint32_t min, uint32_t max);
2467 #endif /* MBEDTLS_SSL_PROTO_DTLS */
2468 
2469 #if defined(MBEDTLS_SSL_SRV_C)
2470 
2508  void *p_cache,
2509  int (*f_get_cache)(void *, mbedtls_ssl_session *),
2510  int (*f_set_cache)(void *, const mbedtls_ssl_session *));
2511 #endif /* MBEDTLS_SSL_SRV_C */
2512 
2513 #if defined(MBEDTLS_SSL_CLI_C)
2514 
2529 #endif /* MBEDTLS_SSL_CLI_C */
2530 
2564  const unsigned char *buf,
2565  size_t len);
2566 
2594  unsigned char *buf,
2595  size_t buf_len,
2596  size_t *olen);
2597 
2614 
2631  const int *ciphersuites);
2632 
2633 #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
2634 #define MBEDTLS_SSL_UNEXPECTED_CID_IGNORE 0
2635 #define MBEDTLS_SSL_UNEXPECTED_CID_FAIL 1
2636 
2668 int mbedtls_ssl_conf_cid(mbedtls_ssl_config *conf, size_t len,
2669  int ignore_other_cids);
2670 #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
2671 
2692  const int *ciphersuites,
2693  int major, int minor);
2694 
2695 #if defined(MBEDTLS_X509_CRT_PARSE_C)
2696 
2707  const mbedtls_x509_crt_profile *profile);
2708 
2721  mbedtls_x509_crt *ca_chain,
2722  mbedtls_x509_crl *ca_crl);
2723 
2724 #if defined(MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK)
2725 
2776 void mbedtls_ssl_conf_ca_cb(mbedtls_ssl_config *conf,
2777  mbedtls_x509_crt_ca_cb_t f_ca_cb,
2778  void *p_ca_cb);
2779 #endif /* MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK */
2780 
2818  mbedtls_x509_crt *own_cert,
2819  mbedtls_pk_context *pk_key);
2820 #endif /* MBEDTLS_X509_CRT_PARSE_C */
2821 
2822 #if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
2823 
2855  const unsigned char *psk, size_t psk_len,
2856  const unsigned char *psk_identity, size_t psk_identity_len);
2857 
2858 #if defined(MBEDTLS_USE_PSA_CRYPTO)
2859 
2895 int mbedtls_ssl_conf_psk_opaque(mbedtls_ssl_config *conf,
2896  psa_key_id_t psk,
2897  const unsigned char *psk_identity,
2898  size_t psk_identity_len);
2899 #endif /* MBEDTLS_USE_PSA_CRYPTO */
2900 
2918  const unsigned char *psk, size_t psk_len);
2919 
2920 #if defined(MBEDTLS_USE_PSA_CRYPTO)
2921 
2941 int mbedtls_ssl_set_hs_psk_opaque(mbedtls_ssl_context *ssl,
2942  psa_key_id_t psk);
2943 #endif /* MBEDTLS_USE_PSA_CRYPTO */
2944 
2984  int (*f_psk)(void *, mbedtls_ssl_context *, const unsigned char *,
2985  size_t),
2986  void *p_psk);
2987 #endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED */
2988 
2989 #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_SRV_C)
2990 
2991 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
2992 
2993 #if defined(MBEDTLS_DEPRECATED_WARNING)
2994 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
2995 #else
2996 #define MBEDTLS_DEPRECATED
2997 #endif
2998 
3013  const char *dhm_P,
3014  const char *dhm_G);
3015 
3016 #endif /* MBEDTLS_DEPRECATED_REMOVED */
3017 
3032  const unsigned char *dhm_P, size_t P_len,
3033  const unsigned char *dhm_G, size_t G_len);
3034 
3045 #endif /* MBEDTLS_DHM_C && defined(MBEDTLS_SSL_SRV_C) */
3046 
3047 #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C)
3048 
3057  unsigned int bitlen);
3058 #endif /* MBEDTLS_DHM_C && MBEDTLS_SSL_CLI_C */
3059 
3060 #if defined(MBEDTLS_ECP_C)
3061 
3091  const mbedtls_ecp_group_id *curves);
3092 #endif /* MBEDTLS_ECP_C */
3093 
3094 #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED)
3095 
3116  const int *hashes);
3117 #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */
3118 
3119 #if defined(MBEDTLS_X509_CRT_PARSE_C)
3120 
3138 int mbedtls_ssl_set_hostname(mbedtls_ssl_context *ssl, const char *hostname);
3139 #endif /* MBEDTLS_X509_CRT_PARSE_C */
3140 
3141 #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
3142 
3155  mbedtls_x509_crt *own_cert,
3156  mbedtls_pk_context *pk_key);
3157 
3170  mbedtls_x509_crt *ca_chain,
3171  mbedtls_x509_crl *ca_crl);
3172 
3184  int authmode);
3185 
3210  int (*f_sni)(void *, mbedtls_ssl_context *, const unsigned char *,
3211  size_t),
3212  void *p_sni);
3213 #endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */
3214 
3215 #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
3216 
3233 int mbedtls_ssl_set_hs_ecjpake_password(mbedtls_ssl_context *ssl,
3234  const unsigned char *pw,
3235  size_t pw_len);
3236 #endif /*MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */
3237 
3238 #if defined(MBEDTLS_SSL_ALPN)
3239 
3251 int mbedtls_ssl_conf_alpn_protocols(mbedtls_ssl_config *conf, const char **protos);
3252 
3262 const char *mbedtls_ssl_get_alpn_protocol(const mbedtls_ssl_context *ssl);
3263 #endif /* MBEDTLS_SSL_ALPN */
3264 
3265 #if defined(MBEDTLS_SSL_DTLS_SRTP)
3266 #if defined(MBEDTLS_DEBUG_C)
3267 static inline const char *mbedtls_ssl_get_srtp_profile_as_string(mbedtls_ssl_srtp_profile profile)
3268 {
3269  switch (profile) {
3270  case MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_80:
3271  return "MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_80";
3272  case MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32:
3273  return "MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32";
3274  case MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_80:
3275  return "MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_80";
3276  case MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_32:
3277  return "MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_32";
3278  default: break;
3279  }
3280  return "";
3281 }
3282 #endif /* MBEDTLS_DEBUG_C */
3283 
3296 void mbedtls_ssl_conf_srtp_mki_value_supported(mbedtls_ssl_config *conf,
3297  int support_mki_value);
3298 
3318 int mbedtls_ssl_conf_dtls_srtp_protection_profiles
3319  (mbedtls_ssl_config *conf,
3320  const mbedtls_ssl_srtp_profile *profiles);
3321 
3338 int mbedtls_ssl_dtls_srtp_set_mki_value(mbedtls_ssl_context *ssl,
3339  unsigned char *mki_value,
3340  uint16_t mki_len);
3359 void mbedtls_ssl_get_dtls_srtp_negotiation_result(const mbedtls_ssl_context *ssl,
3360  mbedtls_dtls_srtp_info *dtls_srtp_info);
3361 #endif /* MBEDTLS_SSL_DTLS_SRTP */
3362 
3379 void mbedtls_ssl_conf_max_version(mbedtls_ssl_config *conf, int major, int minor);
3380 
3399 void mbedtls_ssl_conf_min_version(mbedtls_ssl_config *conf, int major, int minor);
3400 
3401 #if defined(MBEDTLS_SSL_FALLBACK_SCSV) && defined(MBEDTLS_SSL_CLI_C)
3402 
3421 void mbedtls_ssl_conf_fallback(mbedtls_ssl_config *conf, char fallback);
3422 #endif /* MBEDTLS_SSL_FALLBACK_SCSV && MBEDTLS_SSL_CLI_C */
3423 
3424 #if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
3425 
3437 #endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */
3438 
3439 #if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET)
3440 
3452 #endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */
3453 
3454 #if defined(MBEDTLS_ARC4_C)
3455 
3470 void mbedtls_ssl_conf_arc4_support(mbedtls_ssl_config *conf, char arc4);
3471 #endif /* MBEDTLS_ARC4_C */
3472 
3473 #if defined(MBEDTLS_SSL_SRV_C)
3474 
3484  char cert_req_ca_list);
3485 #endif /* MBEDTLS_SSL_SRV_C */
3486 
3487 #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
3488 
3522 int mbedtls_ssl_conf_max_frag_len(mbedtls_ssl_config *conf, unsigned char mfl_code);
3523 #endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
3524 
3525 #if defined(MBEDTLS_SSL_TRUNCATED_HMAC)
3526 
3534 void mbedtls_ssl_conf_truncated_hmac(mbedtls_ssl_config *conf, int truncate);
3535 #endif /* MBEDTLS_SSL_TRUNCATED_HMAC */
3536 
3537 #if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING)
3538 
3550 #endif /* MBEDTLS_SSL_CBC_RECORD_SPLITTING */
3551 
3552 #if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_CLI_C)
3553 
3563 void mbedtls_ssl_conf_session_tickets(mbedtls_ssl_config *conf, int use_tickets);
3564 #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_CLI_C */
3565 
3566 #if defined(MBEDTLS_SSL_RENEGOTIATION)
3567 
3584 void mbedtls_ssl_conf_renegotiation(mbedtls_ssl_config *conf, int renegotiation);
3585 #endif /* MBEDTLS_SSL_RENEGOTIATION */
3586 
3614 void mbedtls_ssl_conf_legacy_renegotiation(mbedtls_ssl_config *conf, int allow_legacy);
3615 
3616 #if defined(MBEDTLS_SSL_RENEGOTIATION)
3617 
3654 void mbedtls_ssl_conf_renegotiation_enforced(mbedtls_ssl_config *conf, int max_records);
3655 
3682  const unsigned char period[8]);
3683 #endif /* MBEDTLS_SSL_RENEGOTIATION */
3684 
3724 
3741 
3755 
3763 const char *mbedtls_ssl_get_ciphersuite(const mbedtls_ssl_context *ssl);
3764 
3772 const char *mbedtls_ssl_get_version(const mbedtls_ssl_context *ssl);
3773 
3788 
3789 #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
3790 
3804 
3820 
3821 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
3822 
3823 #if defined(MBEDTLS_DEPRECATED_WARNING)
3824 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
3825 #else
3826 #define MBEDTLS_DEPRECATED
3827 #endif
3828 
3844  const mbedtls_ssl_context *ssl);
3845 #endif /* MBEDTLS_DEPRECATED_REMOVED */
3846 #endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
3847 
3876 
3877 #if defined(MBEDTLS_X509_CRT_PARSE_C)
3878 
3909 #endif /* MBEDTLS_X509_CRT_PARSE_C */
3910 
3911 #if defined(MBEDTLS_SSL_CLI_C)
3912 
3939 #endif /* MBEDTLS_SSL_CLI_C */
3940 
3996 
4018 
4019 #if defined(MBEDTLS_SSL_RENEGOTIATION)
4020 
4044 #endif /* MBEDTLS_SSL_RENEGOTIATION */
4045 
4123 int mbedtls_ssl_read(mbedtls_ssl_context *ssl, unsigned char *buf, size_t len);
4124 
4185 int mbedtls_ssl_write(mbedtls_ssl_context *ssl, const unsigned char *buf, size_t len);
4186 
4204  unsigned char level,
4205  unsigned char message);
4220 
4227 
4228 #if defined(MBEDTLS_SSL_CONTEXT_SERIALIZATION)
4229 
4278  unsigned char *buf,
4279  size_t buf_len,
4280  size_t *olen);
4281 
4348  const unsigned char *buf,
4349  size_t len);
4350 #endif /* MBEDTLS_SSL_CONTEXT_SERIALIZATION */
4351 
4363 
4380  int endpoint, int transport, int preset);
4381 
4388 
4395 
4406 
4423  const unsigned char *secret, size_t slen,
4424  const char *label,
4425  const unsigned char *random, size_t rlen,
4426  unsigned char *dstbuf, size_t dlen);
4427 
4428 #ifdef __cplusplus
4429 }
4430 #endif
4431 
4432 #endif /* ssl.h */
uint64_t in_window_top
Definition: ssl.h:1359
int mbedtls_ssl_tls_prf(const mbedtls_tls_prf_types prf, const unsigned char *secret, size_t slen, const char *label, const unsigned char *random, size_t rlen, unsigned char *dstbuf, size_t dlen)
TLS-PRF function for key derivation.
mbedtls_ssl_send_t * f_send
Definition: ssl.h:1296
void * p_rng
Definition: ssl.h:1127
uint8_t allow_legacy_renegotiation
Definition: ssl.h:1043
const char ** alpn_list
Definition: ssl.h:1258
unsigned char * in_ctr
Definition: ssl.h:1334
mbedtls_x509_crt * peer_cert
Definition: ssl.h:992
unsigned char * out_msg
Definition: ssl.h:1387
unsigned char master[48]
Definition: ssl.h:988
unsigned char * in_len
Definition: ssl.h:1342
unsigned char * in_buf
Definition: ssl.h:1333
Public key container.
Definition: pk.h:197
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:2125
mbedtls_mpi dhm_P
Definition: ssl.h:1219
char peer_verify_data[MBEDTLS_SSL_VERIFY_DATA_MAX_LEN]
Definition: ssl.h:1450
unsigned char max_minor_ver
Definition: ssl.h:1029
uint8_t disable_renegotiation
Definition: ssl.h:1063
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:1031
uint8_t authmode
Definition: ssl.h:1041
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:2276
unsigned char * in_hdr
Definition: ssl.h:1337
size_t psk_identity_len
Definition: ssl.h:1249
unsigned int dhm_min_bitlen
Definition: ssl.h:1112
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:2293
void * p_sni
Definition: ssl.h:1138
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:1004
struct mbedtls_ssl_sig_hash_set_t mbedtls_ssl_sig_hash_set_t
Definition: ssl.h:692
size_t ticket_len
Definition: ssl.h:1005
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:1386
uint8_t transport
Definition: ssl.h:1040
mbedtls_ssl_transform * transform_in
Definition: ssl.h:1317
size_t in_left
Definition: ssl.h:1349
int mbedtls_ssl_send_t(void *ctx, const unsigned char *buf, size_t len)
Callback type: send data on the network.
Definition: ssl.h:591
uint8_t extended_ms
Definition: ssl.h:1054
unsigned int badmac_limit
Definition: ssl.h:1108
void * p_psk
Definition: ssl.h:1150
void mbedtls_ssl_conf_fallback(mbedtls_ssl_config *conf, char fallback)
Set the fallback flag (client-side only). (Default: MBEDTLS_SSL_IS_NOT_FALLBACK). ...
void mbedtls_ssl_set_verify(mbedtls_ssl_context *ssl, int(*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *), void *p_vrfy)
Set a connection-specific verification callback (optional).
int mbedtls_ssl_recv_t(void *ctx, unsigned char *buf, size_t len)
Callback type: receive data from the network.
Definition: ssl.h:615
uint8_t fallback
Definition: ssl.h:1072
const mbedtls_ecp_group_id * curve_list
Definition: ssl.h:1215
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:1155
int(* f_export_keys)(void *, const unsigned char *, const unsigned char *, size_t, size_t, size_t)
Definition: ssl.h:1174
int mbedtls_ssl_export_keys_ext_t(void *p_expkey, const unsigned char *ms, const unsigned char *kb, size_t maclen, size_t keylen, size_t ivlen, const unsigned char client_random[32], const unsigned char server_random[32], mbedtls_tls_prf_types tls_prf_type)
Callback type: Export key block, master secret, handshake randbytes and the tls_prf function used to ...
Definition: ssl.h:2091
int(* f_get_cache)(void *, mbedtls_ssl_session *)
Definition: ssl.h:1130
Platform Security Architecture cryptography module.
uint8_t encrypt_then_mac
Definition: ssl.h:1051
unsigned char _pms_dhm[MBEDTLS_MPI_MAX_SIZE]
Definition: ssl.h:504
void(* f_dbg)(void *, int, const char *, int, const char *)
Definition: ssl.h:1122
void * p_cache
Definition: ssl.h:1133
int(* f_sni)(void *, mbedtls_ssl_context *, const unsigned char *, size_t)
Definition: ssl.h:1137
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 char _pms_rsa[48]
Definition: ssl.h:501
unsigned char _pms_ecdh[MBEDTLS_ECP_MAX_BYTES]
Definition: ssl.h:510
unsigned char renego_period[8]
Definition: ssl.h:1103
uint32_t ticket_lifetime
Definition: ssl.h:1006
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:1306
uint8_t disable_datagram_packing
Definition: ssl.h:1371
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:1287
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:1328
int(* mbedtls_x509_crt_ca_cb_t)(void *p_ctx, mbedtls_x509_crt const *child, mbedtls_x509_crt **candidate_cas)
The type of trusted certificate callbacks.
Definition: x509_crt.h:744
Configuration options (set of defines)
uint32_t psa_key_id_t
Definition: crypto_types.h:278
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:1193
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:1307
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_session_save(const mbedtls_ssl_session *session, unsigned char *buf, size_t buf_len, size_t *olen)
Save session structure as serialized data in a buffer. On client, this can be used for saving session...
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:641
uint16_t mtu
Definition: ssl.h:1399
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:1165
mbedtls_ssl_transform * transform_out
Definition: ssl.h:1318
unsigned char mfl_code
Definition: ssl.h:978
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)
int(* f_set_cache)(void *, const mbedtls_ssl_session *)
Definition: ssl.h:1132
Multi-precision integer library.
int encrypt_then_mac
Definition: ssl.h:1014
size_t in_hslen
Definition: ssl.h:1363
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)
Configure a pre-shared key (PSK) and identity to be used in PSK-based ciphersuites.
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:43
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:1158
uint64_t in_window
Definition: ssl.h:1360
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:697
void * p_cookie
Definition: ssl.h:1160
void mbedtls_ssl_conf_export_keys_ext_cb(mbedtls_ssl_config *conf, mbedtls_ssl_export_keys_ext_t *f_export_keys_ext, void *p_export_keys)
Configure extended key export callback. (Default: none.)
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.)
int(* f_export_keys_ext)(void *, const unsigned char *, const unsigned char *, size_t, size_t, size_t, const unsigned char[32], const unsigned char[32], mbedtls_tls_prf_types)
Definition: ssl.h:1178
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:1319
uint32_t hs_timeout_min
Definition: ssl.h:1095
mbedtls_ssl_handshake_params * handshake
Definition: ssl.h:1311
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.
MBEDTLS_DEPRECATED size_t mbedtls_ssl_get_max_frag_len(const mbedtls_ssl_context *ssl)
This function is a deprecated approach to getting the max fragment length. Its an alias for mbedtls_s...
size_t mbedtls_ssl_get_input_max_frag_len(const mbedtls_ssl_context *ssl)
Return the maximum fragment length (payload, in bytes) for the input buffer. This is the negotiated m...
size_t out_left
Definition: ssl.h:1391
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:1344
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:1030
struct mbedtls_ssl_transform mbedtls_ssl_transform
Definition: ssl.h:690
mbedtls_ssl_set_timer_t * f_set_timer
Definition: ssl.h:1327
uint8_t anti_replay
Definition: ssl.h:1057
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...
uint8_t endpoint
Definition: ssl.h:1039
const int * ciphersuite_list[4]
Definition: ssl.h:1119
int(* f_rng)(void *, unsigned char *, size_t)
Definition: ssl.h:1126
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:1191
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:1297
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:1309
mbedtls_ssl_states
Definition: ssl.h:540
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:1211
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 Transport Unit (MTU). Special value: 0 means unset (no limit). This represents the ma...
#define MBEDTLS_DEPRECATED
Definition: ssl.h:3826
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.)
uint8_t cert_req_ca_list
Definition: ssl.h:1075
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:986
void * p_bio
Definition: ssl.h:1301
int mbedtls_ssl_context_save(mbedtls_ssl_context *ssl, unsigned char *buf, size_t buf_len, size_t *olen)
Save an active connection as serialized data in a buffer. This allows the freeing or re-using of the ...
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.
uint8_t session_tickets
Definition: ssl.h:1069
unsigned char _pms_ecdhe_psk[4+MBEDTLS_ECP_MAX_BYTES+MBEDTLS_PSK_MAX_LEN]
Definition: ssl.h:524
void * p_vrfy
Definition: ssl.h:1144
const mbedtls_x509_crt_profile * cert_profile
Definition: ssl.h:1190
void * p_timer
Definition: ssl.h:1325
This file contains Diffie-Hellman-Merkle (DHM) key exchange definitions and functions.
X.509 certificate parsing and writing.
int mbedtls_ssl_context_load(mbedtls_ssl_context *ssl, const unsigned char *buf, size_t len)
Load serialized connection data to an SSL context.
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:494
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:1308
unsigned char * in_iv
Definition: ssl.h:1343
char own_verify_data[MBEDTLS_SSL_VERIFY_DATA_MAX_LEN]
Definition: ssl.h:1449
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:1320
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:125
unsigned char * out_ctr
Definition: ssl.h:1379
int secure_renegotiation
Definition: ssl.h:1445
int mbedtls_ssl_get_timer_t(void *ctx)
Callback type: get status of timers/delays.
Definition: ssl.h:682
The DHM context structure.
Definition: dhm.h:111
const mbedtls_ssl_config * conf
Definition: ssl.h:1270
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:1149
unsigned char * in_offt
Definition: ssl.h:1345
unsigned char max_major_ver
Definition: ssl.h:1028
unsigned char * psk
Definition: ssl.h:1234
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:1423
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:1220
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:88
void * p_export_keys
Definition: ssl.h:1182
char * hostname
Definition: ssl.h:1418
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.
uint8_t arc4_disabled
Definition: ssl.h:1045
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:1390
uint32_t read_timeout
Definition: ssl.h:1092
void mbedtls_ssl_conf_legacy_renegotiation(mbedtls_ssl_config *conf, int allow_legacy)
Prevent or allow legacy renegotiation. (Default: MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION) ...
size_t mbedtls_ssl_get_output_max_frag_len(const mbedtls_ssl_context *ssl)
Return the maximum fragment length (payload, in bytes) for the output buffer. For the client...
unsigned char _pms_rsa_psk[52+MBEDTLS_PSK_MAX_LEN]
Definition: ssl.h:520
uint8_t trunc_hmac
Definition: ssl.h:1066
int mbedtls_ssl_renegotiate(mbedtls_ssl_context *ssl)
Initiate an SSL renegotiation on the running connection. Client: perform the renegotiation right now...
int(* f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *)
Definition: ssl.h:1292
int(* f_ticket_parse)(void *, mbedtls_ssl_session *, unsigned char *, size_t)
Definition: ssl.h:1168
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:2059
unsigned char * out_len
Definition: ssl.h:1385
void * p_vrfy
Definition: ssl.h:1293
int(* f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *)
Definition: ssl.h:1143
uint32_t hs_timeout_max
Definition: ssl.h:1097
MPI structure.
Definition: bignum.h:208
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:1437
int renego_max_records
Definition: ssl.h:1102
mbedtls_ssl_recv_timeout_t * f_recv_timeout
Definition: ssl.h:1298
mbedtls_x509_crt * ca_chain
Definition: ssl.h:1192
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:1448
void mbedtls_ssl_config_free(mbedtls_ssl_config *conf)
Free an SSL configuration context.
unsigned char * psk_identity
Definition: ssl.h:1244
#define MBEDTLS_SSL_CID_OUT_LEN_MAX
Definition: ssl.h:345
int mbedtls_ssl_read(mbedtls_ssl_context *ssl, unsigned char *buf, size_t len)
Read at most 'len' application data bytes.
unsigned char dummy
Definition: ssl.h:499
struct mbedtls_ssl_key_cert mbedtls_ssl_key_cert
Definition: ssl.h:694
uint8_t cbc_record_splitting
Definition: ssl.h:1060
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:667
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:517
size_t next_record_offset
Definition: ssl.h:1355
unsigned char * out_buf
Definition: ssl.h:1378
#define MBEDTLS_SSL_CID_IN_LEN_MAX
Definition: ssl.h:341
size_t psk_len
Definition: ssl.h:1238
void mbedtls_ssl_session_init(mbedtls_ssl_session *session)
Initialize SSL session structure.
void * p_dbg
Definition: ssl.h:1123
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:2031
size_t cli_id_len
Definition: ssl.h:1438
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 reasonable 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:1278
uint8_t mfl_code
Definition: ssl.h:1048
unsigned char * out_hdr
Definition: ssl.h:1380
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:513
uint32_t verify_result
Definition: ssl.h:1001
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.
mbedtls_md_type_t
Supported message digests.
Definition: md.h:62
int keep_current_message
Definition: ssl.h:1367
signed char split_done
Definition: ssl.h:1406
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:1396
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:691
#define MBEDTLS_ECP_MAX_BYTES
Definition: ecp.h:336
int mbedtls_ssl_session_load(mbedtls_ssl_session *session, const unsigned char *buf, size_t len)
Load serialized session data into a session structure. On client, this can be used for loading saved ...
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:1169
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...
#define MBEDTLS_SSL_VERIFY_DATA_MAX_LEN
Definition: ssl.h:364
const mbedtls_ssl_session * mbedtls_ssl_get_session_pointer(const mbedtls_ssl_context *ssl)
Get a pointer to the current session structure, for example to serialize it.
mbedtls_time_t start
Definition: ssl.h:982
size_t in_msglen
Definition: ssl.h:1348
uint16_t in_epoch
Definition: ssl.h:1354
mbedtls_tls_prf_types
Definition: ssl.h:566
int mbedtls_ssl_check_record(mbedtls_ssl_context const *ssl, unsigned char *buf, size_t buflen)
Check whether a buffer contains a valid and authentic record that has not been seen before...