Lines Matching refs:ssl
48 int mbedtls_ssl_set_client_transport_id(mbedtls_ssl_context *ssl, in mbedtls_ssl_set_client_transport_id() argument
52 if (ssl->conf->endpoint != MBEDTLS_SSL_IS_SERVER) { in mbedtls_ssl_set_client_transport_id()
56 mbedtls_free(ssl->cli_id); in mbedtls_ssl_set_client_transport_id()
58 if ((ssl->cli_id = mbedtls_calloc(1, ilen)) == NULL) { in mbedtls_ssl_set_client_transport_id()
62 memcpy(ssl->cli_id, info, ilen); in mbedtls_ssl_set_client_transport_id()
63 ssl->cli_id_len = ilen; in mbedtls_ssl_set_client_transport_id()
107 static int ssl_parse_renegotiation_info(mbedtls_ssl_context *ssl, in ssl_parse_renegotiation_info() argument
112 if (ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE) { in ssl_parse_renegotiation_info()
114 if (len != 1 + ssl->verify_data_len || in ssl_parse_renegotiation_info()
115 buf[0] != ssl->verify_data_len || in ssl_parse_renegotiation_info()
116 mbedtls_ct_memcmp(buf + 1, ssl->peer_verify_data, in ssl_parse_renegotiation_info()
117 ssl->verify_data_len) != 0) { in ssl_parse_renegotiation_info()
119 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_renegotiation_info()
128 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_renegotiation_info()
133 ssl->secure_renegotiation = MBEDTLS_SSL_SECURE_RENEGOTIATION; in ssl_parse_renegotiation_info()
181 static int ssl_parse_supported_groups_ext(mbedtls_ssl_context *ssl, in ssl_parse_supported_groups_ext() argument
191 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_supported_groups_ext()
199 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_supported_groups_ext()
205 if (ssl->handshake->curves_tls_id != NULL) { in ssl_parse_supported_groups_ext()
207 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_supported_groups_ext()
221 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_supported_groups_ext()
226 ssl->handshake->curves_tls_id = curves_tls_id; in ssl_parse_supported_groups_ext()
246 static int ssl_parse_supported_point_formats(mbedtls_ssl_context *ssl, in ssl_parse_supported_point_formats() argument
255 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_supported_point_formats()
267 ssl->handshake->ecdh_ctx.point_format = p[0]; in ssl_parse_supported_point_formats()
271 mbedtls_ecjpake_set_point_format(&ssl->handshake->ecjpake_ctx, in ssl_parse_supported_point_formats()
290 static int ssl_parse_ecjpake_kkpp(mbedtls_ssl_context *ssl, in ssl_parse_ecjpake_kkpp() argument
297 if (ssl->handshake->psa_pake_ctx_is_ok != 1) in ssl_parse_ecjpake_kkpp()
299 if (mbedtls_ecjpake_check(&ssl->handshake->ecjpake_ctx) != 0) in ssl_parse_ecjpake_kkpp()
308 &ssl->handshake->psa_pake_ctx, buf, len, in ssl_parse_ecjpake_kkpp()
310 psa_destroy_key(ssl->handshake->psa_pake_password); in ssl_parse_ecjpake_kkpp()
311 psa_pake_abort(&ssl->handshake->psa_pake_ctx); in ssl_parse_ecjpake_kkpp()
315 ssl, in ssl_parse_ecjpake_kkpp()
322 if ((ret = mbedtls_ecjpake_read_round_one(&ssl->handshake->ecjpake_ctx, in ssl_parse_ecjpake_kkpp()
325 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_ecjpake_kkpp()
332 ssl->handshake->cli_exts |= MBEDTLS_TLS_EXT_ECJPAKE_KKPP_OK; in ssl_parse_ecjpake_kkpp()
340 static int ssl_parse_max_fragment_length_ext(mbedtls_ssl_context *ssl, in ssl_parse_max_fragment_length_ext() argument
346 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_max_fragment_length_ext()
351 ssl->session_negotiate->mfl_code = buf[0]; in ssl_parse_max_fragment_length_ext()
359 static int ssl_parse_cid_ext(mbedtls_ssl_context *ssl, in ssl_parse_cid_ext() argument
366 if (ssl->conf->transport != MBEDTLS_SSL_TRANSPORT_DATAGRAM) { in ssl_parse_cid_ext()
368 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_cid_ext()
381 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_cid_ext()
391 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_cid_ext()
397 if (ssl->negotiate_cid == MBEDTLS_SSL_CID_DISABLED) { in ssl_parse_cid_ext()
406 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_cid_ext()
411 ssl->handshake->cid_in_use = MBEDTLS_SSL_CID_ENABLED; in ssl_parse_cid_ext()
412 ssl->handshake->peer_cid_len = (uint8_t) peer_cid_len; in ssl_parse_cid_ext()
413 memcpy(ssl->handshake->peer_cid, buf, peer_cid_len); in ssl_parse_cid_ext()
424 static int ssl_parse_encrypt_then_mac_ext(mbedtls_ssl_context *ssl, in ssl_parse_encrypt_then_mac_ext() argument
430 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_encrypt_then_mac_ext()
437 if (ssl->conf->encrypt_then_mac == MBEDTLS_SSL_ETM_ENABLED) { in ssl_parse_encrypt_then_mac_ext()
438 ssl->session_negotiate->encrypt_then_mac = MBEDTLS_SSL_ETM_ENABLED; in ssl_parse_encrypt_then_mac_ext()
447 static int ssl_parse_extended_ms_ext(mbedtls_ssl_context *ssl, in ssl_parse_extended_ms_ext() argument
453 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_extended_ms_ext()
460 if (ssl->conf->extended_ms == MBEDTLS_SSL_EXTENDED_MS_ENABLED) { in ssl_parse_extended_ms_ext()
461 ssl->handshake->extended_ms = MBEDTLS_SSL_EXTENDED_MS_ENABLED; in ssl_parse_extended_ms_ext()
470 static int ssl_parse_session_ticket_ext(mbedtls_ssl_context *ssl, in ssl_parse_session_ticket_ext() argument
479 if (ssl->conf->f_ticket_parse == NULL || in ssl_parse_session_ticket_ext()
480 ssl->conf->f_ticket_write == NULL) { in ssl_parse_session_ticket_ext()
485 ssl->handshake->new_session_ticket = 1; in ssl_parse_session_ticket_ext()
494 if (ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE) { in ssl_parse_session_ticket_ext()
503 if ((ret = ssl->conf->f_ticket_parse(ssl->conf->p_ticket, &session, in ssl_parse_session_ticket_ext()
522 session.id_len = ssl->session_negotiate->id_len; in ssl_parse_session_ticket_ext()
523 memcpy(&session.id, ssl->session_negotiate->id, session.id_len); in ssl_parse_session_ticket_ext()
525 mbedtls_ssl_session_free(ssl->session_negotiate); in ssl_parse_session_ticket_ext()
526 memcpy(ssl->session_negotiate, &session, sizeof(mbedtls_ssl_session)); in ssl_parse_session_ticket_ext()
533 ssl->handshake->resume = 1; in ssl_parse_session_ticket_ext()
536 ssl->handshake->new_session_ticket = 0; in ssl_parse_session_ticket_ext()
544 static int ssl_parse_use_srtp_ext(mbedtls_ssl_context *ssl, in ssl_parse_use_srtp_ext() argument
556 if ((ssl->conf->transport != MBEDTLS_SSL_TRANSPORT_DATAGRAM) || in ssl_parse_use_srtp_ext()
557 (ssl->conf->dtls_srtp_profile_list == NULL) || in ssl_parse_use_srtp_ext()
558 (ssl->conf->dtls_srtp_profile_list_len == 0)) { in ssl_parse_use_srtp_ext()
580 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_use_srtp_ext()
585 ssl->dtls_srtp_info.chosen_dtls_srtp_profile = MBEDTLS_TLS_SRTP_UNSET; in ssl_parse_use_srtp_ext()
594 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_use_srtp_ext()
614 for (i = 0; i < ssl->conf->dtls_srtp_profile_list_len; i++) { in ssl_parse_use_srtp_ext()
615 if (client_protection == ssl->conf->dtls_srtp_profile_list[i]) { in ssl_parse_use_srtp_ext()
616 ssl->dtls_srtp_info.chosen_dtls_srtp_profile = ssl->conf->dtls_srtp_profile_list[i]; in ssl_parse_use_srtp_ext()
623 if (ssl->dtls_srtp_info.chosen_dtls_srtp_profile != MBEDTLS_TLS_SRTP_UNSET) { in ssl_parse_use_srtp_ext()
633 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_use_srtp_ext()
639 if (ssl->conf->dtls_srtp_mki_support == MBEDTLS_SSL_DTLS_SRTP_MKI_SUPPORTED && in ssl_parse_use_srtp_ext()
641 ssl->dtls_srtp_info.mki_len = mki_length; in ssl_parse_use_srtp_ext()
643 memcpy(ssl->dtls_srtp_info.mki_value, buf, mki_length); in ssl_parse_use_srtp_ext()
645 MBEDTLS_SSL_DEBUG_BUF(3, "using mki", ssl->dtls_srtp_info.mki_value, in ssl_parse_use_srtp_ext()
646 ssl->dtls_srtp_info.mki_len); in ssl_parse_use_srtp_ext()
687 static int ssl_pick_cert(mbedtls_ssl_context *ssl, in ssl_pick_cert() argument
703 if (ssl->handshake->sni_key_cert != NULL) { in ssl_pick_cert()
704 list = ssl->handshake->sni_key_cert; in ssl_pick_cert()
707 list = ssl->conf->key_cert; in ssl_pick_cert()
734 key_type_matches = ((ssl->conf->f_async_sign_start != NULL || in ssl_pick_cert()
735 ssl->conf->f_async_decrypt_start != NULL || in ssl_pick_cert()
768 ssl->handshake->curves_tls_id) != 0) { in ssl_pick_cert()
780 ssl->handshake->key_cert = cur; in ssl_pick_cert()
782 ssl->handshake->key_cert->cert); in ssl_pick_cert()
795 static int ssl_ciphersuite_match(mbedtls_ssl_context *ssl, int suite_id, in ssl_ciphersuite_match() argument
813 if (suite_info->min_tls_version > ssl->tls_version || in ssl_ciphersuite_match()
814 suite_info->max_tls_version < ssl->tls_version) { in ssl_ciphersuite_match()
821 (ssl->handshake->cli_exts & MBEDTLS_TLS_EXT_ECJPAKE_KKPP_OK) == 0) { in ssl_ciphersuite_match()
832 (ssl->handshake->curves_tls_id == NULL || in ssl_ciphersuite_match()
833 ssl->handshake->curves_tls_id[0] == 0)) { in ssl_ciphersuite_match()
844 ssl_conf_has_psk_or_cb(ssl->conf) == 0) { in ssl_ciphersuite_match()
858 if (ssl_pick_cert(ssl, suite_info) != 0) { in ssl_ciphersuite_match()
871 ssl, mbedtls_ssl_sig_from_pk_alg(sig_type)) == MBEDTLS_SSL_HASH_NONE) { in ssl_ciphersuite_match()
887 static int ssl_parse_client_hello(mbedtls_ssl_context *ssl) in ssl_parse_client_hello() argument
928 renegotiating = (ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE); in ssl_parse_client_hello()
930 if (!renegotiating && !ssl->keep_current_message) { in ssl_parse_client_hello()
931 if ((ret = mbedtls_ssl_fetch_input(ssl, 5)) != 0) { in ssl_parse_client_hello()
938 buf = ssl->in_hdr; in ssl_parse_client_hello()
940 MBEDTLS_SSL_DEBUG_BUF(4, "record header", buf, mbedtls_ssl_in_hdr_len(ssl)); in ssl_parse_client_hello()
960 (ssl->in_len[0] << 8) | ssl->in_len[1])); in ssl_parse_client_hello()
968 if (ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM in ssl_parse_client_hello()
970 && ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE in ssl_parse_client_hello()
974 if (ssl->in_ctr[0] != 0 || ssl->in_ctr[1] != 0) { in ssl_parse_client_hello()
979 memcpy(&ssl->cur_out_ctr[2], ssl->in_ctr + 2, in ssl_parse_client_hello()
980 sizeof(ssl->cur_out_ctr) - 2); in ssl_parse_client_hello()
983 if (mbedtls_ssl_dtls_replay_check(ssl) != 0) { in ssl_parse_client_hello()
985 ssl->next_record_offset = 0; in ssl_parse_client_hello()
986 ssl->in_left = 0; in ssl_parse_client_hello()
991 mbedtls_ssl_dtls_replay_update(ssl); in ssl_parse_client_hello()
996 msg_len = (ssl->in_len[0] << 8) | ssl->in_len[1]; in ssl_parse_client_hello()
999 if (ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE) { in ssl_parse_client_hello()
1001 msg_len = ssl->in_hslen; in ssl_parse_client_hello()
1005 if (ssl->keep_current_message) { in ssl_parse_client_hello()
1006 ssl->keep_current_message = 0; in ssl_parse_client_hello()
1013 if ((ret = mbedtls_ssl_fetch_input(ssl, in ssl_parse_client_hello()
1014 mbedtls_ssl_in_hdr_len(ssl) + msg_len)) != 0) { in ssl_parse_client_hello()
1021 if (ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM) { in ssl_parse_client_hello()
1022 ssl->next_record_offset = msg_len + mbedtls_ssl_in_hdr_len(ssl); in ssl_parse_client_hello()
1025 ssl->in_left = 0; in ssl_parse_client_hello()
1029 buf = ssl->in_msg; in ssl_parse_client_hello()
1033 ret = ssl->handshake->update_checksum(ssl, buf, msg_len); in ssl_parse_client_hello()
1047 if (msg_len < mbedtls_ssl_hs_hdr_len(ssl)) { in ssl_parse_client_hello()
1072 if (msg_len != mbedtls_ssl_hs_hdr_len(ssl) + handshake_len) { in ssl_parse_client_hello()
1075 (unsigned) mbedtls_ssl_hs_hdr_len(ssl), in ssl_parse_client_hello()
1082 if (ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM) { in ssl_parse_client_hello()
1088 if (ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS) { in ssl_parse_client_hello()
1090 unsigned int cli_msg_seq = (unsigned int) MBEDTLS_GET_UINT16_BE(ssl->in_msg, 4); in ssl_parse_client_hello()
1091 if (cli_msg_seq != ssl->handshake->in_msg_seq) { in ssl_parse_client_hello()
1094 ssl->handshake->in_msg_seq)); in ssl_parse_client_hello()
1098 ssl->handshake->in_msg_seq++; in ssl_parse_client_hello()
1102 unsigned int cli_msg_seq = (unsigned int) MBEDTLS_GET_UINT16_BE(ssl->in_msg, 4); in ssl_parse_client_hello()
1103 ssl->handshake->out_msg_seq = cli_msg_seq; in ssl_parse_client_hello()
1104 ssl->handshake->in_msg_seq = cli_msg_seq + 1; in ssl_parse_client_hello()
1112 fragment_offset = MBEDTLS_GET_UINT24_BE(ssl->in_msg, 6); in ssl_parse_client_hello()
1113 fragment_length = MBEDTLS_GET_UINT24_BE(ssl->in_msg, 9); in ssl_parse_client_hello()
1114 length = MBEDTLS_GET_UINT24_BE(ssl->in_msg, 1); in ssl_parse_client_hello()
1127 buf += mbedtls_ssl_hs_hdr_len(ssl); in ssl_parse_client_hello()
1128 msg_len -= mbedtls_ssl_hs_hdr_len(ssl); in ssl_parse_client_hello()
1161 ssl->tls_version = (mbedtls_ssl_protocol_version) mbedtls_ssl_read_version(buf, in ssl_parse_client_hello()
1162 … ssl->conf->transport); in ssl_parse_client_hello()
1163 ssl->session_negotiate->tls_version = ssl->tls_version; in ssl_parse_client_hello()
1165 if (ssl->tls_version != MBEDTLS_SSL_VERSION_TLS1_2) { in ssl_parse_client_hello()
1167 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_client_hello()
1177 memcpy(ssl->handshake->randbytes, buf + 2, 32); in ssl_parse_client_hello()
1184 if (sess_len > sizeof(ssl->session_negotiate->id) || in ssl_parse_client_hello()
1187 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_client_hello()
1194 ssl->session_negotiate->id_len = sess_len; in ssl_parse_client_hello()
1195 memset(ssl->session_negotiate->id, 0, in ssl_parse_client_hello()
1196 sizeof(ssl->session_negotiate->id)); in ssl_parse_client_hello()
1197 memcpy(ssl->session_negotiate->id, buf + 35, in ssl_parse_client_hello()
1198 ssl->session_negotiate->id_len); in ssl_parse_client_hello()
1204 if (ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM) { in ssl_parse_client_hello()
1210 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_client_hello()
1219 if (ssl->conf->f_cookie_check != NULL in ssl_parse_client_hello()
1221 && ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE in ssl_parse_client_hello()
1224 if (ssl->conf->f_cookie_check(ssl->conf->p_cookie, in ssl_parse_client_hello()
1226 ssl->cli_id, ssl->cli_id_len) != 0) { in ssl_parse_client_hello()
1228 ssl->handshake->cookie_verify_result = 1; in ssl_parse_client_hello()
1231 ssl->handshake->cookie_verify_result = 0; in ssl_parse_client_hello()
1261 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_client_hello()
1283 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_client_hello()
1298 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_client_hello()
1308 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_client_hello()
1324 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_client_hello()
1333 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_client_hello()
1341 ret = mbedtls_ssl_parse_server_name_ext(ssl, ext + 4, in ssl_parse_client_hello()
1355 ret = ssl_parse_renegotiation_info(ssl, ext + 4, ext_size); in ssl_parse_client_hello()
1365 ret = mbedtls_ssl_parse_sig_alg_ext(ssl, ext + 4, ext + 4 + ext_size); in ssl_parse_client_hello()
1380 ret = ssl_parse_supported_groups_ext(ssl, ext + 4, ext_size); in ssl_parse_client_hello()
1388 ssl->handshake->cli_exts |= MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS_PRESENT; in ssl_parse_client_hello()
1390 ret = ssl_parse_supported_point_formats(ssl, ext + 4, ext_size); in ssl_parse_client_hello()
1403 ret = ssl_parse_ecjpake_kkpp(ssl, ext + 4, ext_size); in ssl_parse_client_hello()
1414 ret = ssl_parse_max_fragment_length_ext(ssl, ext + 4, ext_size); in ssl_parse_client_hello()
1425 ret = ssl_parse_cid_ext(ssl, ext + 4, ext_size); in ssl_parse_client_hello()
1436 ret = ssl_parse_encrypt_then_mac_ext(ssl, ext + 4, ext_size); in ssl_parse_client_hello()
1447 ret = ssl_parse_extended_ms_ext(ssl, ext + 4, ext_size); in ssl_parse_client_hello()
1458 ret = ssl_parse_session_ticket_ext(ssl, ext + 4, ext_size); in ssl_parse_client_hello()
1469 ret = mbedtls_ssl_parse_alpn_ext(ssl, ext + 4, in ssl_parse_client_hello()
1481 ret = ssl_parse_use_srtp_ext(ssl, ext + 4, ext_size); in ssl_parse_client_hello()
1504 uint16_t *received_sig_algs = ssl->handshake->received_sig_algs; in ssl_parse_client_hello()
1533 if (ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS) { in ssl_parse_client_hello()
1536 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_client_hello()
1541 ssl->secure_renegotiation = MBEDTLS_SSL_SECURE_RENEGOTIATION; in ssl_parse_client_hello()
1549 if (ssl->secure_renegotiation != MBEDTLS_SSL_SECURE_RENEGOTIATION && in ssl_parse_client_hello()
1550 ssl->conf->allow_legacy_renegotiation == MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE) { in ssl_parse_client_hello()
1555 else if (ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS && in ssl_parse_client_hello()
1556 ssl->secure_renegotiation == MBEDTLS_SSL_SECURE_RENEGOTIATION && in ssl_parse_client_hello()
1560 } else if (ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS && in ssl_parse_client_hello()
1561 ssl->secure_renegotiation == MBEDTLS_SSL_LEGACY_RENEGOTIATION && in ssl_parse_client_hello()
1562 ssl->conf->allow_legacy_renegotiation == MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION) { in ssl_parse_client_hello()
1565 } else if (ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS && in ssl_parse_client_hello()
1566 ssl->secure_renegotiation == MBEDTLS_SSL_LEGACY_RENEGOTIATION && in ssl_parse_client_hello()
1574 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_client_hello()
1582 if (ssl->conf->f_cert_cb && (ret = ssl->conf->f_cert_cb(ssl)) != 0) { in ssl_parse_client_hello()
1587 ssl->handshake->sni_name = NULL; in ssl_parse_client_hello()
1588 ssl->handshake->sni_name_len = 0; in ssl_parse_client_hello()
1598 ciphersuites = ssl->conf->ciphersuite_list; in ssl_parse_client_hello()
1601 if (ssl->conf->respect_cli_pref == MBEDTLS_SSL_SRV_CIPHERSUITE_ORDER_CLIENT) { in ssl_parse_client_hello()
1610 if ((ret = ssl_ciphersuite_match(ssl, ciphersuites[i], in ssl_parse_client_hello()
1629 if ((ret = ssl_ciphersuite_match(ssl, ciphersuites[i], in ssl_parse_client_hello()
1644 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_client_hello()
1649 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_client_hello()
1657 ssl->session_negotiate->ciphersuite = ciphersuites[i]; in ssl_parse_client_hello()
1658 ssl->handshake->ciphersuite_info = ciphersuite_info; in ssl_parse_client_hello()
1660 ssl->state++; in ssl_parse_client_hello()
1663 if (ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM) { in ssl_parse_client_hello()
1664 mbedtls_ssl_recv_flight_completed(ssl); in ssl_parse_client_hello()
1674 ssl, mbedtls_ssl_sig_from_pk_alg(sig_alg)); in ssl_parse_client_hello()
1689 static void ssl_write_cid_ext(mbedtls_ssl_context *ssl, in ssl_write_cid_ext() argument
1695 const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_OUT_CONTENT_LEN; in ssl_write_cid_ext()
1701 if (ssl->handshake->cid_in_use == MBEDTLS_SSL_CID_DISABLED) { in ssl_write_cid_ext()
1707 if (end < p || (size_t) (end - p) < (unsigned) (ssl->own_cid_len + 5)) { in ssl_write_cid_ext()
1721 ext_len = (size_t) ssl->own_cid_len + 1; in ssl_write_cid_ext()
1725 *p++ = (uint8_t) ssl->own_cid_len; in ssl_write_cid_ext()
1726 memcpy(p, ssl->own_cid, ssl->own_cid_len); in ssl_write_cid_ext()
1728 *olen = ssl->own_cid_len + 5; in ssl_write_cid_ext()
1733 static void ssl_write_encrypt_then_mac_ext(mbedtls_ssl_context *ssl, in ssl_write_encrypt_then_mac_ext() argument
1747 ssl->session_negotiate->ciphersuite); in ssl_write_encrypt_then_mac_ext()
1749 ssl->session_negotiate->encrypt_then_mac = MBEDTLS_SSL_ETM_DISABLED; in ssl_write_encrypt_then_mac_ext()
1753 ssl->session_negotiate->encrypt_then_mac, in ssl_write_encrypt_then_mac_ext()
1757 ssl->session_negotiate->encrypt_then_mac = MBEDTLS_SSL_ETM_DISABLED; in ssl_write_encrypt_then_mac_ext()
1761 if (ssl->session_negotiate->encrypt_then_mac == MBEDTLS_SSL_ETM_DISABLED) { in ssl_write_encrypt_then_mac_ext()
1779 static void ssl_write_extended_ms_ext(mbedtls_ssl_context *ssl, in ssl_write_extended_ms_ext() argument
1785 if (ssl->handshake->extended_ms == MBEDTLS_SSL_EXTENDED_MS_DISABLED) { in ssl_write_extended_ms_ext()
1804 static void ssl_write_session_ticket_ext(mbedtls_ssl_context *ssl, in ssl_write_session_ticket_ext() argument
1810 if (ssl->handshake->new_session_ticket == 0) { in ssl_write_session_ticket_ext()
1827 static void ssl_write_renegotiation_ext(mbedtls_ssl_context *ssl, in ssl_write_renegotiation_ext() argument
1833 if (ssl->secure_renegotiation != MBEDTLS_SSL_SECURE_RENEGOTIATION) { in ssl_write_renegotiation_ext()
1844 if (ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE) { in ssl_write_renegotiation_ext()
1846 *p++ = (ssl->verify_data_len * 2 + 1) & 0xFF; in ssl_write_renegotiation_ext()
1847 *p++ = ssl->verify_data_len * 2 & 0xFF; in ssl_write_renegotiation_ext()
1849 memcpy(p, ssl->peer_verify_data, ssl->verify_data_len); in ssl_write_renegotiation_ext()
1850 p += ssl->verify_data_len; in ssl_write_renegotiation_ext()
1851 memcpy(p, ssl->own_verify_data, ssl->verify_data_len); in ssl_write_renegotiation_ext()
1852 p += ssl->verify_data_len; in ssl_write_renegotiation_ext()
1865 static void ssl_write_max_fragment_length_ext(mbedtls_ssl_context *ssl, in ssl_write_max_fragment_length_ext() argument
1871 if (ssl->session_negotiate->mfl_code == MBEDTLS_SSL_MAX_FRAG_LEN_NONE) { in ssl_write_max_fragment_length_ext()
1884 *p++ = ssl->session_negotiate->mfl_code; in ssl_write_max_fragment_length_ext()
1893 static void ssl_write_supported_point_formats_ext(mbedtls_ssl_context *ssl, in ssl_write_supported_point_formats_ext() argument
1898 ((void) ssl); in ssl_write_supported_point_formats_ext()
1900 if ((ssl->handshake->cli_exts & in ssl_write_supported_point_formats_ext()
1924 static void ssl_write_ecjpake_kkpp_ext(mbedtls_ssl_context *ssl, in ssl_write_ecjpake_kkpp_ext() argument
1930 const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_OUT_CONTENT_LEN; in ssl_write_ecjpake_kkpp_ext()
1936 if (ssl->handshake->ciphersuite_info->key_exchange != in ssl_write_ecjpake_kkpp_ext()
1952 ret = mbedtls_psa_ecjpake_write_round(&ssl->handshake->psa_pake_ctx, in ssl_write_ecjpake_kkpp_ext()
1956 psa_destroy_key(ssl->handshake->psa_pake_password); in ssl_write_ecjpake_kkpp_ext()
1957 psa_pake_abort(&ssl->handshake->psa_pake_ctx); in ssl_write_ecjpake_kkpp_ext()
1962 ret = mbedtls_ecjpake_write_round_one(&ssl->handshake->ecjpake_ctx, in ssl_write_ecjpake_kkpp_ext()
1964 ssl->conf->f_rng, ssl->conf->p_rng); in ssl_write_ecjpake_kkpp_ext()
1979 static void ssl_write_use_srtp_ext(mbedtls_ssl_context *ssl, in ssl_write_use_srtp_ext() argument
1985 const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_OUT_CONTENT_LEN; in ssl_write_use_srtp_ext()
1989 if ((ssl->conf->transport != MBEDTLS_SSL_TRANSPORT_DATAGRAM) || in ssl_write_use_srtp_ext()
1990 (ssl->dtls_srtp_info.chosen_dtls_srtp_profile == MBEDTLS_TLS_SRTP_UNSET)) { in ssl_write_use_srtp_ext()
1996 if (ssl->conf->dtls_srtp_mki_support == MBEDTLS_SSL_DTLS_SRTP_MKI_SUPPORTED) { in ssl_write_use_srtp_ext()
1997 mki_len = ssl->dtls_srtp_info.mki_len; in ssl_write_use_srtp_ext()
2026 ssl->dtls_srtp_info.chosen_dtls_srtp_profile); in ssl_write_use_srtp_ext()
2035 memcpy(&buf[9], ssl->dtls_srtp_info.mki_value, mki_len); in ssl_write_use_srtp_ext()
2043 static int ssl_write_hello_verify_request(mbedtls_ssl_context *ssl) in ssl_write_hello_verify_request() argument
2046 unsigned char *p = ssl->out_msg + 4; in ssl_write_hello_verify_request()
2060 mbedtls_ssl_write_version(p, ssl->conf->transport, ssl->tls_version); in ssl_write_hello_verify_request()
2065 if (ssl->conf->f_cookie_write == NULL) { in ssl_write_hello_verify_request()
2073 if ((ret = ssl->conf->f_cookie_write(ssl->conf->p_cookie, in ssl_write_hello_verify_request()
2074 &p, ssl->out_buf + MBEDTLS_SSL_OUT_BUFFER_LEN, in ssl_write_hello_verify_request()
2075 ssl->cli_id, ssl->cli_id_len)) != 0) { in ssl_write_hello_verify_request()
2084 ssl->out_msglen = p - ssl->out_msg; in ssl_write_hello_verify_request()
2085 ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; in ssl_write_hello_verify_request()
2086 ssl->out_msg[0] = MBEDTLS_SSL_HS_HELLO_VERIFY_REQUEST; in ssl_write_hello_verify_request()
2088 ssl->state = MBEDTLS_SSL_SERVER_HELLO_VERIFY_REQUEST_SENT; in ssl_write_hello_verify_request()
2090 if ((ret = mbedtls_ssl_write_handshake_msg(ssl)) != 0) { in ssl_write_hello_verify_request()
2096 if (ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && in ssl_write_hello_verify_request()
2097 (ret = mbedtls_ssl_flight_transmit(ssl)) != 0) { in ssl_write_hello_verify_request()
2109 static void ssl_handle_id_based_session_resumption(mbedtls_ssl_context *ssl) in ssl_handle_id_based_session_resumption() argument
2113 mbedtls_ssl_session * const session = ssl->session_negotiate; in ssl_handle_id_based_session_resumption()
2117 if (ssl->handshake->resume == 1) { in ssl_handle_id_based_session_resumption()
2123 if (ssl->conf->f_get_cache == NULL) { in ssl_handle_id_based_session_resumption()
2127 if (ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE) { in ssl_handle_id_based_session_resumption()
2134 ret = ssl->conf->f_get_cache(ssl->conf->p_cache, in ssl_handle_id_based_session_resumption()
2153 ssl->handshake->resume = 1; in ssl_handle_id_based_session_resumption()
2161 static int ssl_write_server_hello(mbedtls_ssl_context *ssl) in ssl_write_server_hello() argument
2173 if (ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && in ssl_write_server_hello()
2174 ssl->handshake->cookie_verify_result != 0) { in ssl_write_server_hello()
2178 return ssl_write_hello_verify_request(ssl); in ssl_write_server_hello()
2182 if (ssl->conf->f_rng == NULL) { in ssl_write_server_hello()
2194 buf = ssl->out_msg; in ssl_write_server_hello()
2197 mbedtls_ssl_write_version(p, ssl->conf->transport, ssl->tls_version); in ssl_write_server_hello()
2211 if ((ret = ssl->conf->f_rng(ssl->conf->p_rng, p, 4)) != 0) { in ssl_write_server_hello()
2218 if ((ret = ssl->conf->f_rng(ssl->conf->p_rng, p, 20)) != 0) { in ssl_write_server_hello()
2231 if (mbedtls_ssl_conf_is_tls13_enabled(ssl->conf)) { in ssl_write_server_hello()
2244 if ((ret = ssl->conf->f_rng(ssl->conf->p_rng, p, 8)) != 0) { in ssl_write_server_hello()
2250 memcpy(ssl->handshake->randbytes + 32, buf + 6, 32); in ssl_write_server_hello()
2254 ssl_handle_id_based_session_resumption(ssl); in ssl_write_server_hello()
2256 if (ssl->handshake->resume == 0) { in ssl_write_server_hello()
2261 ssl->state++; in ssl_write_server_hello()
2264 ssl->session_negotiate->start = mbedtls_time(NULL); in ssl_write_server_hello()
2268 if (ssl->handshake->new_session_ticket != 0) { in ssl_write_server_hello()
2269 ssl->session_negotiate->id_len = n = 0; in ssl_write_server_hello()
2270 memset(ssl->session_negotiate->id, 0, 32); in ssl_write_server_hello()
2274 ssl->session_negotiate->id_len = n = 32; in ssl_write_server_hello()
2275 if ((ret = ssl->conf->f_rng(ssl->conf->p_rng, ssl->session_negotiate->id, in ssl_write_server_hello()
2284 n = ssl->session_negotiate->id_len; in ssl_write_server_hello()
2285 ssl->state = MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC; in ssl_write_server_hello()
2287 if ((ret = mbedtls_ssl_derive_keys(ssl)) != 0) { in ssl_write_server_hello()
2301 *p++ = (unsigned char) ssl->session_negotiate->id_len; in ssl_write_server_hello()
2302 memcpy(p, ssl->session_negotiate->id, ssl->session_negotiate->id_len); in ssl_write_server_hello()
2303 p += ssl->session_negotiate->id_len; in ssl_write_server_hello()
2308 ssl->handshake->resume ? "a" : "no")); in ssl_write_server_hello()
2310 MBEDTLS_PUT_UINT16_BE(ssl->session_negotiate->ciphersuite, p, 0); in ssl_write_server_hello()
2315 … mbedtls_ssl_get_ciphersuite_name(ssl->session_negotiate->ciphersuite))); in ssl_write_server_hello()
2322 ssl_write_renegotiation_ext(ssl, p + 2 + ext_len, &olen); in ssl_write_server_hello()
2326 ssl_write_max_fragment_length_ext(ssl, p + 2 + ext_len, &olen); in ssl_write_server_hello()
2331 ssl_write_cid_ext(ssl, p + 2 + ext_len, &olen); in ssl_write_server_hello()
2336 ssl_write_encrypt_then_mac_ext(ssl, p + 2 + ext_len, &olen); in ssl_write_server_hello()
2341 ssl_write_extended_ms_ext(ssl, p + 2 + ext_len, &olen); in ssl_write_server_hello()
2346 ssl_write_session_ticket_ext(ssl, p + 2 + ext_len, &olen); in ssl_write_server_hello()
2354 mbedtls_ssl_ciphersuite_from_id(ssl->session_negotiate->ciphersuite); in ssl_write_server_hello()
2356 ssl_write_supported_point_formats_ext(ssl, p + 2 + ext_len, &olen); in ssl_write_server_hello()
2362 ssl_write_ecjpake_kkpp_ext(ssl, p + 2 + ext_len, &olen); in ssl_write_server_hello()
2368 if ((ret = mbedtls_ssl_write_alpn_ext(ssl, p + 2 + ext_len, end, &olen)) in ssl_write_server_hello()
2377 ssl_write_use_srtp_ext(ssl, p + 2 + ext_len, &olen); in ssl_write_server_hello()
2389 ssl->out_msglen = p - buf; in ssl_write_server_hello()
2390 ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; in ssl_write_server_hello()
2391 ssl->out_msg[0] = MBEDTLS_SSL_HS_SERVER_HELLO; in ssl_write_server_hello()
2393 ret = mbedtls_ssl_write_handshake_msg(ssl); in ssl_write_server_hello()
2402 static int ssl_write_certificate_request(mbedtls_ssl_context *ssl) in ssl_write_certificate_request() argument
2405 ssl->handshake->ciphersuite_info; in ssl_write_certificate_request()
2411 ssl->state++; in ssl_write_certificate_request()
2420 static int ssl_write_certificate_request(mbedtls_ssl_context *ssl) in ssl_write_certificate_request() argument
2424 ssl->handshake->ciphersuite_info; in ssl_write_certificate_request()
2428 const unsigned char * const end = ssl->out_msg + MBEDTLS_SSL_OUT_CONTENT_LEN; in ssl_write_certificate_request()
2434 ssl->state++; in ssl_write_certificate_request()
2437 if (ssl->handshake->sni_authmode != MBEDTLS_SSL_VERIFY_UNSET) { in ssl_write_certificate_request()
2438 authmode = ssl->handshake->sni_authmode; in ssl_write_certificate_request()
2441 authmode = ssl->conf->authmode; in ssl_write_certificate_request()
2461 buf = ssl->out_msg; in ssl_write_certificate_request()
2497 const uint16_t *sig_alg = mbedtls_ssl_get_sig_algs(ssl); in ssl_write_certificate_request()
2505 if (mbedtls_ssl_set_calc_verify_md(ssl, hash)) { in ssl_write_certificate_request()
2508 if (!mbedtls_ssl_sig_alg_is_supported(ssl, *sig_alg)) { in ssl_write_certificate_request()
2533 if (ssl->conf->cert_req_ca_list == MBEDTLS_SSL_CERT_REQ_CA_LIST_ENABLED) { in ssl_write_certificate_request()
2541 if (ssl->handshake->dn_hints != NULL) { in ssl_write_certificate_request()
2542 crt = ssl->handshake->dn_hints; in ssl_write_certificate_request()
2545 if (ssl->conf->dn_hints != NULL) { in ssl_write_certificate_request()
2546 crt = ssl->conf->dn_hints; in ssl_write_certificate_request()
2550 if (ssl->handshake->sni_ca_chain != NULL) { in ssl_write_certificate_request()
2551 crt = ssl->handshake->sni_ca_chain; in ssl_write_certificate_request()
2554 crt = ssl->conf->ca_chain; in ssl_write_certificate_request()
2578 ssl->out_msglen = p - buf; in ssl_write_certificate_request()
2579 ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; in ssl_write_certificate_request()
2580 ssl->out_msg[0] = MBEDTLS_SSL_HS_CERTIFICATE_REQUEST; in ssl_write_certificate_request()
2581 MBEDTLS_PUT_UINT16_BE(total_dn_size, ssl->out_msg, 4 + ct_len + sa_len); in ssl_write_certificate_request()
2583 ret = mbedtls_ssl_write_handshake_msg(ssl); in ssl_write_certificate_request()
2595 static int ssl_get_ecdh_params_from_cert(mbedtls_ssl_context *ssl) in ssl_get_ecdh_params_from_cert() argument
2611 pk = mbedtls_ssl_own_key(ssl); in ssl_get_ecdh_params_from_cert()
2630 ssl->handshake->xxdh_psa_privkey = pk->priv_id; in ssl_get_ecdh_params_from_cert()
2633 ssl->handshake->xxdh_psa_privkey_is_external = 1; in ssl_get_ecdh_params_from_cert()
2635 status = psa_get_key_attributes(ssl->handshake->xxdh_psa_privkey, in ssl_get_ecdh_params_from_cert()
2638 ssl->handshake->xxdh_psa_privkey = MBEDTLS_SVC_KEY_ID_INIT; in ssl_get_ecdh_params_from_cert()
2642 ssl->handshake->xxdh_psa_type = psa_get_key_type(&key_attributes); in ssl_get_ecdh_params_from_cert()
2643 ssl->handshake->xxdh_psa_bits = psa_get_key_bits(&key_attributes); in ssl_get_ecdh_params_from_cert()
2667 &ssl->handshake->xxdh_psa_bits); in ssl_get_ecdh_params_from_cert()
2669 ssl->handshake->xxdh_psa_type = key_type; in ssl_get_ecdh_params_from_cert()
2675 PSA_KEY_TYPE_ECC_KEY_PAIR(ssl->handshake->xxdh_psa_type)); in ssl_get_ecdh_params_from_cert()
2676 psa_set_key_bits(&key_attributes, ssl->handshake->xxdh_psa_bits); in ssl_get_ecdh_params_from_cert()
2686 &ssl->handshake->xxdh_psa_privkey); in ssl_get_ecdh_params_from_cert()
2706 static int ssl_get_ecdh_params_from_cert(mbedtls_ssl_context *ssl) in ssl_get_ecdh_params_from_cert() argument
2710 const mbedtls_pk_context *private_key = mbedtls_ssl_own_key(ssl); in ssl_get_ecdh_params_from_cert()
2721 if ((ret = mbedtls_ecdh_get_params(&ssl->handshake->ecdh_ctx, in ssl_get_ecdh_params_from_cert()
2722 mbedtls_pk_ec_ro(*mbedtls_ssl_own_key(ssl)), in ssl_get_ecdh_params_from_cert()
2736 static int ssl_resume_server_key_exchange(mbedtls_ssl_context *ssl, in ssl_resume_server_key_exchange() argument
2744 unsigned char *sig_start = ssl->out_msg + ssl->out_msglen + 2; in ssl_resume_server_key_exchange()
2745 size_t sig_max_len = (ssl->out_buf + MBEDTLS_SSL_OUT_CONTENT_LEN in ssl_resume_server_key_exchange()
2747 int ret = ssl->conf->f_async_resume(ssl, in ssl_resume_server_key_exchange()
2750 ssl->handshake->async_in_progress = 0; in ssl_resume_server_key_exchange()
2751 mbedtls_ssl_set_async_operation_data(ssl, NULL); in ssl_resume_server_key_exchange()
2763 static int ssl_prepare_server_key_exchange(mbedtls_ssl_context *ssl, in ssl_prepare_server_key_exchange() argument
2767 ssl->handshake->ciphersuite_info; in ssl_prepare_server_key_exchange()
2782 size_t out_buf_len = ssl->out_buf_len - (ssl->out_msg - ssl->out_buf); in ssl_prepare_server_key_exchange()
2784 size_t out_buf_len = MBEDTLS_SSL_OUT_BUFFER_LEN - (ssl->out_msg - ssl->out_buf); in ssl_prepare_server_key_exchange()
2788 ssl->out_msglen = 4; /* header (type:1, length:3) to be written later */ in ssl_prepare_server_key_exchange()
2803 unsigned char *out_p = ssl->out_msg + ssl->out_msglen; in ssl_prepare_server_key_exchange()
2804 unsigned char *end_p = ssl->out_msg + MBEDTLS_SSL_OUT_CONTENT_LEN - in ssl_prepare_server_key_exchange()
2805 ssl->out_msglen; in ssl_prepare_server_key_exchange()
2826 ret = mbedtls_psa_ecjpake_write_round(&ssl->handshake->psa_pake_ctx, in ssl_prepare_server_key_exchange()
2831 psa_destroy_key(ssl->handshake->psa_pake_password); in ssl_prepare_server_key_exchange()
2832 psa_pake_abort(&ssl->handshake->psa_pake_ctx); in ssl_prepare_server_key_exchange()
2838 ssl->out_msglen += output_offset; in ssl_prepare_server_key_exchange()
2843 &ssl->handshake->ecjpake_ctx, in ssl_prepare_server_key_exchange()
2844 ssl->out_msg + ssl->out_msglen, in ssl_prepare_server_key_exchange()
2845 MBEDTLS_SSL_OUT_CONTENT_LEN - ssl->out_msglen, &len, in ssl_prepare_server_key_exchange()
2846 ssl->conf->f_rng, ssl->conf->p_rng); in ssl_prepare_server_key_exchange()
2852 ssl->out_msglen += len; in ssl_prepare_server_key_exchange()
2866 ssl->out_msg[ssl->out_msglen++] = 0x00; in ssl_prepare_server_key_exchange()
2867 ssl->out_msg[ssl->out_msglen++] = 0x00; in ssl_prepare_server_key_exchange()
2880 if (ssl->conf->dhm_P.p == NULL || ssl->conf->dhm_G.p == NULL) { in ssl_prepare_server_key_exchange()
2894 if ((ret = mbedtls_dhm_set_group(&ssl->handshake->dhm_ctx, in ssl_prepare_server_key_exchange()
2895 &ssl->conf->dhm_P, in ssl_prepare_server_key_exchange()
2896 &ssl->conf->dhm_G)) != 0) { in ssl_prepare_server_key_exchange()
2902 &ssl->handshake->dhm_ctx, in ssl_prepare_server_key_exchange()
2903 (int) mbedtls_dhm_get_len(&ssl->handshake->dhm_ctx), in ssl_prepare_server_key_exchange()
2904 ssl->out_msg + ssl->out_msglen, &len, in ssl_prepare_server_key_exchange()
2905 ssl->conf->f_rng, ssl->conf->p_rng)) != 0) { in ssl_prepare_server_key_exchange()
2911 dig_signed = ssl->out_msg + ssl->out_msglen; in ssl_prepare_server_key_exchange()
2914 ssl->out_msglen += len; in ssl_prepare_server_key_exchange()
2916 MBEDTLS_SSL_DEBUG_MPI(3, "DHM: X ", &ssl->handshake->dhm_ctx.X); in ssl_prepare_server_key_exchange()
2917 MBEDTLS_SSL_DEBUG_MPI(3, "DHM: P ", &ssl->handshake->dhm_ctx.P); in ssl_prepare_server_key_exchange()
2918 MBEDTLS_SSL_DEBUG_MPI(3, "DHM: G ", &ssl->handshake->dhm_ctx.G); in ssl_prepare_server_key_exchange()
2919 MBEDTLS_SSL_DEBUG_MPI(3, "DHM: GX", &ssl->handshake->dhm_ctx.GX); in ssl_prepare_server_key_exchange()
2936 uint16_t *curr_tls_id = ssl->handshake->curves_tls_id; in ssl_prepare_server_key_exchange()
2937 const uint16_t *group_list = mbedtls_ssl_get_groups(ssl); in ssl_prepare_server_key_exchange()
2946 for (curr_tls_id = ssl->handshake->curves_tls_id; in ssl_prepare_server_key_exchange()
2966 mbedtls_ssl_handshake_params *handshake = ssl->handshake; in ssl_prepare_server_key_exchange()
2967 uint8_t *p = ssl->out_msg + ssl->out_msglen; in ssl_prepare_server_key_exchange()
3027 - (own_pubkey - ssl->out_msg)); in ssl_prepare_server_key_exchange()
3049 if ((ret = mbedtls_ecdh_setup(&ssl->handshake->ecdh_ctx, in ssl_prepare_server_key_exchange()
3056 &ssl->handshake->ecdh_ctx, &len, in ssl_prepare_server_key_exchange()
3057 ssl->out_msg + ssl->out_msglen, in ssl_prepare_server_key_exchange()
3058 MBEDTLS_SSL_OUT_CONTENT_LEN - ssl->out_msglen, in ssl_prepare_server_key_exchange()
3059 ssl->conf->f_rng, ssl->conf->p_rng)) != 0) { in ssl_prepare_server_key_exchange()
3064 MBEDTLS_SSL_DEBUG_ECDH(3, &ssl->handshake->ecdh_ctx, in ssl_prepare_server_key_exchange()
3069 dig_signed = ssl->out_msg + ssl->out_msglen; in ssl_prepare_server_key_exchange()
3072 ssl->out_msglen += len; in ssl_prepare_server_key_exchange()
3089 size_t dig_signed_len = ssl->out_msg + ssl->out_msglen - dig_signed; in ssl_prepare_server_key_exchange()
3106 ssl, mbedtls_ssl_sig_from_pk_alg(sig_alg)); in ssl_prepare_server_key_exchange()
3125 ret = mbedtls_ssl_get_key_exchange_md_tls1_2(ssl, hash, &hashlen, in ssl_prepare_server_key_exchange()
3158 ssl->out_msg[ssl->out_msglen++] = mbedtls_ssl_hash_from_md_alg(md_alg); in ssl_prepare_server_key_exchange()
3159 ssl->out_msg[ssl->out_msglen++] = mbedtls_ssl_sig_from_pk_alg(sig_alg); in ssl_prepare_server_key_exchange()
3162 if (ssl->conf->f_async_sign_start != NULL) { in ssl_prepare_server_key_exchange()
3163 ret = ssl->conf->f_async_sign_start(ssl, in ssl_prepare_server_key_exchange()
3164 mbedtls_ssl_own_cert(ssl), in ssl_prepare_server_key_exchange()
3171 ssl->handshake->async_in_progress = 1; in ssl_prepare_server_key_exchange()
3172 return ssl_resume_server_key_exchange(ssl, signature_len); in ssl_prepare_server_key_exchange()
3174 ssl->handshake->async_in_progress = 1; in ssl_prepare_server_key_exchange()
3183 if (mbedtls_ssl_own_key(ssl) == NULL) { in ssl_prepare_server_key_exchange()
3193 if ((ret = mbedtls_pk_sign(mbedtls_ssl_own_key(ssl), in ssl_prepare_server_key_exchange()
3195 ssl->out_msg + ssl->out_msglen + 2, in ssl_prepare_server_key_exchange()
3196 out_buf_len - ssl->out_msglen - 2, in ssl_prepare_server_key_exchange()
3198 ssl->conf->f_rng, in ssl_prepare_server_key_exchange()
3199 ssl->conf->p_rng)) != 0) { in ssl_prepare_server_key_exchange()
3214 static int ssl_write_server_key_exchange(mbedtls_ssl_context *ssl) in ssl_write_server_key_exchange() argument
3220 ssl->handshake->ciphersuite_info; in ssl_write_server_key_exchange()
3233 ret = ssl_get_ecdh_params_from_cert(ssl); in ssl_write_server_key_exchange()
3244 ssl->state++; in ssl_write_server_key_exchange()
3253 if (ssl->handshake->async_in_progress != 0) { in ssl_write_server_key_exchange()
3255 ret = ssl_resume_server_key_exchange(ssl, &signature_len); in ssl_write_server_key_exchange()
3261 ret = ssl_prepare_server_key_exchange(ssl, &signature_len); in ssl_write_server_key_exchange()
3272 ssl->out_msglen = 0; in ssl_write_server_key_exchange()
3282 ssl->out_msg[ssl->out_msglen++] = MBEDTLS_BYTE_1(signature_len); in ssl_write_server_key_exchange()
3283 ssl->out_msg[ssl->out_msglen++] = MBEDTLS_BYTE_0(signature_len); in ssl_write_server_key_exchange()
3286 ssl->out_msg + ssl->out_msglen, in ssl_write_server_key_exchange()
3290 ssl->out_msglen += signature_len; in ssl_write_server_key_exchange()
3295 ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; in ssl_write_server_key_exchange()
3296 ssl->out_msg[0] = MBEDTLS_SSL_HS_SERVER_KEY_EXCHANGE; in ssl_write_server_key_exchange()
3298 ssl->state++; in ssl_write_server_key_exchange()
3300 if ((ret = mbedtls_ssl_write_handshake_msg(ssl)) != 0) { in ssl_write_server_key_exchange()
3310 static int ssl_write_server_hello_done(mbedtls_ssl_context *ssl) in ssl_write_server_hello_done() argument
3316 ssl->out_msglen = 4; in ssl_write_server_hello_done()
3317 ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; in ssl_write_server_hello_done()
3318 ssl->out_msg[0] = MBEDTLS_SSL_HS_SERVER_HELLO_DONE; in ssl_write_server_hello_done()
3320 ssl->state++; in ssl_write_server_hello_done()
3323 if (ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM) { in ssl_write_server_hello_done()
3324 mbedtls_ssl_send_flight_completed(ssl); in ssl_write_server_hello_done()
3328 if ((ret = mbedtls_ssl_write_handshake_msg(ssl)) != 0) { in ssl_write_server_hello_done()
3334 if (ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && in ssl_write_server_hello_done()
3335 (ret = mbedtls_ssl_flight_transmit(ssl)) != 0) { in ssl_write_server_hello_done()
3349 static int ssl_parse_client_dh_public(mbedtls_ssl_context *ssl, unsigned char **p, in ssl_parse_client_dh_public() argument
3371 if ((ret = mbedtls_dhm_read_public(&ssl->handshake->dhm_ctx, *p, n)) != 0) { in ssl_parse_client_dh_public()
3378 MBEDTLS_SSL_DEBUG_MPI(3, "DHM: GY", &ssl->handshake->dhm_ctx.GY); in ssl_parse_client_dh_public()
3390 static int ssl_resume_decrypt_pms(mbedtls_ssl_context *ssl, in ssl_resume_decrypt_pms() argument
3395 int ret = ssl->conf->f_async_resume(ssl, in ssl_resume_decrypt_pms()
3398 ssl->handshake->async_in_progress = 0; in ssl_resume_decrypt_pms()
3399 mbedtls_ssl_set_async_operation_data(ssl, NULL); in ssl_resume_decrypt_pms()
3407 static int ssl_decrypt_encrypted_pms(mbedtls_ssl_context *ssl, in ssl_decrypt_encrypted_pms() argument
3416 mbedtls_x509_crt *own_cert = mbedtls_ssl_own_cert(ssl); in ssl_decrypt_encrypted_pms()
3422 mbedtls_pk_context *private_key = mbedtls_ssl_own_key(ssl); in ssl_decrypt_encrypted_pms()
3428 if (ssl->handshake->async_in_progress != 0) { in ssl_decrypt_encrypted_pms()
3430 return ssl_resume_decrypt_pms(ssl, in ssl_decrypt_encrypted_pms()
3457 if (ssl->conf->f_async_decrypt_start != NULL) { in ssl_decrypt_encrypted_pms()
3458 ret = ssl->conf->f_async_decrypt_start(ssl, in ssl_decrypt_encrypted_pms()
3459 mbedtls_ssl_own_cert(ssl), in ssl_decrypt_encrypted_pms()
3466 ssl->handshake->async_in_progress = 1; in ssl_decrypt_encrypted_pms()
3467 return ssl_resume_decrypt_pms(ssl, in ssl_decrypt_encrypted_pms()
3472 ssl->handshake->async_in_progress = 1; in ssl_decrypt_encrypted_pms()
3488 ssl->conf->f_rng, ssl->conf->p_rng); in ssl_decrypt_encrypted_pms()
3493 static int ssl_parse_encrypted_pms(mbedtls_ssl_context *ssl, in ssl_parse_encrypted_pms() argument
3499 unsigned char *pms = ssl->handshake->premaster + pms_offset; in ssl_parse_encrypted_pms()
3515 ret = ssl_decrypt_encrypted_pms(ssl, p, end, in ssl_parse_encrypted_pms()
3526 mbedtls_ssl_write_version(ver, ssl->conf->transport, in ssl_parse_encrypted_pms()
3527 ssl->session_negotiate->tls_version); in ssl_parse_encrypted_pms()
3546 ret = ssl->conf->f_rng(ssl->conf->p_rng, fake_pms, sizeof(fake_pms)); in ssl_parse_encrypted_pms()
3559 if (sizeof(ssl->handshake->premaster) < pms_offset || in ssl_parse_encrypted_pms()
3560 sizeof(ssl->handshake->premaster) - pms_offset < 48) { in ssl_parse_encrypted_pms()
3564 ssl->handshake->pmslen = 48; in ssl_parse_encrypted_pms()
3568 mbedtls_ct_memcpy_if(diff, pms, fake_pms, peer_pms, ssl->handshake->pmslen); in ssl_parse_encrypted_pms()
3577 static int ssl_parse_client_psk_identity(mbedtls_ssl_context *ssl, unsigned char **p, in ssl_parse_client_psk_identity() argument
3583 if (ssl_conf_has_psk_or_cb(ssl->conf) == 0) { in ssl_parse_client_psk_identity()
3604 if (ssl->conf->f_psk != NULL) { in ssl_parse_client_psk_identity()
3605 if (ssl->conf->f_psk(ssl->conf->p_psk, ssl, *p, n) != 0) { in ssl_parse_client_psk_identity()
3611 if (n != ssl->conf->psk_identity_len || in ssl_parse_client_psk_identity()
3612 mbedtls_ct_memcmp(ssl->conf->psk_identity, *p, n) != 0) { in ssl_parse_client_psk_identity()
3619 mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, in ssl_parse_client_psk_identity()
3631 static int ssl_parse_client_key_exchange(mbedtls_ssl_context *ssl) in ssl_parse_client_key_exchange() argument
3637 ciphersuite_info = ssl->handshake->ciphersuite_info; in ssl_parse_client_key_exchange()
3646 (ssl->handshake->async_in_progress != 0)) { in ssl_parse_client_key_exchange()
3653 if ((ret = mbedtls_ssl_read_record(ssl, 1)) != 0) { in ssl_parse_client_key_exchange()
3658 p = ssl->in_msg + mbedtls_ssl_hs_hdr_len(ssl); in ssl_parse_client_key_exchange()
3659 end = ssl->in_msg + ssl->in_hslen; in ssl_parse_client_key_exchange()
3661 if (ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE) { in ssl_parse_client_key_exchange()
3666 if (ssl->in_msg[0] != MBEDTLS_SSL_HS_CLIENT_KEY_EXCHANGE) { in ssl_parse_client_key_exchange()
3673 if ((ret = ssl_parse_client_dh_public(ssl, &p, end)) != 0) { in ssl_parse_client_key_exchange()
3683 if ((ret = mbedtls_dhm_calc_secret(&ssl->handshake->dhm_ctx, in ssl_parse_client_key_exchange()
3684 ssl->handshake->premaster, in ssl_parse_client_key_exchange()
3686 &ssl->handshake->pmslen, in ssl_parse_client_key_exchange()
3687 ssl->conf->f_rng, ssl->conf->p_rng)) != 0) { in ssl_parse_client_key_exchange()
3692 MBEDTLS_SSL_DEBUG_MPI(3, "DHM: K ", &ssl->handshake->dhm_ctx.K); in ssl_parse_client_key_exchange()
3707 mbedtls_ssl_handshake_params *handshake = ssl->handshake; in ssl_parse_client_key_exchange()
3765 if ((ret = mbedtls_ecdh_read_public(&ssl->handshake->ecdh_ctx, in ssl_parse_client_key_exchange()
3771 MBEDTLS_SSL_DEBUG_ECDH(3, &ssl->handshake->ecdh_ctx, in ssl_parse_client_key_exchange()
3774 if ((ret = mbedtls_ecdh_calc_secret(&ssl->handshake->ecdh_ctx, in ssl_parse_client_key_exchange()
3775 &ssl->handshake->pmslen, in ssl_parse_client_key_exchange()
3776 ssl->handshake->premaster, in ssl_parse_client_key_exchange()
3778 ssl->conf->f_rng, ssl->conf->p_rng)) != 0) { in ssl_parse_client_key_exchange()
3783 MBEDTLS_SSL_DEBUG_ECDH(3, &ssl->handshake->ecdh_ctx, in ssl_parse_client_key_exchange()
3793 if ((ret = ssl_parse_client_psk_identity(ssl, &p, end)) != 0) { in ssl_parse_client_key_exchange()
3804 if ((ret = mbedtls_ssl_psk_derive_premaster(ssl, in ssl_parse_client_key_exchange()
3816 if (ssl->handshake->async_in_progress != 0) { in ssl_parse_client_key_exchange()
3823 p += ssl->conf->psk_identity_len + 2; in ssl_parse_client_key_exchange()
3826 if ((ret = ssl_parse_client_psk_identity(ssl, &p, end)) != 0) { in ssl_parse_client_key_exchange()
3831 if ((ret = ssl_parse_encrypted_pms(ssl, p, end, 2)) != 0) { in ssl_parse_client_key_exchange()
3837 if ((ret = mbedtls_ssl_psk_derive_premaster(ssl, in ssl_parse_client_key_exchange()
3848 if ((ret = ssl_parse_client_psk_identity(ssl, &p, end)) != 0) { in ssl_parse_client_key_exchange()
3852 if ((ret = ssl_parse_client_dh_public(ssl, &p, end)) != 0) { in ssl_parse_client_key_exchange()
3863 unsigned char *pms = ssl->handshake->premaster; in ssl_parse_client_key_exchange()
3864 unsigned char *pms_end = pms + sizeof(ssl->handshake->premaster); in ssl_parse_client_key_exchange()
3868 if ((ret = mbedtls_dhm_calc_secret(&ssl->handshake->dhm_ctx, in ssl_parse_client_key_exchange()
3870 ssl->conf->f_rng, ssl->conf->p_rng)) != 0) { in ssl_parse_client_key_exchange()
3877 MBEDTLS_SSL_DEBUG_MPI(3, "DHM: K ", &ssl->handshake->dhm_ctx.K); in ssl_parse_client_key_exchange()
3879 if ((ret = mbedtls_ssl_psk_derive_premaster(ssl, in ssl_parse_client_key_exchange()
3895 mbedtls_ssl_handshake_params *handshake = ssl->handshake; in ssl_parse_client_key_exchange()
3897 if ((ret = ssl_parse_client_psk_identity(ssl, &p, end)) != 0) { in ssl_parse_client_key_exchange()
3943 unsigned char *psm = ssl->handshake->premaster; in ssl_parse_client_key_exchange()
3945 psm + sizeof(ssl->handshake->premaster); in ssl_parse_client_key_exchange()
3973 if ((ret = ssl_parse_client_psk_identity(ssl, &p, end)) != 0) { in ssl_parse_client_key_exchange()
3978 if ((ret = mbedtls_ecdh_read_public(&ssl->handshake->ecdh_ctx, in ssl_parse_client_key_exchange()
3984 MBEDTLS_SSL_DEBUG_ECDH(3, &ssl->handshake->ecdh_ctx, in ssl_parse_client_key_exchange()
3987 if ((ret = mbedtls_ssl_psk_derive_premaster(ssl, in ssl_parse_client_key_exchange()
3998 if ((ret = ssl_parse_encrypted_pms(ssl, p, end, 0)) != 0) { in ssl_parse_client_key_exchange()
4008 &ssl->handshake->psa_pake_ctx, p, end - p, in ssl_parse_client_key_exchange()
4010 psa_destroy_key(ssl->handshake->psa_pake_password); in ssl_parse_client_key_exchange()
4011 psa_pake_abort(&ssl->handshake->psa_pake_ctx); in ssl_parse_client_key_exchange()
4017 ret = mbedtls_ecjpake_read_round_two(&ssl->handshake->ecjpake_ctx, in ssl_parse_client_key_exchange()
4024 ret = mbedtls_ecjpake_derive_secret(&ssl->handshake->ecjpake_ctx, in ssl_parse_client_key_exchange()
4025 ssl->handshake->premaster, 32, &ssl->handshake->pmslen, in ssl_parse_client_key_exchange()
4026 ssl->conf->f_rng, ssl->conf->p_rng); in ssl_parse_client_key_exchange()
4039 if ((ret = mbedtls_ssl_derive_keys(ssl)) != 0) { in ssl_parse_client_key_exchange()
4044 ssl->state++; in ssl_parse_client_key_exchange()
4053 static int ssl_parse_certificate_verify(mbedtls_ssl_context *ssl) in ssl_parse_certificate_verify() argument
4056 ssl->handshake->ciphersuite_info; in ssl_parse_certificate_verify()
4062 ssl->state++; in ssl_parse_certificate_verify()
4071 static int ssl_parse_certificate_verify(mbedtls_ssl_context *ssl) in ssl_parse_certificate_verify() argument
4081 ssl->handshake->ciphersuite_info; in ssl_parse_certificate_verify()
4088 ssl->state++; in ssl_parse_certificate_verify()
4093 if (ssl->session_negotiate->peer_cert == NULL) { in ssl_parse_certificate_verify()
4095 ssl->state++; in ssl_parse_certificate_verify()
4099 if (ssl->session_negotiate->peer_cert_digest == NULL) { in ssl_parse_certificate_verify()
4101 ssl->state++; in ssl_parse_certificate_verify()
4107 ret = mbedtls_ssl_read_record(ssl, 0 /* no checksum update */); in ssl_parse_certificate_verify()
4113 ssl->state++; in ssl_parse_certificate_verify()
4116 if (ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE || in ssl_parse_certificate_verify()
4117 ssl->in_msg[0] != MBEDTLS_SSL_HS_CERTIFICATE_VERIFY) { in ssl_parse_certificate_verify()
4122 i = mbedtls_ssl_hs_hdr_len(ssl); in ssl_parse_certificate_verify()
4125 peer_pk = &ssl->handshake->peer_pubkey; in ssl_parse_certificate_verify()
4127 if (ssl->session_negotiate->peer_cert == NULL) { in ssl_parse_certificate_verify()
4131 peer_pk = &ssl->session_negotiate->peer_cert->pk; in ssl_parse_certificate_verify()
4140 if (i + 2 > ssl->in_hslen) { in ssl_parse_certificate_verify()
4148 md_alg = mbedtls_ssl_md_alg_from_hash(ssl->in_msg[i]); in ssl_parse_certificate_verify()
4150 if (md_alg == MBEDTLS_MD_NONE || mbedtls_ssl_set_calc_verify_md(ssl, ssl->in_msg[i])) { in ssl_parse_certificate_verify()
4170 if ((pk_alg = mbedtls_ssl_pk_alg_from_sig(ssl->in_msg[i])) in ssl_parse_certificate_verify()
4187 if (i + 2 > ssl->in_hslen) { in ssl_parse_certificate_verify()
4192 sig_len = (ssl->in_msg[i] << 8) | ssl->in_msg[i+1]; in ssl_parse_certificate_verify()
4195 if (i + sig_len != ssl->in_hslen) { in ssl_parse_certificate_verify()
4203 ret = ssl->handshake->calc_verify(ssl, hash, &dummy_hlen); in ssl_parse_certificate_verify()
4212 ssl->in_msg + i, sig_len)) != 0) { in ssl_parse_certificate_verify()
4217 ret = mbedtls_ssl_update_handshake_status(ssl); in ssl_parse_certificate_verify()
4231 static int ssl_write_new_session_ticket(mbedtls_ssl_context *ssl) in ssl_write_new_session_ticket() argument
4239 ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; in ssl_write_new_session_ticket()
4240 ssl->out_msg[0] = MBEDTLS_SSL_HS_NEW_SESSION_TICKET; in ssl_write_new_session_ticket()
4253 if ((ret = ssl->conf->f_ticket_write(ssl->conf->p_ticket, in ssl_write_new_session_ticket()
4254 ssl->session_negotiate, in ssl_write_new_session_ticket()
4255 ssl->out_msg + 10, in ssl_write_new_session_ticket()
4256 ssl->out_msg + MBEDTLS_SSL_OUT_CONTENT_LEN, in ssl_write_new_session_ticket()
4262 MBEDTLS_PUT_UINT32_BE(lifetime, ssl->out_msg, 4); in ssl_write_new_session_ticket()
4263 MBEDTLS_PUT_UINT16_BE(tlen, ssl->out_msg, 8); in ssl_write_new_session_ticket()
4264 ssl->out_msglen = 10 + tlen; in ssl_write_new_session_ticket()
4270 ssl->handshake->new_session_ticket = 0; in ssl_write_new_session_ticket()
4272 if ((ret = mbedtls_ssl_write_handshake_msg(ssl)) != 0) { in ssl_write_new_session_ticket()
4286 int mbedtls_ssl_handshake_server_step(mbedtls_ssl_context *ssl) in mbedtls_ssl_handshake_server_step() argument
4290 MBEDTLS_SSL_DEBUG_MSG(2, ("server state: %d", ssl->state)); in mbedtls_ssl_handshake_server_step()
4292 switch (ssl->state) { in mbedtls_ssl_handshake_server_step()
4294 ssl->state = MBEDTLS_SSL_CLIENT_HELLO; in mbedtls_ssl_handshake_server_step()
4301 ret = ssl_parse_client_hello(ssl); in mbedtls_ssl_handshake_server_step()
4317 ret = ssl_write_server_hello(ssl); in mbedtls_ssl_handshake_server_step()
4321 ret = mbedtls_ssl_write_certificate(ssl); in mbedtls_ssl_handshake_server_step()
4325 ret = ssl_write_server_key_exchange(ssl); in mbedtls_ssl_handshake_server_step()
4329 ret = ssl_write_certificate_request(ssl); in mbedtls_ssl_handshake_server_step()
4333 ret = ssl_write_server_hello_done(ssl); in mbedtls_ssl_handshake_server_step()
4344 ret = mbedtls_ssl_parse_certificate(ssl); in mbedtls_ssl_handshake_server_step()
4348 ret = ssl_parse_client_key_exchange(ssl); in mbedtls_ssl_handshake_server_step()
4352 ret = ssl_parse_certificate_verify(ssl); in mbedtls_ssl_handshake_server_step()
4356 ret = mbedtls_ssl_parse_change_cipher_spec(ssl); in mbedtls_ssl_handshake_server_step()
4360 ret = mbedtls_ssl_parse_finished(ssl); in mbedtls_ssl_handshake_server_step()
4370 if (ssl->handshake->new_session_ticket != 0) { in mbedtls_ssl_handshake_server_step()
4371 ret = ssl_write_new_session_ticket(ssl); in mbedtls_ssl_handshake_server_step()
4374 ret = mbedtls_ssl_write_change_cipher_spec(ssl); in mbedtls_ssl_handshake_server_step()
4378 ret = mbedtls_ssl_write_finished(ssl); in mbedtls_ssl_handshake_server_step()
4383 ssl->state = MBEDTLS_SSL_HANDSHAKE_WRAPUP; in mbedtls_ssl_handshake_server_step()
4387 mbedtls_ssl_handshake_wrapup(ssl); in mbedtls_ssl_handshake_server_step()
4391 MBEDTLS_SSL_DEBUG_MSG(1, ("invalid state %d", ssl->state)); in mbedtls_ssl_handshake_server_step()