Lines Matching refs:p
85 const unsigned char *p; in ssl_parse_servername_ext() local
105 p = buf + 2; in ssl_parse_servername_ext()
108 hostname_len = ( ( p[1] << 8 ) | p[2] ); in ssl_parse_servername_ext()
117 if( p[0] == MBEDTLS_TLS_EXT_SERVERNAME_HOSTNAME ) in ssl_parse_servername_ext()
120 ssl, p + 3, hostname_len ); in ssl_parse_servername_ext()
132 p += hostname_len + 3; in ssl_parse_servername_ext()
246 const unsigned char *p; in ssl_parse_signature_algorithms_ext() local
277 for( p = buf + 2; p < end; p += 2 ) in ssl_parse_signature_algorithms_ext()
281 if( ( sig_cur = mbedtls_ssl_pk_alg_from_sig( p[1] ) ) == MBEDTLS_PK_NONE ) in ssl_parse_signature_algorithms_ext()
284 " unknown sig alg encoding %d", p[1] ) ); in ssl_parse_signature_algorithms_ext()
289 md_cur = mbedtls_ssl_md_alg_from_hash( p[0] ); in ssl_parse_signature_algorithms_ext()
293 " unknown hash alg encoding %d", p[0] ) ); in ssl_parse_signature_algorithms_ext()
323 const unsigned char *p; in ssl_parse_supported_elliptic_curves() local
366 p = buf + 2; in ssl_parse_supported_elliptic_curves()
369 curve_info = mbedtls_ecp_curve_info_from_tls_id( ( p[0] << 8 ) | p[1] ); in ssl_parse_supported_elliptic_curves()
378 p += 2; in ssl_parse_supported_elliptic_curves()
389 const unsigned char *p; in ssl_parse_supported_point_formats() local
400 p = buf + 1; in ssl_parse_supported_point_formats()
403 if( p[0] == MBEDTLS_ECP_PF_UNCOMPRESSED || in ssl_parse_supported_point_formats()
404 p[0] == MBEDTLS_ECP_PF_COMPRESSED ) in ssl_parse_supported_point_formats()
407 ssl->handshake->ecdh_ctx.point_format = p[0]; in ssl_parse_supported_point_formats()
411 p[0] ); in ssl_parse_supported_point_formats()
413 MBEDTLS_SSL_DEBUG_MSG( 4, ( "point format selected: %d", p[0] ) ); in ssl_parse_supported_point_formats()
418 p++; in ssl_parse_supported_point_formats()
1127 unsigned char *buf, *p, *ext; in ssl_parse_client_hello() local
1778 for( i = 0, p = buf + ciph_offset + 2; i < ciph_len; i += 2, p += 2 ) in ssl_parse_client_hello()
1780 if( p[0] == 0 && p[1] == MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO ) in ssl_parse_client_hello()
1849 for( j = 0, p = buf + ciph_offset + 2; j < ciph_len; j += 2, p += 2 ) in ssl_parse_client_hello()
1852 if( MBEDTLS_GET_UINT16_BE(p, 0) != ciphersuites[i] ) in ssl_parse_client_hello()
1866 for( j = 0, p = buf + ciph_offset + 2; j < ciph_len; j += 2, p += 2 ) in ssl_parse_client_hello()
1868 if( MBEDTLS_GET_UINT16_BE(p, 0) != ciphersuites[i] ) in ssl_parse_client_hello()
1943 unsigned char *p = buf; in ssl_write_cid_ext() local
1956 if( end < p || (size_t)( end - p ) < (unsigned)( ssl->own_cid_len + 5 ) ) in ssl_write_cid_ext()
1972 MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_CID, p, 0 ); in ssl_write_cid_ext()
1973 p += 2; in ssl_write_cid_ext()
1975 MBEDTLS_PUT_UINT16_BE( ext_len, p, 0 ); in ssl_write_cid_ext()
1976 p += 2; in ssl_write_cid_ext()
1978 *p++ = (uint8_t) ssl->own_cid_len; in ssl_write_cid_ext()
1979 memcpy( p, ssl->own_cid, ssl->own_cid_len ); in ssl_write_cid_ext()
1990 unsigned char *p = buf; in ssl_write_encrypt_then_mac_ext() local
2017 MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC, p, 0 ); in ssl_write_encrypt_then_mac_ext()
2018 p += 2; in ssl_write_encrypt_then_mac_ext()
2020 *p++ = 0x00; in ssl_write_encrypt_then_mac_ext()
2021 *p++ = 0x00; in ssl_write_encrypt_then_mac_ext()
2032 unsigned char *p = buf; in ssl_write_extended_ms_ext() local
2043 MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET, p, 0 ); in ssl_write_extended_ms_ext()
2044 p += 2; in ssl_write_extended_ms_ext()
2046 *p++ = 0x00; in ssl_write_extended_ms_ext()
2047 *p++ = 0x00; in ssl_write_extended_ms_ext()
2058 unsigned char *p = buf; in ssl_write_session_ticket_ext() local
2068 MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SESSION_TICKET, p, 0 ); in ssl_write_session_ticket_ext()
2069 p += 2; in ssl_write_session_ticket_ext()
2071 *p++ = 0x00; in ssl_write_session_ticket_ext()
2072 *p++ = 0x00; in ssl_write_session_ticket_ext()
2082 unsigned char *p = buf; in ssl_write_renegotiation_ext() local
2092 MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO, p, 0 ); in ssl_write_renegotiation_ext()
2093 p += 2; in ssl_write_renegotiation_ext()
2098 *p++ = 0x00; in ssl_write_renegotiation_ext()
2099 *p++ = ( ssl->verify_data_len * 2 + 1 ) & 0xFF; in ssl_write_renegotiation_ext()
2100 *p++ = ssl->verify_data_len * 2 & 0xFF; in ssl_write_renegotiation_ext()
2102 memcpy( p, ssl->peer_verify_data, ssl->verify_data_len ); in ssl_write_renegotiation_ext()
2103 p += ssl->verify_data_len; in ssl_write_renegotiation_ext()
2104 memcpy( p, ssl->own_verify_data, ssl->verify_data_len ); in ssl_write_renegotiation_ext()
2105 p += ssl->verify_data_len; in ssl_write_renegotiation_ext()
2110 *p++ = 0x00; in ssl_write_renegotiation_ext()
2111 *p++ = 0x01; in ssl_write_renegotiation_ext()
2112 *p++ = 0x00; in ssl_write_renegotiation_ext()
2115 *olen = p - buf; in ssl_write_renegotiation_ext()
2123 unsigned char *p = buf; in ssl_write_max_fragment_length_ext() local
2133 MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH, p, 0 ); in ssl_write_max_fragment_length_ext()
2134 p += 2; in ssl_write_max_fragment_length_ext()
2136 *p++ = 0x00; in ssl_write_max_fragment_length_ext()
2137 *p++ = 1; in ssl_write_max_fragment_length_ext()
2139 *p++ = ssl->session_negotiate->mfl_code; in ssl_write_max_fragment_length_ext()
2151 unsigned char *p = buf; in ssl_write_supported_point_formats_ext() local
2163 MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS, p, 0 ); in ssl_write_supported_point_formats_ext()
2164 p += 2; in ssl_write_supported_point_formats_ext()
2166 *p++ = 0x00; in ssl_write_supported_point_formats_ext()
2167 *p++ = 2; in ssl_write_supported_point_formats_ext()
2169 *p++ = 1; in ssl_write_supported_point_formats_ext()
2170 *p++ = MBEDTLS_ECP_PF_UNCOMPRESSED; in ssl_write_supported_point_formats_ext()
2182 unsigned char *p = buf; in ssl_write_ecjpake_kkpp_ext() local
2195 if( end - p < 4 ) in ssl_write_ecjpake_kkpp_ext()
2201 MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_ECJPAKE_KKPP, p, 0 ); in ssl_write_ecjpake_kkpp_ext()
2202 p += 2; in ssl_write_ecjpake_kkpp_ext()
2205 p + 2, end - p - 2, &kkpp_len, in ssl_write_ecjpake_kkpp_ext()
2213 MBEDTLS_PUT_UINT16_BE( kkpp_len, p, 0 ); in ssl_write_ecjpake_kkpp_ext()
2214 p += 2; in ssl_write_ecjpake_kkpp_ext()
2326 unsigned char *p = ssl->out_msg + 4; in ssl_write_hello_verify_request() local
2341 ssl->conf->transport, p ); in ssl_write_hello_verify_request()
2342 MBEDTLS_SSL_DEBUG_BUF( 3, "server version", p, 2 ); in ssl_write_hello_verify_request()
2343 p += 2; in ssl_write_hello_verify_request()
2353 cookie_len_byte = p++; in ssl_write_hello_verify_request()
2356 &p, ssl->out_buf + MBEDTLS_SSL_OUT_BUFFER_LEN, in ssl_write_hello_verify_request()
2363 *cookie_len_byte = (unsigned char)( p - ( cookie_len_byte + 1 ) ); in ssl_write_hello_verify_request()
2367 ssl->out_msglen = p - ssl->out_msg; in ssl_write_hello_verify_request()
2449 unsigned char *buf, *p; in ssl_write_server_hello() local
2478 p = buf + 4; in ssl_write_server_hello()
2481 ssl->conf->transport, p ); in ssl_write_server_hello()
2482 p += 2; in ssl_write_server_hello()
2489 MBEDTLS_PUT_UINT32_BE( t, p, 0 ); in ssl_write_server_hello()
2490 p += 4; in ssl_write_server_hello()
2495 if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, p, 4 ) ) != 0 ) in ssl_write_server_hello()
2498 p += 4; in ssl_write_server_hello()
2501 if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, p, 28 ) ) != 0 ) in ssl_write_server_hello()
2504 p += 28; in ssl_write_server_hello()
2562 *p++ = (unsigned char) ssl->session_negotiate->id_len; in ssl_write_server_hello()
2563 memcpy( p, ssl->session_negotiate->id, ssl->session_negotiate->id_len ); in ssl_write_server_hello()
2564 p += ssl->session_negotiate->id_len; in ssl_write_server_hello()
2571 MBEDTLS_PUT_UINT16_BE( ssl->session_negotiate->ciphersuite, p, 0 ); in ssl_write_server_hello()
2572 p += 2; in ssl_write_server_hello()
2573 *p++ = MBEDTLS_BYTE_0( ssl->session_negotiate->compression ); in ssl_write_server_hello()
2583 ssl_write_renegotiation_ext( ssl, p + 2 + ext_len, &olen ); in ssl_write_server_hello()
2587 ssl_write_max_fragment_length_ext( ssl, p + 2 + ext_len, &olen ); in ssl_write_server_hello()
2592 ssl_write_cid_ext( ssl, p + 2 + ext_len, &olen ); in ssl_write_server_hello()
2597 ssl_write_encrypt_then_mac_ext( ssl, p + 2 + ext_len, &olen ); in ssl_write_server_hello()
2602 ssl_write_extended_ms_ext( ssl, p + 2 + ext_len, &olen ); in ssl_write_server_hello()
2607 ssl_write_session_ticket_ext( ssl, p + 2 + ext_len, &olen ); in ssl_write_server_hello()
2616 ssl_write_supported_point_formats_ext( ssl, p + 2 + ext_len, &olen ); in ssl_write_server_hello()
2622 ssl_write_ecjpake_kkpp_ext( ssl, p + 2 + ext_len, &olen ); in ssl_write_server_hello()
2627 ssl_write_alpn_ext( ssl, p + 2 + ext_len, &olen ); in ssl_write_server_hello()
2632 ssl_write_use_srtp_ext( ssl, p + 2 + ext_len, &olen ); in ssl_write_server_hello()
2641 MBEDTLS_PUT_UINT16_BE( ext_len, p, 0 ); in ssl_write_server_hello()
2642 p += 2 + ext_len; in ssl_write_server_hello()
2645 ssl->out_msglen = p - buf; in ssl_write_server_hello()
2682 unsigned char *buf, *p; in ssl_write_certificate_request() local
2718 p = buf + 4; in ssl_write_certificate_request()
2729 p[1 + ct_len++] = MBEDTLS_SSL_CERT_TYPE_RSA_SIGN; in ssl_write_certificate_request()
2732 p[1 + ct_len++] = MBEDTLS_SSL_CERT_TYPE_ECDSA_SIGN; in ssl_write_certificate_request()
2735 p[0] = (unsigned char) ct_len++; in ssl_write_certificate_request()
2736 p += ct_len; in ssl_write_certificate_request()
2768 p[2 + sa_len++] = hash; in ssl_write_certificate_request()
2769 p[2 + sa_len++] = MBEDTLS_SSL_SIG_RSA; in ssl_write_certificate_request()
2772 p[2 + sa_len++] = hash; in ssl_write_certificate_request()
2773 p[2 + sa_len++] = MBEDTLS_SSL_SIG_ECDSA; in ssl_write_certificate_request()
2777 MBEDTLS_PUT_UINT16_BE( sa_len, p, 0 ); in ssl_write_certificate_request()
2779 p += sa_len; in ssl_write_certificate_request()
2787 p += 2; in ssl_write_certificate_request()
2811 if( end < p || (size_t)( end - p ) < 2 + (size_t) dn_size ) in ssl_write_certificate_request()
2817 MBEDTLS_PUT_UINT16_BE( dn_size, p, 0 ); in ssl_write_certificate_request()
2818 p += 2; in ssl_write_certificate_request()
2819 memcpy( p, crt->subject_raw.p, dn_size ); in ssl_write_certificate_request()
2820 p += dn_size; in ssl_write_certificate_request()
2822 MBEDTLS_SSL_DEBUG_BUF( 3, "requested DN", p - dn_size, dn_size ); in ssl_write_certificate_request()
2829 ssl->out_msglen = p - buf; in ssl_write_certificate_request()
2978 if( ssl->conf->dhm_P.p == NULL || ssl->conf->dhm_G.p == NULL ) in ssl_prepare_server_key_exchange()
3379 static int ssl_parse_client_dh_public( mbedtls_ssl_context *ssl, unsigned char **p, in ssl_parse_client_dh_public() argument
3388 if( *p + 2 > end ) in ssl_parse_client_dh_public()
3394 n = ( (*p)[0] << 8 ) | (*p)[1]; in ssl_parse_client_dh_public()
3395 *p += 2; in ssl_parse_client_dh_public()
3397 if( *p + n > end ) in ssl_parse_client_dh_public()
3403 if( ( ret = mbedtls_dhm_read_public( &ssl->handshake->dhm_ctx, *p, n ) ) != 0 ) in ssl_parse_client_dh_public()
3409 *p += n; in ssl_parse_client_dh_public()
3440 const unsigned char *p, in ssl_decrypt_encrypted_pms() argument
3466 if ( p + 2 > end ) { in ssl_decrypt_encrypted_pms()
3470 if( *p++ != MBEDTLS_BYTE_1( len ) || in ssl_decrypt_encrypted_pms()
3471 *p++ != MBEDTLS_BYTE_0( len ) ) in ssl_decrypt_encrypted_pms()
3478 if( p + len != end ) in ssl_decrypt_encrypted_pms()
3492 p, len ); in ssl_decrypt_encrypted_pms()
3520 ret = mbedtls_pk_decrypt( private_key, p, len, in ssl_decrypt_encrypted_pms()
3527 const unsigned char *p, in ssl_parse_encrypted_pms() argument
3549 ret = ssl_decrypt_encrypted_pms( ssl, p, end, in ssl_parse_encrypted_pms()
3624 static int ssl_parse_client_psk_identity( mbedtls_ssl_context *ssl, unsigned char **p, in ssl_parse_client_psk_identity() argument
3639 if( end - *p < 2 ) in ssl_parse_client_psk_identity()
3645 n = ( (*p)[0] << 8 ) | (*p)[1]; in ssl_parse_client_psk_identity()
3646 *p += 2; in ssl_parse_client_psk_identity()
3648 if( n == 0 || n > end - *p ) in ssl_parse_client_psk_identity()
3656 if( ssl->conf->f_psk( ssl->conf->p_psk, ssl, *p, n ) != 0 ) in ssl_parse_client_psk_identity()
3664 mbedtls_ssl_safer_memcmp( ssl->conf->psk_identity, *p, n ) != 0 ) in ssl_parse_client_psk_identity()
3672 MBEDTLS_SSL_DEBUG_BUF( 3, "Unknown PSK identity", *p, n ); in ssl_parse_client_psk_identity()
3678 *p += n; in ssl_parse_client_psk_identity()
3688 unsigned char *p, *end; in ssl_parse_client_key_exchange() local
3714 p = ssl->in_msg + mbedtls_ssl_hs_hdr_len( ssl ); in ssl_parse_client_key_exchange()
3732 if( ( ret = ssl_parse_client_dh_public( ssl, &p, end ) ) != 0 ) in ssl_parse_client_key_exchange()
3738 if( p != end ) in ssl_parse_client_key_exchange()
3768 p, end - p) ) != 0 ) in ssl_parse_client_key_exchange()
3798 if( ( ret = ssl_parse_client_psk_identity( ssl, &p, end ) ) != 0 ) in ssl_parse_client_key_exchange()
3804 if( p != end ) in ssl_parse_client_key_exchange()
3838 p += ssl->conf->psk_identity_len + 2; in ssl_parse_client_key_exchange()
3842 if( ( ret = ssl_parse_client_psk_identity( ssl, &p, end ) ) != 0 ) in ssl_parse_client_key_exchange()
3854 if( ( ret = ssl_parse_encrypted_pms( ssl, p, end, 2 ) ) != 0 ) in ssl_parse_client_key_exchange()
3872 if( ( ret = ssl_parse_client_psk_identity( ssl, &p, end ) ) != 0 ) in ssl_parse_client_key_exchange()
3877 if( ( ret = ssl_parse_client_dh_public( ssl, &p, end ) ) != 0 ) in ssl_parse_client_key_exchange()
3889 if( p != end ) in ssl_parse_client_key_exchange()
3907 if( ( ret = ssl_parse_client_psk_identity( ssl, &p, end ) ) != 0 ) in ssl_parse_client_key_exchange()
3914 p, end - p ) ) != 0 ) in ssl_parse_client_key_exchange()
3941 if( ( ret = ssl_parse_encrypted_pms( ssl, p, end, 0 ) ) != 0 ) in ssl_parse_client_key_exchange()
3953 p, end - p ); in ssl_parse_client_key_exchange()