mbed TLS v2.28.3
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 /*
198  * Various constants
199  */
200 #define MBEDTLS_SSL_MAJOR_VERSION_3 3
201 #define MBEDTLS_SSL_MINOR_VERSION_0 0
202 #define MBEDTLS_SSL_MINOR_VERSION_1 1
203 #define MBEDTLS_SSL_MINOR_VERSION_2 2
204 #define MBEDTLS_SSL_MINOR_VERSION_3 3
205 #define MBEDTLS_SSL_MINOR_VERSION_4 4
207 #define MBEDTLS_SSL_TRANSPORT_STREAM 0
208 #define MBEDTLS_SSL_TRANSPORT_DATAGRAM 1
210 #define MBEDTLS_SSL_MAX_HOST_NAME_LEN 255
211 #define MBEDTLS_SSL_MAX_ALPN_NAME_LEN 255
213 #define MBEDTLS_SSL_MAX_ALPN_LIST_LEN 65535
215 /* RFC 6066 section 4, see also mfl_code_to_length in ssl_tls.c
216  * NONE must be zero so that memset()ing structure to zero works */
217 #define MBEDTLS_SSL_MAX_FRAG_LEN_NONE 0
218 #define MBEDTLS_SSL_MAX_FRAG_LEN_512 1
219 #define MBEDTLS_SSL_MAX_FRAG_LEN_1024 2
220 #define MBEDTLS_SSL_MAX_FRAG_LEN_2048 3
221 #define MBEDTLS_SSL_MAX_FRAG_LEN_4096 4
222 #define MBEDTLS_SSL_MAX_FRAG_LEN_INVALID 5
224 #define MBEDTLS_SSL_IS_CLIENT 0
225 #define MBEDTLS_SSL_IS_SERVER 1
226 
227 #define MBEDTLS_SSL_IS_NOT_FALLBACK 0
228 #define MBEDTLS_SSL_IS_FALLBACK 1
229 
230 #define MBEDTLS_SSL_EXTENDED_MS_DISABLED 0
231 #define MBEDTLS_SSL_EXTENDED_MS_ENABLED 1
232 
233 #define MBEDTLS_SSL_CID_DISABLED 0
234 #define MBEDTLS_SSL_CID_ENABLED 1
235 
236 #define MBEDTLS_SSL_ETM_DISABLED 0
237 #define MBEDTLS_SSL_ETM_ENABLED 1
238 
239 #define MBEDTLS_SSL_COMPRESS_NULL 0
240 #define MBEDTLS_SSL_COMPRESS_DEFLATE 1
241 
242 #define MBEDTLS_SSL_VERIFY_NONE 0
243 #define MBEDTLS_SSL_VERIFY_OPTIONAL 1
244 #define MBEDTLS_SSL_VERIFY_REQUIRED 2
245 #define MBEDTLS_SSL_VERIFY_UNSET 3 /* Used only for sni_authmode */
246 
247 #define MBEDTLS_SSL_LEGACY_RENEGOTIATION 0
248 #define MBEDTLS_SSL_SECURE_RENEGOTIATION 1
249 
250 #define MBEDTLS_SSL_RENEGOTIATION_DISABLED 0
251 #define MBEDTLS_SSL_RENEGOTIATION_ENABLED 1
252 
253 #define MBEDTLS_SSL_ANTI_REPLAY_DISABLED 0
254 #define MBEDTLS_SSL_ANTI_REPLAY_ENABLED 1
255 
256 #define MBEDTLS_SSL_RENEGOTIATION_NOT_ENFORCED -1
257 #define MBEDTLS_SSL_RENEGO_MAX_RECORDS_DEFAULT 16
258 
259 #define MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION 0
260 #define MBEDTLS_SSL_LEGACY_ALLOW_RENEGOTIATION 1
261 #define MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE 2
262 
263 #define MBEDTLS_SSL_TRUNC_HMAC_DISABLED 0
264 #define MBEDTLS_SSL_TRUNC_HMAC_ENABLED 1
265 #define MBEDTLS_SSL_TRUNCATED_HMAC_LEN 10 /* 80 bits, rfc 6066 section 7 */
266 
267 #define MBEDTLS_SSL_SESSION_TICKETS_DISABLED 0
268 #define MBEDTLS_SSL_SESSION_TICKETS_ENABLED 1
269 
270 #define MBEDTLS_SSL_CBC_RECORD_SPLITTING_DISABLED 0
271 #define MBEDTLS_SSL_CBC_RECORD_SPLITTING_ENABLED 1
272 
273 #define MBEDTLS_SSL_ARC4_ENABLED 0
274 #define MBEDTLS_SSL_ARC4_DISABLED 1
275 
276 #define MBEDTLS_SSL_PRESET_DEFAULT 0
277 #define MBEDTLS_SSL_PRESET_SUITEB 2
278 
279 #define MBEDTLS_SSL_CERT_REQ_CA_LIST_ENABLED 1
280 #define MBEDTLS_SSL_CERT_REQ_CA_LIST_DISABLED 0
281 
282 #define MBEDTLS_SSL_DTLS_SRTP_MKI_UNSUPPORTED 0
283 #define MBEDTLS_SSL_DTLS_SRTP_MKI_SUPPORTED 1
284 
285 /*
286  * Default range for DTLS retransmission timer value, in milliseconds.
287  * RFC 6347 4.2.4.1 says from 1 second to 60 seconds.
288  */
289 #define MBEDTLS_SSL_DTLS_TIMEOUT_DFL_MIN 1000
290 #define MBEDTLS_SSL_DTLS_TIMEOUT_DFL_MAX 60000
291 
300 #if !defined(MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME)
301 #define MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME 86400
302 #endif
303 
304 /*
305  * Maximum fragment length in bytes,
306  * determines the size of each of the two internal I/O buffers.
307  *
308  * Note: the RFC defines the default size of SSL / TLS messages. If you
309  * change the value here, other clients / servers may not be able to
310  * communicate with you anymore. Only change this value if you control
311  * both sides of the connection and have it reduced at both sides, or
312  * if you're using the Max Fragment Length extension and you know all your
313  * peers are using it too!
314  */
315 #if !defined(MBEDTLS_SSL_MAX_CONTENT_LEN)
316 #define MBEDTLS_SSL_MAX_CONTENT_LEN 16384
317 #endif
318 
319 #if !defined(MBEDTLS_SSL_IN_CONTENT_LEN)
320 #define MBEDTLS_SSL_IN_CONTENT_LEN MBEDTLS_SSL_MAX_CONTENT_LEN
321 #endif
322 
323 #if !defined(MBEDTLS_SSL_OUT_CONTENT_LEN)
324 #define MBEDTLS_SSL_OUT_CONTENT_LEN MBEDTLS_SSL_MAX_CONTENT_LEN
325 #endif
326 
327 /*
328  * Maximum number of heap-allocated bytes for the purpose of
329  * DTLS handshake message reassembly and future message buffering.
330  */
331 #if !defined(MBEDTLS_SSL_DTLS_MAX_BUFFERING)
332 #define MBEDTLS_SSL_DTLS_MAX_BUFFERING 32768
333 #endif
334 
335 /*
336  * Maximum length of CIDs for incoming and outgoing messages.
337  */
338 #if !defined(MBEDTLS_SSL_CID_IN_LEN_MAX)
339 #define MBEDTLS_SSL_CID_IN_LEN_MAX 32
340 #endif
341 
342 #if !defined(MBEDTLS_SSL_CID_OUT_LEN_MAX)
343 #define MBEDTLS_SSL_CID_OUT_LEN_MAX 32
344 #endif
345 
346 #if !defined(MBEDTLS_SSL_CID_PADDING_GRANULARITY)
347 #define MBEDTLS_SSL_CID_PADDING_GRANULARITY 16
348 #endif
349 
350 #if !defined(MBEDTLS_SSL_TLS1_3_PADDING_GRANULARITY)
351 #define MBEDTLS_SSL_TLS1_3_PADDING_GRANULARITY 1
352 #endif
353 
356 /*
357  * Length of the verify data for secure renegotiation
358  */
359 #if defined(MBEDTLS_SSL_PROTO_SSL3)
360 #define MBEDTLS_SSL_VERIFY_DATA_MAX_LEN 36
361 #else
362 #define MBEDTLS_SSL_VERIFY_DATA_MAX_LEN 12
363 #endif
364 
365 /*
366  * Signaling ciphersuite values (SCSV)
367  */
368 #define MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO 0xFF
369 #define MBEDTLS_SSL_FALLBACK_SCSV_VALUE 0x5600
371 /*
372  * Supported Signature and Hash algorithms (For TLS 1.2)
373  * RFC 5246 section 7.4.1.4.1
374  */
375 #define MBEDTLS_SSL_HASH_NONE 0
376 #define MBEDTLS_SSL_HASH_MD5 1
377 #define MBEDTLS_SSL_HASH_SHA1 2
378 #define MBEDTLS_SSL_HASH_SHA224 3
379 #define MBEDTLS_SSL_HASH_SHA256 4
380 #define MBEDTLS_SSL_HASH_SHA384 5
381 #define MBEDTLS_SSL_HASH_SHA512 6
382 
383 #define MBEDTLS_SSL_SIG_ANON 0
384 #define MBEDTLS_SSL_SIG_RSA 1
385 #define MBEDTLS_SSL_SIG_ECDSA 3
386 
387 /*
388  * Client Certificate Types
389  * RFC 5246 section 7.4.4 plus RFC 4492 section 5.5
390  */
391 #define MBEDTLS_SSL_CERT_TYPE_RSA_SIGN 1
392 #define MBEDTLS_SSL_CERT_TYPE_ECDSA_SIGN 64
393 
394 /*
395  * Message, alert and handshake types
396  */
397 #define MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC 20
398 #define MBEDTLS_SSL_MSG_ALERT 21
399 #define MBEDTLS_SSL_MSG_HANDSHAKE 22
400 #define MBEDTLS_SSL_MSG_APPLICATION_DATA 23
401 #define MBEDTLS_SSL_MSG_CID 25
402 
403 #define MBEDTLS_SSL_ALERT_LEVEL_WARNING 1
404 #define MBEDTLS_SSL_ALERT_LEVEL_FATAL 2
405 
406 #define MBEDTLS_SSL_ALERT_MSG_CLOSE_NOTIFY 0 /* 0x00 */
407 #define MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE 10 /* 0x0A */
408 #define MBEDTLS_SSL_ALERT_MSG_BAD_RECORD_MAC 20 /* 0x14 */
409 #define MBEDTLS_SSL_ALERT_MSG_DECRYPTION_FAILED 21 /* 0x15 */
410 #define MBEDTLS_SSL_ALERT_MSG_RECORD_OVERFLOW 22 /* 0x16 */
411 #define MBEDTLS_SSL_ALERT_MSG_DECOMPRESSION_FAILURE 30 /* 0x1E */
412 #define MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE 40 /* 0x28 */
413 #define MBEDTLS_SSL_ALERT_MSG_NO_CERT 41 /* 0x29 */
414 #define MBEDTLS_SSL_ALERT_MSG_BAD_CERT 42 /* 0x2A */
415 #define MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT 43 /* 0x2B */
416 #define MBEDTLS_SSL_ALERT_MSG_CERT_REVOKED 44 /* 0x2C */
417 #define MBEDTLS_SSL_ALERT_MSG_CERT_EXPIRED 45 /* 0x2D */
418 #define MBEDTLS_SSL_ALERT_MSG_CERT_UNKNOWN 46 /* 0x2E */
419 #define MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER 47 /* 0x2F */
420 #define MBEDTLS_SSL_ALERT_MSG_UNKNOWN_CA 48 /* 0x30 */
421 #define MBEDTLS_SSL_ALERT_MSG_ACCESS_DENIED 49 /* 0x31 */
422 #define MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR 50 /* 0x32 */
423 #define MBEDTLS_SSL_ALERT_MSG_DECRYPT_ERROR 51 /* 0x33 */
424 #define MBEDTLS_SSL_ALERT_MSG_EXPORT_RESTRICTION 60 /* 0x3C */
425 #define MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION 70 /* 0x46 */
426 #define MBEDTLS_SSL_ALERT_MSG_INSUFFICIENT_SECURITY 71 /* 0x47 */
427 #define MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR 80 /* 0x50 */
428 #define MBEDTLS_SSL_ALERT_MSG_INAPROPRIATE_FALLBACK 86 /* 0x56 */
429 #define MBEDTLS_SSL_ALERT_MSG_USER_CANCELED 90 /* 0x5A */
430 #define MBEDTLS_SSL_ALERT_MSG_NO_RENEGOTIATION 100 /* 0x64 */
431 #define MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_EXT 110 /* 0x6E */
432 #define MBEDTLS_SSL_ALERT_MSG_UNRECOGNIZED_NAME 112 /* 0x70 */
433 #define MBEDTLS_SSL_ALERT_MSG_UNKNOWN_PSK_IDENTITY 115 /* 0x73 */
434 #define MBEDTLS_SSL_ALERT_MSG_NO_APPLICATION_PROTOCOL 120 /* 0x78 */
435 
436 #define MBEDTLS_SSL_HS_HELLO_REQUEST 0
437 #define MBEDTLS_SSL_HS_CLIENT_HELLO 1
438 #define MBEDTLS_SSL_HS_SERVER_HELLO 2
439 #define MBEDTLS_SSL_HS_HELLO_VERIFY_REQUEST 3
440 #define MBEDTLS_SSL_HS_NEW_SESSION_TICKET 4
441 #define MBEDTLS_SSL_HS_CERTIFICATE 11
442 #define MBEDTLS_SSL_HS_SERVER_KEY_EXCHANGE 12
443 #define MBEDTLS_SSL_HS_CERTIFICATE_REQUEST 13
444 #define MBEDTLS_SSL_HS_SERVER_HELLO_DONE 14
445 #define MBEDTLS_SSL_HS_CERTIFICATE_VERIFY 15
446 #define MBEDTLS_SSL_HS_CLIENT_KEY_EXCHANGE 16
447 #define MBEDTLS_SSL_HS_FINISHED 20
448 
449 /*
450  * TLS extensions
451  */
452 #define MBEDTLS_TLS_EXT_SERVERNAME 0
453 #define MBEDTLS_TLS_EXT_SERVERNAME_HOSTNAME 0
454 
455 #define MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH 1
456 
457 #define MBEDTLS_TLS_EXT_TRUNCATED_HMAC 4
458 
459 #define MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES 10
460 #define MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS 11
461 
462 #define MBEDTLS_TLS_EXT_SIG_ALG 13
463 
464 #define MBEDTLS_TLS_EXT_USE_SRTP 14
465 
466 #define MBEDTLS_TLS_EXT_ALPN 16
467 
468 #define MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC 22 /* 0x16 */
469 #define MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET 0x0017 /* 23 */
470 
471 #define MBEDTLS_TLS_EXT_SESSION_TICKET 35
472 
473 /* The value of the CID extension is still TBD as of
474  * draft-ietf-tls-dtls-connection-id-05
475  * (https://tools.ietf.org/html/draft-ietf-tls-dtls-connection-id-05).
476  *
477  * A future minor revision of Mbed TLS may change the default value of
478  * this option to match evolving standards and usage.
479  */
480 #if !defined(MBEDTLS_TLS_EXT_CID)
481 #define MBEDTLS_TLS_EXT_CID 254 /* TBD */
482 #endif
483 
484 #define MBEDTLS_TLS_EXT_ECJPAKE_KKPP 256 /* experimental */
485 
486 #define MBEDTLS_TLS_EXT_RENEGOTIATION_INFO 0xFF01
487 
488 /*
489  * Size defines
490  */
491 #if !defined(MBEDTLS_PSK_MAX_LEN)
492 #define MBEDTLS_PSK_MAX_LEN 32 /* 256 bits */
493 #endif
494 
495 /* Dummy type used only for its size */
497 #if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED)
498  unsigned char _pms_rsa[48]; /* RFC 5246 8.1.1 */
499 #endif
500 #if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED)
501  unsigned char _pms_dhm[MBEDTLS_MPI_MAX_SIZE]; /* RFC 5246 8.1.2 */
502 #endif
503 #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
504  defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \
505  defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \
506  defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)
507  unsigned char _pms_ecdh[MBEDTLS_ECP_MAX_BYTES]; /* RFC 4492 5.10 */
508 #endif
509 #if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED)
510  unsigned char _pms_psk[4 + 2 * MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 2 */
511 #endif
512 #if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED)
513  unsigned char _pms_dhe_psk[4 + MBEDTLS_MPI_MAX_SIZE
514  + MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 3 */
515 #endif
516 #if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED)
517  unsigned char _pms_rsa_psk[52 + MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 4 */
518 #endif
519 #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED)
520  unsigned char _pms_ecdhe_psk[4 + MBEDTLS_ECP_MAX_BYTES
521  + MBEDTLS_PSK_MAX_LEN]; /* RFC 5489 2 */
522 #endif
523 #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
524  unsigned char _pms_ecjpake[32]; /* Thread spec: SHA-256 output */
525 #endif
526 };
527 
528 #define MBEDTLS_PREMASTER_SIZE sizeof(union mbedtls_ssl_premaster_secret)
529 
530 #ifdef __cplusplus
531 extern "C" {
532 #endif
533 
534 /*
535  * SSL state machine
536  */
537 typedef enum {
557 }
559 
560 /*
561  * The tls_prf function types.
562  */
563 typedef enum {
569 }
588 typedef int mbedtls_ssl_send_t(void *ctx,
589  const unsigned char *buf,
590  size_t len);
591 
612 typedef int mbedtls_ssl_recv_t(void *ctx,
613  unsigned char *buf,
614  size_t len);
615 
638 typedef int mbedtls_ssl_recv_timeout_t(void *ctx,
639  unsigned char *buf,
640  size_t len,
641  uint32_t timeout);
664 typedef void mbedtls_ssl_set_timer_t(void *ctx,
665  uint32_t int_ms,
666  uint32_t fin_ms);
667 
679 typedef int mbedtls_ssl_get_timer_t(void *ctx);
680 
681 /* Defined below */
685 
686 /* Defined in ssl_internal.h */
690 #if defined(MBEDTLS_X509_CRT_PARSE_C)
692 #endif
693 #if defined(MBEDTLS_SSL_PROTO_DTLS)
695 #endif
696 
697 #if defined(MBEDTLS_SSL_ASYNC_PRIVATE)
698 #if defined(MBEDTLS_X509_CRT_PARSE_C)
699 
770 typedef int mbedtls_ssl_async_sign_t(mbedtls_ssl_context *ssl,
771  mbedtls_x509_crt *cert,
772  mbedtls_md_type_t md_alg,
773  const unsigned char *hash,
774  size_t hash_len);
775 
836 typedef int mbedtls_ssl_async_decrypt_t(mbedtls_ssl_context *ssl,
837  mbedtls_x509_crt *cert,
838  const unsigned char *input,
839  size_t input_len);
840 #endif /* MBEDTLS_X509_CRT_PARSE_C */
841 
884 typedef int mbedtls_ssl_async_resume_t(mbedtls_ssl_context *ssl,
885  unsigned char *output,
886  size_t *output_len,
887  size_t output_size);
888 
906 typedef void mbedtls_ssl_async_cancel_t(mbedtls_ssl_context *ssl);
907 #endif /* MBEDTLS_SSL_ASYNC_PRIVATE */
908 
909 #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) && \
910  !defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE)
911 #define MBEDTLS_SSL_PEER_CERT_DIGEST_MAX_LEN 48
912 #if defined(MBEDTLS_SHA256_C)
913 #define MBEDTLS_SSL_PEER_CERT_DIGEST_DFL_TYPE MBEDTLS_MD_SHA256
914 #define MBEDTLS_SSL_PEER_CERT_DIGEST_DFL_LEN 32
915 #elif defined(MBEDTLS_SHA512_C)
916 #define MBEDTLS_SSL_PEER_CERT_DIGEST_DFL_TYPE MBEDTLS_MD_SHA384
917 #define MBEDTLS_SSL_PEER_CERT_DIGEST_DFL_LEN 48
918 #elif defined(MBEDTLS_SHA1_C)
919 #define MBEDTLS_SSL_PEER_CERT_DIGEST_DFL_TYPE MBEDTLS_MD_SHA1
920 #define MBEDTLS_SSL_PEER_CERT_DIGEST_DFL_LEN 20
921 #else
922 /* This is already checked in check_config.h, but be sure. */
923 #error "Bad configuration - need SHA-1, SHA-256 or SHA-512 enabled to compute digest of peer CRT."
924 #endif
925 #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED &&
926  !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE */
927 
928 #if defined(MBEDTLS_SSL_DTLS_SRTP)
929 
930 #define MBEDTLS_TLS_SRTP_MAX_MKI_LENGTH 255
931 #define MBEDTLS_TLS_SRTP_MAX_PROFILE_LIST_LENGTH 4
932 /*
933  * For code readability use a typedef for DTLS-SRTP profiles
934  *
935  * Use_srtp extension protection profiles values as defined in
936  * http://www.iana.org/assignments/srtp-protection/srtp-protection.xhtml
937  *
938  * Reminder: if this list is expanded mbedtls_ssl_check_srtp_profile_value
939  * must be updated too.
940  */
941 #define MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_80 ((uint16_t) 0x0001)
942 #define MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32 ((uint16_t) 0x0002)
943 #define MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_80 ((uint16_t) 0x0005)
944 #define MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_32 ((uint16_t) 0x0006)
945 /* This one is not iana defined, but for code readability. */
946 #define MBEDTLS_TLS_SRTP_UNSET ((uint16_t) 0x0000)
947 
948 typedef uint16_t mbedtls_ssl_srtp_profile;
949 
950 typedef struct mbedtls_dtls_srtp_info_t {
952  mbedtls_ssl_srtp_profile chosen_dtls_srtp_profile;
954  uint16_t mki_len;
956  unsigned char mki_value[MBEDTLS_TLS_SRTP_MAX_MKI_LENGTH];
957 }
958 mbedtls_dtls_srtp_info;
959 
960 #endif /* MBEDTLS_SSL_DTLS_SRTP */
961 
962 /*
963  * This structure is used for storing current session data.
964  *
965  * Note: when changing this definition, we need to check and update:
966  * - in tests/suites/test_suite_ssl.function:
967  * ssl_populate_session() and ssl_serialize_session_save_load()
968  * - in library/ssl_tls.c:
969  * mbedtls_ssl_session_init() and mbedtls_ssl_session_free()
970  * mbedtls_ssl_session_save() and ssl_session_load()
971  * ssl_session_copy()
972  */
974 #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
975  unsigned char mfl_code;
976 #endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
977 
978 #if defined(MBEDTLS_HAVE_TIME)
980 #endif
983  size_t id_len;
984  unsigned char id[32];
985  unsigned char master[48];
987 #if defined(MBEDTLS_X509_CRT_PARSE_C)
988 #if defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE)
990 #else /* MBEDTLS_SSL_KEEP_PEER_CERTIFICATE */
991 
993  unsigned char *peer_cert_digest;
994  size_t peer_cert_digest_len;
995  mbedtls_md_type_t peer_cert_digest_type;
996 #endif /* !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE */
997 #endif /* MBEDTLS_X509_CRT_PARSE_C */
998  uint32_t verify_result;
1000 #if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_CLI_C)
1001  unsigned char *ticket;
1002  size_t ticket_len;
1003  uint32_t ticket_lifetime;
1004 #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_CLI_C */
1005 
1006 #if defined(MBEDTLS_SSL_TRUNCATED_HMAC)
1008 #endif /* MBEDTLS_SSL_TRUNCATED_HMAC */
1009 
1010 #if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
1012 #endif
1013 };
1014 
1019  /* Group items by size and reorder them to maximize usage of immediate offset access. */
1020 
1021  /*
1022  * Numerical settings (char)
1023  */
1024 
1025  unsigned char max_major_ver;
1026  unsigned char max_minor_ver;
1027  unsigned char min_major_ver;
1028  unsigned char min_minor_ver;
1030  /*
1031  * Flags (could be bit-fields to save RAM, but separate bytes make
1032  * the code smaller on architectures with an instruction for direct
1033  * byte access).
1034  */
1035 
1036  uint8_t endpoint /*bool*/;
1037  uint8_t transport /*bool*/;
1038  uint8_t authmode /*2 bits*/;
1039  /* needed even with renego disabled for LEGACY_BREAK_HANDSHAKE */
1040  uint8_t allow_legacy_renegotiation /*2 bits*/;
1041 #if defined(MBEDTLS_ARC4_C)
1042  uint8_t arc4_disabled /*bool*/;
1043 #endif
1044 #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
1045  uint8_t mfl_code /*3 bits*/;
1046 #endif
1047 #if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
1048  uint8_t encrypt_then_mac /*bool*/;
1049 #endif
1050 #if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET)
1051  uint8_t extended_ms /*bool*/;
1052 #endif
1053 #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)
1054  uint8_t anti_replay /*bool*/;
1055 #endif
1056 #if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING)
1057  uint8_t cbc_record_splitting /*bool*/;
1058 #endif
1059 #if defined(MBEDTLS_SSL_RENEGOTIATION)
1060  uint8_t disable_renegotiation /*bool*/;
1061 #endif
1062 #if defined(MBEDTLS_SSL_TRUNCATED_HMAC)
1063  uint8_t trunc_hmac /*bool*/;
1064 #endif
1065 #if defined(MBEDTLS_SSL_SESSION_TICKETS)
1066  uint8_t session_tickets /*bool*/;
1067 #endif
1068 #if defined(MBEDTLS_SSL_FALLBACK_SCSV) && defined(MBEDTLS_SSL_CLI_C)
1069  uint8_t fallback /*bool*/;
1070 #endif
1071 #if defined(MBEDTLS_SSL_SRV_C)
1072  uint8_t cert_req_ca_list /*bool*/;
1074 #endif
1075 #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
1076  uint8_t ignore_unexpected_cid /*bool*/;
1079 #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
1080 #if defined(MBEDTLS_SSL_DTLS_SRTP)
1081  uint8_t dtls_srtp_mki_support /*bool*/;
1083 #endif
1084 
1085  /*
1086  * Numerical settings (int or larger)
1087  */
1088 
1089  uint32_t read_timeout;
1091 #if defined(MBEDTLS_SSL_PROTO_DTLS)
1092  uint32_t hs_timeout_min;
1094  uint32_t hs_timeout_max;
1096 #endif
1097 
1098 #if defined(MBEDTLS_SSL_RENEGOTIATION)
1100  unsigned char renego_period[8];
1102 #endif
1103 
1104 #if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT)
1105  unsigned int badmac_limit;
1106 #endif
1107 
1108 #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C)
1109  unsigned int dhm_min_bitlen;
1110 #endif
1111 
1112  /*
1113  * Pointers
1114  */
1115 
1116  const int *ciphersuite_list[4];
1119  void (*f_dbg)(void *, int, const char *, int, const char *);
1120  void *p_dbg;
1123  int (*f_rng)(void *, unsigned char *, size_t);
1124  void *p_rng;
1129  int (*f_set_cache)(void *, const mbedtls_ssl_session *);
1130  void *p_cache;
1132 #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
1133 
1134  int (*f_sni)(void *, mbedtls_ssl_context *, const unsigned char *, size_t);
1135  void *p_sni;
1136 #endif
1137 
1138 #if defined(MBEDTLS_X509_CRT_PARSE_C)
1139 
1140  int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *);
1141  void *p_vrfy;
1142 #endif
1143 
1144 #if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
1145 
1146  int (*f_psk)(void *, mbedtls_ssl_context *, const unsigned char *, size_t);
1147  void *p_psk;
1148 #endif
1149 
1150 #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C)
1151 
1152  int (*f_cookie_write)(void *, unsigned char **, unsigned char *,
1153  const unsigned char *, size_t);
1155  int (*f_cookie_check)(void *, const unsigned char *, size_t,
1156  const unsigned char *, size_t);
1157  void *p_cookie;
1158 #endif
1159 
1160 #if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_SRV_C)
1161 
1162  int (*f_ticket_write)(void *, const mbedtls_ssl_session *,
1163  unsigned char *, const unsigned char *, size_t *, uint32_t *);
1165  int (*f_ticket_parse)(void *, mbedtls_ssl_session *, unsigned char *, size_t);
1166  void *p_ticket;
1167 #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_SRV_C */
1168 
1169 #if defined(MBEDTLS_SSL_EXPORT_KEYS)
1170 
1171  int (*f_export_keys)(void *, const unsigned char *,
1172  const unsigned char *, size_t, size_t, size_t);
1175  int (*f_export_keys_ext)(void *, const unsigned char *,
1176  const unsigned char *, size_t, size_t, size_t,
1177  const unsigned char[32], const unsigned char[32],
1180 #endif
1181 
1182 #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
1183  size_t cid_len;
1184 #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
1185 
1186 #if defined(MBEDTLS_X509_CRT_PARSE_C)
1191 #if defined(MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK)
1192  mbedtls_x509_crt_ca_cb_t f_ca_cb;
1193  void *p_ca_cb;
1194 #endif /* MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK */
1195 #endif /* MBEDTLS_X509_CRT_PARSE_C */
1196 
1197 #if defined(MBEDTLS_SSL_ASYNC_PRIVATE)
1198 #if defined(MBEDTLS_X509_CRT_PARSE_C)
1199  mbedtls_ssl_async_sign_t *f_async_sign_start;
1200  mbedtls_ssl_async_decrypt_t *f_async_decrypt_start;
1201 #endif /* MBEDTLS_X509_CRT_PARSE_C */
1202  mbedtls_ssl_async_resume_t *f_async_resume;
1203  mbedtls_ssl_async_cancel_t *f_async_cancel;
1204  void *p_async_config_data;
1205 #endif /* MBEDTLS_SSL_ASYNC_PRIVATE */
1206 
1207 #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED)
1208  const int *sig_hashes;
1209 #endif
1210 
1211 #if defined(MBEDTLS_ECP_C)
1213 #endif
1214 
1215 #if defined(MBEDTLS_DHM_C)
1218 #endif
1219 
1220 #if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
1221 
1222 #if defined(MBEDTLS_USE_PSA_CRYPTO)
1223  psa_key_id_t psk_opaque;
1229 #endif /* MBEDTLS_USE_PSA_CRYPTO */
1230 
1231  unsigned char *psk;
1235  size_t psk_len;
1241  unsigned char *psk_identity;
1252 #endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED */
1253 
1254 #if defined(MBEDTLS_SSL_ALPN)
1255  const char **alpn_list;
1256 #endif
1257 
1258 #if defined(MBEDTLS_SSL_DTLS_SRTP)
1259 
1260  const mbedtls_ssl_srtp_profile *dtls_srtp_profile_list;
1262  size_t dtls_srtp_profile_list_len;
1263 #endif /* MBEDTLS_SSL_DTLS_SRTP */
1264 };
1265 
1269  /*
1270  * Miscellaneous
1271  */
1272  int state;
1273 #if defined(MBEDTLS_SSL_RENEGOTIATION)
1278 #endif /* MBEDTLS_SSL_RENEGOTIATION */
1279 
1283 #if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT)
1284  unsigned badmac_seen;
1285 #endif /* MBEDTLS_SSL_DTLS_BADMAC_LIMIT */
1286 
1287 #if defined(MBEDTLS_X509_CRT_PARSE_C)
1288 
1289  int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *);
1290  void *p_vrfy;
1291 #endif
1292 
1298  void *p_bio;
1300  /*
1301  * Session layer
1302  */
1311  /*
1312  * Record layer transformations
1313  */
1319  /*
1320  * Timers
1321  */
1322  void *p_timer;
1327  /*
1328  * Record layer (incoming data)
1329  */
1330  unsigned char *in_buf;
1331  unsigned char *in_ctr;
1334  unsigned char *in_hdr;
1335 #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
1336  unsigned char *in_cid;
1338 #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
1339  unsigned char *in_len;
1340  unsigned char *in_iv;
1341  unsigned char *in_msg;
1342  unsigned char *in_offt;
1345  size_t in_msglen;
1346  size_t in_left;
1347 #if defined(MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH)
1348  size_t in_buf_len;
1349 #endif
1350 #if defined(MBEDTLS_SSL_PROTO_DTLS)
1351  uint16_t in_epoch;
1354 #endif /* MBEDTLS_SSL_PROTO_DTLS */
1355 #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)
1356  uint64_t in_window_top;
1357  uint64_t in_window;
1358 #endif /* MBEDTLS_SSL_DTLS_ANTI_REPLAY */
1359 
1360  size_t in_hslen;
1362  int nb_zero;
1367 #if defined(MBEDTLS_SSL_PROTO_DTLS)
1370 #endif /* MBEDTLS_SSL_PROTO_DTLS */
1371 
1372  /*
1373  * Record layer (outgoing data)
1374  */
1375  unsigned char *out_buf;
1376  unsigned char *out_ctr;
1377  unsigned char *out_hdr;
1378 #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
1379  unsigned char *out_cid;
1381 #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
1382  unsigned char *out_len;
1383  unsigned char *out_iv;
1384  unsigned char *out_msg;
1387  size_t out_msglen;
1388  size_t out_left;
1389 #if defined(MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH)
1390  size_t out_buf_len;
1391 #endif
1392 
1393  unsigned char cur_out_ctr[8];
1395 #if defined(MBEDTLS_SSL_PROTO_DTLS)
1396  uint16_t mtu;
1397 #endif /* MBEDTLS_SSL_PROTO_DTLS */
1398 
1399 #if defined(MBEDTLS_ZLIB_SUPPORT)
1400  unsigned char *compress_buf;
1401 #endif /* MBEDTLS_ZLIB_SUPPORT */
1402 #if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING)
1403  signed char split_done;
1404 #endif /* MBEDTLS_SSL_CBC_RECORD_SPLITTING */
1405 
1406  /*
1407  * PKI layer
1408  */
1411  /*
1412  * User settings
1413  */
1414 #if defined(MBEDTLS_X509_CRT_PARSE_C)
1415  char *hostname;
1417 #endif /* MBEDTLS_X509_CRT_PARSE_C */
1418 
1419 #if defined(MBEDTLS_SSL_ALPN)
1420  const char *alpn_chosen;
1421 #endif /* MBEDTLS_SSL_ALPN */
1422 
1423 #if defined(MBEDTLS_SSL_DTLS_SRTP)
1424  /*
1425  * use_srtp extension
1426  */
1427  mbedtls_dtls_srtp_info dtls_srtp_info;
1428 #endif /* MBEDTLS_SSL_DTLS_SRTP */
1429 
1430  /*
1431  * Information for DTLS hello verify
1432  */
1433 #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C)
1434  unsigned char *cli_id;
1435  size_t cli_id_len;
1436 #endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY && MBEDTLS_SSL_SRV_C */
1437 
1438  /*
1439  * Secure renegotiation
1440  */
1441  /* needed to know when to send extension on server */
1444 #if defined(MBEDTLS_SSL_RENEGOTIATION)
1448 #endif /* MBEDTLS_SSL_RENEGOTIATION */
1449 
1450 #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
1451  /* CID configuration to use in subsequent handshakes. */
1452 
1457  unsigned char own_cid[MBEDTLS_SSL_CID_IN_LEN_MAX];
1458  uint8_t own_cid_len;
1459  uint8_t negotiate_cid;
1463 #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
1464 };
1465 
1466 #if defined(MBEDTLS_SSL_HW_RECORD_ACCEL)
1467 
1468 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
1469 
1470 #define MBEDTLS_SSL_CHANNEL_OUTBOUND MBEDTLS_DEPRECATED_NUMERIC_CONSTANT(0)
1471 #define MBEDTLS_SSL_CHANNEL_INBOUND MBEDTLS_DEPRECATED_NUMERIC_CONSTANT(1)
1472 
1473 #if defined(MBEDTLS_DEPRECATED_WARNING)
1474 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
1475 #else
1476 #define MBEDTLS_DEPRECATED
1477 #endif /* MBEDTLS_DEPRECATED_WARNING */
1478 
1479 MBEDTLS_DEPRECATED extern int (*mbedtls_ssl_hw_record_init)(
1480  mbedtls_ssl_context *ssl,
1481  const unsigned char *key_enc, const unsigned char *key_dec,
1482  size_t keylen,
1483  const unsigned char *iv_enc, const unsigned char *iv_dec,
1484  size_t ivlen,
1485  const unsigned char *mac_enc, const unsigned char *mac_dec,
1486  size_t maclen);
1487 MBEDTLS_DEPRECATED extern int (*mbedtls_ssl_hw_record_activate)(
1488  mbedtls_ssl_context *ssl,
1489  int direction);
1490 MBEDTLS_DEPRECATED extern int (*mbedtls_ssl_hw_record_reset)(
1491  mbedtls_ssl_context *ssl);
1492 MBEDTLS_DEPRECATED extern int (*mbedtls_ssl_hw_record_write)(
1493  mbedtls_ssl_context *ssl);
1494 MBEDTLS_DEPRECATED extern int (*mbedtls_ssl_hw_record_read)(
1495  mbedtls_ssl_context *ssl);
1496 MBEDTLS_DEPRECATED extern int (*mbedtls_ssl_hw_record_finish)(
1497  mbedtls_ssl_context *ssl);
1498 
1499 #undef MBEDTLS_DEPRECATED
1500 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
1501 
1502 #endif /* MBEDTLS_SSL_HW_RECORD_ACCEL */
1503 
1512 const char *mbedtls_ssl_get_ciphersuite_name(const int ciphersuite_id);
1513 
1522 int mbedtls_ssl_get_ciphersuite_id(const char *ciphersuite_name);
1523 
1532 
1558  const mbedtls_ssl_config *conf);
1559 
1571 
1578 void mbedtls_ssl_conf_endpoint(mbedtls_ssl_config *conf, int endpoint);
1579 
1594 void mbedtls_ssl_conf_transport(mbedtls_ssl_config *conf, int transport);
1595 
1622 void mbedtls_ssl_conf_authmode(mbedtls_ssl_config *conf, int authmode);
1623 
1624 #if defined(MBEDTLS_X509_CRT_PARSE_C)
1625 
1641  int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *),
1642  void *p_vrfy);
1643 #endif /* MBEDTLS_X509_CRT_PARSE_C */
1644 
1653  int (*f_rng)(void *, unsigned char *, size_t),
1654  void *p_rng);
1655 
1671  void (*f_dbg)(void *, int, const char *, int, const char *),
1672  void *p_dbg);
1673 
1705  void *p_bio,
1706  mbedtls_ssl_send_t *f_send,
1707  mbedtls_ssl_recv_t *f_recv,
1708  mbedtls_ssl_recv_timeout_t *f_recv_timeout);
1709 
1710 #if defined(MBEDTLS_SSL_PROTO_DTLS)
1711 
1712 #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
1713 
1714 
1798 int mbedtls_ssl_set_cid(mbedtls_ssl_context *ssl,
1799  int enable,
1800  unsigned char const *own_cid,
1801  size_t own_cid_len);
1802 
1840 int mbedtls_ssl_get_peer_cid(mbedtls_ssl_context *ssl,
1841  int *enabled,
1842  unsigned char peer_cid[MBEDTLS_SSL_CID_OUT_LEN_MAX],
1843  size_t *peer_cid_len);
1844 
1845 #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
1846 
1889 void mbedtls_ssl_set_mtu(mbedtls_ssl_context *ssl, uint16_t mtu);
1890 #endif /* MBEDTLS_SSL_PROTO_DTLS */
1891 
1892 #if defined(MBEDTLS_X509_CRT_PARSE_C)
1893 
1912  int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *),
1913  void *p_vrfy);
1914 #endif /* MBEDTLS_X509_CRT_PARSE_C */
1915 
1932 void mbedtls_ssl_conf_read_timeout(mbedtls_ssl_config *conf, uint32_t timeout);
1933 
1934 #if defined(MBEDTLS_SSL_RECORD_CHECKING)
1935 
1980  unsigned char *buf,
1981  size_t buflen);
1982 #endif /* MBEDTLS_SSL_RECORD_CHECKING */
1983 
2005  void *p_timer,
2006  mbedtls_ssl_set_timer_t *f_set_timer,
2007  mbedtls_ssl_get_timer_t *f_get_timer);
2008 
2028 typedef int mbedtls_ssl_ticket_write_t(void *p_ticket,
2029  const mbedtls_ssl_session *session,
2030  unsigned char *start,
2031  const unsigned char *end,
2032  size_t *tlen,
2033  uint32_t *lifetime);
2034 
2035 #if defined(MBEDTLS_SSL_EXPORT_KEYS)
2036 
2056 typedef int mbedtls_ssl_export_keys_t(void *p_expkey,
2057  const unsigned char *ms,
2058  const unsigned char *kb,
2059  size_t maclen,
2060  size_t keylen,
2061  size_t ivlen);
2062 
2088 typedef int mbedtls_ssl_export_keys_ext_t(void *p_expkey,
2089  const unsigned char *ms,
2090  const unsigned char *kb,
2091  size_t maclen,
2092  size_t keylen,
2093  size_t ivlen,
2094  const unsigned char client_random[32],
2095  const unsigned char server_random[32],
2096  mbedtls_tls_prf_types tls_prf_type);
2097 #endif /* MBEDTLS_SSL_EXPORT_KEYS */
2098 
2122 typedef int mbedtls_ssl_ticket_parse_t(void *p_ticket,
2123  mbedtls_ssl_session *session,
2124  unsigned char *buf,
2125  size_t len);
2126 
2127 #if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_SRV_C)
2128 
2143  mbedtls_ssl_ticket_write_t *f_ticket_write,
2144  mbedtls_ssl_ticket_parse_t *f_ticket_parse,
2145  void *p_ticket);
2146 #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_SRV_C */
2147 
2148 #if defined(MBEDTLS_SSL_EXPORT_KEYS)
2149 
2160  mbedtls_ssl_export_keys_t *f_export_keys,
2161  void *p_export_keys);
2162 
2176  mbedtls_ssl_export_keys_ext_t *f_export_keys_ext,
2177  void *p_export_keys);
2178 #endif /* MBEDTLS_SSL_EXPORT_KEYS */
2179 
2180 #if defined(MBEDTLS_SSL_ASYNC_PRIVATE)
2181 
2211 void mbedtls_ssl_conf_async_private_cb(mbedtls_ssl_config *conf,
2212  mbedtls_ssl_async_sign_t *f_async_sign,
2213  mbedtls_ssl_async_decrypt_t *f_async_decrypt,
2214  mbedtls_ssl_async_resume_t *f_async_resume,
2215  mbedtls_ssl_async_cancel_t *f_async_cancel,
2216  void *config_data);
2217 
2226 void *mbedtls_ssl_conf_get_async_config_data(const mbedtls_ssl_config *conf);
2227 
2242 void *mbedtls_ssl_get_async_operation_data(const mbedtls_ssl_context *ssl);
2243 
2255 void mbedtls_ssl_set_async_operation_data(mbedtls_ssl_context *ssl,
2256  void *ctx);
2257 #endif /* MBEDTLS_SSL_ASYNC_PRIVATE */
2258 
2273 typedef int mbedtls_ssl_cookie_write_t(void *ctx,
2274  unsigned char **p, unsigned char *end,
2275  const unsigned char *info, size_t ilen);
2276 
2290 typedef int mbedtls_ssl_cookie_check_t(void *ctx,
2291  const unsigned char *cookie, size_t clen,
2292  const unsigned char *info, size_t ilen);
2293 
2294 #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C)
2295 
2324  mbedtls_ssl_cookie_write_t *f_cookie_write,
2325  mbedtls_ssl_cookie_check_t *f_cookie_check,
2326  void *p_cookie);
2327 
2348  const unsigned char *info,
2349  size_t ilen);
2350 
2351 #endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY && MBEDTLS_SSL_SRV_C */
2352 
2353 #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)
2354 
2370 #endif /* MBEDTLS_SSL_DTLS_ANTI_REPLAY */
2371 
2372 #if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT)
2373 
2396 void mbedtls_ssl_conf_dtls_badmac_limit(mbedtls_ssl_config *conf, unsigned limit);
2397 #endif /* MBEDTLS_SSL_DTLS_BADMAC_LIMIT */
2398 
2399 #if defined(MBEDTLS_SSL_PROTO_DTLS)
2400 
2430  unsigned allow_packing);
2431 
2463 void mbedtls_ssl_conf_handshake_timeout(mbedtls_ssl_config *conf, uint32_t min, uint32_t max);
2464 #endif /* MBEDTLS_SSL_PROTO_DTLS */
2465 
2466 #if defined(MBEDTLS_SSL_SRV_C)
2467 
2505  void *p_cache,
2506  int (*f_get_cache)(void *, mbedtls_ssl_session *),
2507  int (*f_set_cache)(void *, const mbedtls_ssl_session *));
2508 #endif /* MBEDTLS_SSL_SRV_C */
2509 
2510 #if defined(MBEDTLS_SSL_CLI_C)
2511 
2526 #endif /* MBEDTLS_SSL_CLI_C */
2527 
2561  const unsigned char *buf,
2562  size_t len);
2563 
2591  unsigned char *buf,
2592  size_t buf_len,
2593  size_t *olen);
2594 
2611 
2628  const int *ciphersuites);
2629 
2630 #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
2631 #define MBEDTLS_SSL_UNEXPECTED_CID_IGNORE 0
2632 #define MBEDTLS_SSL_UNEXPECTED_CID_FAIL 1
2633 
2665 int mbedtls_ssl_conf_cid(mbedtls_ssl_config *conf, size_t len,
2666  int ignore_other_cids);
2667 #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
2668 
2689  const int *ciphersuites,
2690  int major, int minor);
2691 
2692 #if defined(MBEDTLS_X509_CRT_PARSE_C)
2693 
2704  const mbedtls_x509_crt_profile *profile);
2705 
2718  mbedtls_x509_crt *ca_chain,
2719  mbedtls_x509_crl *ca_crl);
2720 
2721 #if defined(MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK)
2722 
2773 void mbedtls_ssl_conf_ca_cb(mbedtls_ssl_config *conf,
2774  mbedtls_x509_crt_ca_cb_t f_ca_cb,
2775  void *p_ca_cb);
2776 #endif /* MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK */
2777 
2815  mbedtls_x509_crt *own_cert,
2816  mbedtls_pk_context *pk_key);
2817 #endif /* MBEDTLS_X509_CRT_PARSE_C */
2818 
2819 #if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
2820 
2852  const unsigned char *psk, size_t psk_len,
2853  const unsigned char *psk_identity, size_t psk_identity_len);
2854 
2855 #if defined(MBEDTLS_USE_PSA_CRYPTO)
2856 
2892 int mbedtls_ssl_conf_psk_opaque(mbedtls_ssl_config *conf,
2893  psa_key_id_t psk,
2894  const unsigned char *psk_identity,
2895  size_t psk_identity_len);
2896 #endif /* MBEDTLS_USE_PSA_CRYPTO */
2897 
2915  const unsigned char *psk, size_t psk_len);
2916 
2917 #if defined(MBEDTLS_USE_PSA_CRYPTO)
2918 
2938 int mbedtls_ssl_set_hs_psk_opaque(mbedtls_ssl_context *ssl,
2939  psa_key_id_t psk);
2940 #endif /* MBEDTLS_USE_PSA_CRYPTO */
2941 
2981  int (*f_psk)(void *, mbedtls_ssl_context *, const unsigned char *,
2982  size_t),
2983  void *p_psk);
2984 #endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED */
2985 
2986 #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_SRV_C)
2987 
2988 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
2989 
2990 #if defined(MBEDTLS_DEPRECATED_WARNING)
2991 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
2992 #else
2993 #define MBEDTLS_DEPRECATED
2994 #endif
2995 
3010  const char *dhm_P,
3011  const char *dhm_G);
3012 
3013 #endif /* MBEDTLS_DEPRECATED_REMOVED */
3014 
3029  const unsigned char *dhm_P, size_t P_len,
3030  const unsigned char *dhm_G, size_t G_len);
3031 
3042 #endif /* MBEDTLS_DHM_C && defined(MBEDTLS_SSL_SRV_C) */
3043 
3044 #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C)
3045 
3054  unsigned int bitlen);
3055 #endif /* MBEDTLS_DHM_C && MBEDTLS_SSL_CLI_C */
3056 
3057 #if defined(MBEDTLS_ECP_C)
3058 
3088  const mbedtls_ecp_group_id *curves);
3089 #endif /* MBEDTLS_ECP_C */
3090 
3091 #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED)
3092 
3113  const int *hashes);
3114 #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */
3115 
3116 #if defined(MBEDTLS_X509_CRT_PARSE_C)
3117 
3135 int mbedtls_ssl_set_hostname(mbedtls_ssl_context *ssl, const char *hostname);
3136 #endif /* MBEDTLS_X509_CRT_PARSE_C */
3137 
3138 #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
3139 
3152  mbedtls_x509_crt *own_cert,
3153  mbedtls_pk_context *pk_key);
3154 
3167  mbedtls_x509_crt *ca_chain,
3168  mbedtls_x509_crl *ca_crl);
3169 
3181  int authmode);
3182 
3207  int (*f_sni)(void *, mbedtls_ssl_context *, const unsigned char *,
3208  size_t),
3209  void *p_sni);
3210 #endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */
3211 
3212 #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
3213 
3230 int mbedtls_ssl_set_hs_ecjpake_password(mbedtls_ssl_context *ssl,
3231  const unsigned char *pw,
3232  size_t pw_len);
3233 #endif /*MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */
3234 
3235 #if defined(MBEDTLS_SSL_ALPN)
3236 
3248 int mbedtls_ssl_conf_alpn_protocols(mbedtls_ssl_config *conf, const char **protos);
3249 
3259 const char *mbedtls_ssl_get_alpn_protocol(const mbedtls_ssl_context *ssl);
3260 #endif /* MBEDTLS_SSL_ALPN */
3261 
3262 #if defined(MBEDTLS_SSL_DTLS_SRTP)
3263 #if defined(MBEDTLS_DEBUG_C)
3264 static inline const char *mbedtls_ssl_get_srtp_profile_as_string(mbedtls_ssl_srtp_profile profile)
3265 {
3266  switch (profile) {
3267  case MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_80:
3268  return "MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_80";
3269  case MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32:
3270  return "MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32";
3271  case MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_80:
3272  return "MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_80";
3273  case MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_32:
3274  return "MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_32";
3275  default: break;
3276  }
3277  return "";
3278 }
3279 #endif /* MBEDTLS_DEBUG_C */
3280 
3293 void mbedtls_ssl_conf_srtp_mki_value_supported(mbedtls_ssl_config *conf,
3294  int support_mki_value);
3295 
3315 int mbedtls_ssl_conf_dtls_srtp_protection_profiles
3316  (mbedtls_ssl_config *conf,
3317  const mbedtls_ssl_srtp_profile *profiles);
3318 
3335 int mbedtls_ssl_dtls_srtp_set_mki_value(mbedtls_ssl_context *ssl,
3336  unsigned char *mki_value,
3337  uint16_t mki_len);
3356 void mbedtls_ssl_get_dtls_srtp_negotiation_result(const mbedtls_ssl_context *ssl,
3357  mbedtls_dtls_srtp_info *dtls_srtp_info);
3358 #endif /* MBEDTLS_SSL_DTLS_SRTP */
3359 
3376 void mbedtls_ssl_conf_max_version(mbedtls_ssl_config *conf, int major, int minor);
3377 
3396 void mbedtls_ssl_conf_min_version(mbedtls_ssl_config *conf, int major, int minor);
3397 
3398 #if defined(MBEDTLS_SSL_FALLBACK_SCSV) && defined(MBEDTLS_SSL_CLI_C)
3399 
3418 void mbedtls_ssl_conf_fallback(mbedtls_ssl_config *conf, char fallback);
3419 #endif /* MBEDTLS_SSL_FALLBACK_SCSV && MBEDTLS_SSL_CLI_C */
3420 
3421 #if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
3422 
3434 #endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */
3435 
3436 #if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET)
3437 
3449 #endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */
3450 
3451 #if defined(MBEDTLS_ARC4_C)
3452 
3467 void mbedtls_ssl_conf_arc4_support(mbedtls_ssl_config *conf, char arc4);
3468 #endif /* MBEDTLS_ARC4_C */
3469 
3470 #if defined(MBEDTLS_SSL_SRV_C)
3471 
3481  char cert_req_ca_list);
3482 #endif /* MBEDTLS_SSL_SRV_C */
3483 
3484 #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
3485 
3519 int mbedtls_ssl_conf_max_frag_len(mbedtls_ssl_config *conf, unsigned char mfl_code);
3520 #endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
3521 
3522 #if defined(MBEDTLS_SSL_TRUNCATED_HMAC)
3523 
3531 void mbedtls_ssl_conf_truncated_hmac(mbedtls_ssl_config *conf, int truncate);
3532 #endif /* MBEDTLS_SSL_TRUNCATED_HMAC */
3533 
3534 #if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING)
3535 
3547 #endif /* MBEDTLS_SSL_CBC_RECORD_SPLITTING */
3548 
3549 #if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_CLI_C)
3550 
3560 void mbedtls_ssl_conf_session_tickets(mbedtls_ssl_config *conf, int use_tickets);
3561 #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_CLI_C */
3562 
3563 #if defined(MBEDTLS_SSL_RENEGOTIATION)
3564 
3581 void mbedtls_ssl_conf_renegotiation(mbedtls_ssl_config *conf, int renegotiation);
3582 #endif /* MBEDTLS_SSL_RENEGOTIATION */
3583 
3611 void mbedtls_ssl_conf_legacy_renegotiation(mbedtls_ssl_config *conf, int allow_legacy);
3612 
3613 #if defined(MBEDTLS_SSL_RENEGOTIATION)
3614 
3651 void mbedtls_ssl_conf_renegotiation_enforced(mbedtls_ssl_config *conf, int max_records);
3652 
3679  const unsigned char period[8]);
3680 #endif /* MBEDTLS_SSL_RENEGOTIATION */
3681 
3721 
3738 
3752 
3760 const char *mbedtls_ssl_get_ciphersuite(const mbedtls_ssl_context *ssl);
3761 
3769 const char *mbedtls_ssl_get_version(const mbedtls_ssl_context *ssl);
3770 
3785 
3786 #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
3787 
3801 
3817 
3818 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
3819 
3820 #if defined(MBEDTLS_DEPRECATED_WARNING)
3821 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
3822 #else
3823 #define MBEDTLS_DEPRECATED
3824 #endif
3825 
3841  const mbedtls_ssl_context *ssl);
3842 #endif /* MBEDTLS_DEPRECATED_REMOVED */
3843 #endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
3844 
3873 
3874 #if defined(MBEDTLS_X509_CRT_PARSE_C)
3875 
3906 #endif /* MBEDTLS_X509_CRT_PARSE_C */
3907 
3908 #if defined(MBEDTLS_SSL_CLI_C)
3909 
3936 #endif /* MBEDTLS_SSL_CLI_C */
3937 
3993 
4015 
4016 #if defined(MBEDTLS_SSL_RENEGOTIATION)
4017 
4041 #endif /* MBEDTLS_SSL_RENEGOTIATION */
4042 
4120 int mbedtls_ssl_read(mbedtls_ssl_context *ssl, unsigned char *buf, size_t len);
4121 
4182 int mbedtls_ssl_write(mbedtls_ssl_context *ssl, const unsigned char *buf, size_t len);
4183 
4201  unsigned char level,
4202  unsigned char message);
4217 
4224 
4225 #if defined(MBEDTLS_SSL_CONTEXT_SERIALIZATION)
4226 
4275  unsigned char *buf,
4276  size_t buf_len,
4277  size_t *olen);
4278 
4345  const unsigned char *buf,
4346  size_t len);
4347 #endif /* MBEDTLS_SSL_CONTEXT_SERIALIZATION */
4348 
4360 
4377  int endpoint, int transport, int preset);
4378 
4385 
4392 
4403 
4420  const unsigned char *secret, size_t slen,
4421  const char *label,
4422  const unsigned char *random, size_t rlen,
4423  unsigned char *dstbuf, size_t dlen);
4424 
4425 #ifdef __cplusplus
4426 }
4427 #endif
4428 
4429 #endif /* ssl.h */
uint64_t in_window_top
Definition: ssl.h:1356
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:1293
void * p_rng
Definition: ssl.h:1124
uint8_t allow_legacy_renegotiation
Definition: ssl.h:1040
const char ** alpn_list
Definition: ssl.h:1255
unsigned char * in_ctr
Definition: ssl.h:1331
mbedtls_x509_crt * peer_cert
Definition: ssl.h:989
unsigned char * out_msg
Definition: ssl.h:1384
unsigned char master[48]
Definition: ssl.h:985
unsigned char * in_len
Definition: ssl.h:1339
unsigned char * in_buf
Definition: ssl.h:1330
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:2122
mbedtls_mpi dhm_P
Definition: ssl.h:1216
char peer_verify_data[MBEDTLS_SSL_VERIFY_DATA_MAX_LEN]
Definition: ssl.h:1447
unsigned char max_minor_ver
Definition: ssl.h:1026
uint8_t disable_renegotiation
Definition: ssl.h:1060
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:1028
uint8_t authmode
Definition: ssl.h:1038
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:2273
unsigned char * in_hdr
Definition: ssl.h:1334
size_t psk_identity_len
Definition: ssl.h:1246
unsigned int dhm_min_bitlen
Definition: ssl.h:1109
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:2290
void * p_sni
Definition: ssl.h:1135
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:1001
struct mbedtls_ssl_sig_hash_set_t mbedtls_ssl_sig_hash_set_t
Definition: ssl.h:689
size_t ticket_len
Definition: ssl.h:1002
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:1383
uint8_t transport
Definition: ssl.h:1037
mbedtls_ssl_transform * transform_in
Definition: ssl.h:1314
size_t in_left
Definition: ssl.h:1346
int mbedtls_ssl_send_t(void *ctx, const unsigned char *buf, size_t len)
Callback type: send data on the network.
Definition: ssl.h:588
uint8_t extended_ms
Definition: ssl.h:1051
unsigned int badmac_limit
Definition: ssl.h:1105
void * p_psk
Definition: ssl.h:1147
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:612
uint8_t fallback
Definition: ssl.h:1069
const mbedtls_ecp_group_id * curve_list
Definition: ssl.h:1212
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:1152
int(* f_export_keys)(void *, const unsigned char *, const unsigned char *, size_t, size_t, size_t)
Definition: ssl.h:1171
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:2088
int(* f_get_cache)(void *, mbedtls_ssl_session *)
Definition: ssl.h:1127
Platform Security Architecture cryptography module.
uint8_t encrypt_then_mac
Definition: ssl.h:1048
unsigned char _pms_dhm[MBEDTLS_MPI_MAX_SIZE]
Definition: ssl.h:501
void(* f_dbg)(void *, int, const char *, int, const char *)
Definition: ssl.h:1119
void * p_cache
Definition: ssl.h:1130
int(* f_sni)(void *, mbedtls_ssl_context *, const unsigned char *, size_t)
Definition: ssl.h:1134
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:498
unsigned char _pms_ecdh[MBEDTLS_ECP_MAX_BYTES]
Definition: ssl.h:507
unsigned char renego_period[8]
Definition: ssl.h:1100
uint32_t ticket_lifetime
Definition: ssl.h:1003
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:1303
uint8_t disable_datagram_packing
Definition: ssl.h:1368
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:1284
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:1325
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:1190
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:1304
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:638
uint16_t mtu
Definition: ssl.h:1396
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:1162
mbedtls_ssl_transform * transform_out
Definition: ssl.h:1315
unsigned char mfl_code
Definition: ssl.h:975
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:1129
Multi-precision integer library.
int encrypt_then_mac
Definition: ssl.h:1011
size_t in_hslen
Definition: ssl.h:1360
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:1155
uint64_t in_window
Definition: ssl.h:1357
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:694
void * p_cookie
Definition: ssl.h:1157
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:1175
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:1316
uint32_t hs_timeout_min
Definition: ssl.h:1092
mbedtls_ssl_handshake_params * handshake
Definition: ssl.h:1308
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:1388
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:1341
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:1027
struct mbedtls_ssl_transform mbedtls_ssl_transform
Definition: ssl.h:687
mbedtls_ssl_set_timer_t * f_set_timer
Definition: ssl.h:1324
uint8_t anti_replay
Definition: ssl.h:1054
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:1036
const int * ciphersuite_list[4]
Definition: ssl.h:1116
int(* f_rng)(void *, unsigned char *, size_t)
Definition: ssl.h:1123
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:1188
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:1294
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:1306
mbedtls_ssl_states
Definition: ssl.h:537
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:1208
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:3823
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:1072
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:983
void * p_bio
Definition: ssl.h:1298
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:1066
unsigned char _pms_ecdhe_psk[4+MBEDTLS_ECP_MAX_BYTES+MBEDTLS_PSK_MAX_LEN]
Definition: ssl.h:521
void * p_vrfy
Definition: ssl.h:1141
const mbedtls_x509_crt_profile * cert_profile
Definition: ssl.h:1187
void * p_timer
Definition: ssl.h:1322
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:492
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:1305
unsigned char * in_iv
Definition: ssl.h:1340
char own_verify_data[MBEDTLS_SSL_VERIFY_DATA_MAX_LEN]
Definition: ssl.h:1446
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:1317
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:120
unsigned char * out_ctr
Definition: ssl.h:1376
int secure_renegotiation
Definition: ssl.h:1442
int mbedtls_ssl_get_timer_t(void *ctx)
Callback type: get status of timers/delays.
Definition: ssl.h:679
The DHM context structure.
Definition: dhm.h:111
const mbedtls_ssl_config * conf
Definition: ssl.h:1267
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:1146
unsigned char * in_offt
Definition: ssl.h:1342
unsigned char max_major_ver
Definition: ssl.h:1025
unsigned char * psk
Definition: ssl.h:1231
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:1420
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:1217
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:1179
char * hostname
Definition: ssl.h:1415
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:1042
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:1387
uint32_t read_timeout
Definition: ssl.h:1089
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:517
uint8_t trunc_hmac
Definition: ssl.h:1063
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:1289
int(* f_ticket_parse)(void *, mbedtls_ssl_session *, unsigned char *, size_t)
Definition: ssl.h:1165
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:2056
unsigned char * out_len
Definition: ssl.h:1382
void * p_vrfy
Definition: ssl.h:1290
int(* f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *)
Definition: ssl.h:1140
uint32_t hs_timeout_max
Definition: ssl.h:1094
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:1434
int renego_max_records
Definition: ssl.h:1099
mbedtls_ssl_recv_timeout_t * f_recv_timeout
Definition: ssl.h:1295
mbedtls_x509_crt * ca_chain
Definition: ssl.h:1189
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:1445
void mbedtls_ssl_config_free(mbedtls_ssl_config *conf)
Free an SSL configuration context.
unsigned char * psk_identity
Definition: ssl.h:1241
#define MBEDTLS_SSL_CID_OUT_LEN_MAX
Definition: ssl.h:343
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:691
uint8_t cbc_record_splitting
Definition: ssl.h:1057
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:664
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:514
size_t next_record_offset
Definition: ssl.h:1352
unsigned char * out_buf
Definition: ssl.h:1375
#define MBEDTLS_SSL_CID_IN_LEN_MAX
Definition: ssl.h:339
size_t psk_len
Definition: ssl.h:1235
void mbedtls_ssl_session_init(mbedtls_ssl_session *session)
Initialize SSL session structure.
void * p_dbg
Definition: ssl.h:1120
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:2028
size_t cli_id_len
Definition: ssl.h:1435
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:1275
uint8_t mfl_code
Definition: ssl.h:1045
unsigned char * out_hdr
Definition: ssl.h:1377
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:510
uint32_t verify_result
Definition: ssl.h:998
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:1364
signed char split_done
Definition: ssl.h:1403
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:1393
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:688
#define MBEDTLS_ECP_MAX_BYTES
Definition: ecp.h:307
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:1166
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:362
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:979
size_t in_msglen
Definition: ssl.h:1345
uint16_t in_epoch
Definition: ssl.h:1351
mbedtls_tls_prf_types
Definition: ssl.h:563
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...