Lines Matching refs:p
182 const unsigned char *p; in ssl_parse_supported_groups_ext() local
225 p = buf + 2; in ssl_parse_supported_groups_ext()
228 curve_info = mbedtls_ecp_curve_info_from_tls_id( ( p[0] << 8 ) | p[1] ); in ssl_parse_supported_groups_ext()
237 p += 2; in ssl_parse_supported_groups_ext()
249 const unsigned char *p; in ssl_parse_supported_point_formats() local
260 p = buf + 1; in ssl_parse_supported_point_formats()
263 if( p[0] == MBEDTLS_ECP_PF_UNCOMPRESSED || in ssl_parse_supported_point_formats()
264 p[0] == MBEDTLS_ECP_PF_COMPRESSED ) in ssl_parse_supported_point_formats()
268 ssl->handshake->ecdh_ctx.point_format = p[0]; in ssl_parse_supported_point_formats()
274 p[0] ); in ssl_parse_supported_point_formats()
276 MBEDTLS_SSL_DEBUG_MSG( 4, ( "point format selected: %d", p[0] ) ); in ssl_parse_supported_point_formats()
281 p++; in ssl_parse_supported_point_formats()
928 unsigned char *buf, *p, *ext; in ssl_parse_client_hello() local
1578 for( i = 0, p = buf + ciph_offset + 2; i < ciph_len; i += 2, p += 2 ) in ssl_parse_client_hello()
1580 if( p[0] == 0 && p[1] == MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO ) in ssl_parse_client_hello()
1663 for( j = 0, p = buf + ciph_offset + 2; j < ciph_len; j += 2, p += 2 ) in ssl_parse_client_hello()
1666 if( MBEDTLS_GET_UINT16_BE(p, 0) != ciphersuites[i] ) in ssl_parse_client_hello()
1680 for( j = 0, p = buf + ciph_offset + 2; j < ciph_len; j += 2, p += 2 ) in ssl_parse_client_hello()
1682 if( MBEDTLS_GET_UINT16_BE(p, 0) != ciphersuites[i] ) in ssl_parse_client_hello()
1753 unsigned char *p = buf; in ssl_write_cid_ext() local
1766 if( end < p || (size_t)( end - p ) < (unsigned)( ssl->own_cid_len + 5 ) ) in ssl_write_cid_ext()
1779 MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_CID, p, 0 ); in ssl_write_cid_ext()
1780 p += 2; in ssl_write_cid_ext()
1782 MBEDTLS_PUT_UINT16_BE( ext_len, p, 0 ); in ssl_write_cid_ext()
1783 p += 2; in ssl_write_cid_ext()
1785 *p++ = (uint8_t) ssl->own_cid_len; in ssl_write_cid_ext()
1786 memcpy( p, ssl->own_cid, ssl->own_cid_len ); in ssl_write_cid_ext()
1797 unsigned char *p = buf; in ssl_write_encrypt_then_mac_ext() local
1829 MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC, p, 0 ); in ssl_write_encrypt_then_mac_ext()
1830 p += 2; in ssl_write_encrypt_then_mac_ext()
1832 *p++ = 0x00; in ssl_write_encrypt_then_mac_ext()
1833 *p++ = 0x00; in ssl_write_encrypt_then_mac_ext()
1844 unsigned char *p = buf; in ssl_write_extended_ms_ext() local
1855 MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET, p, 0 ); in ssl_write_extended_ms_ext()
1856 p += 2; in ssl_write_extended_ms_ext()
1858 *p++ = 0x00; in ssl_write_extended_ms_ext()
1859 *p++ = 0x00; in ssl_write_extended_ms_ext()
1870 unsigned char *p = buf; in ssl_write_session_ticket_ext() local
1880 MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SESSION_TICKET, p, 0 ); in ssl_write_session_ticket_ext()
1881 p += 2; in ssl_write_session_ticket_ext()
1883 *p++ = 0x00; in ssl_write_session_ticket_ext()
1884 *p++ = 0x00; in ssl_write_session_ticket_ext()
1894 unsigned char *p = buf; in ssl_write_renegotiation_ext() local
1904 MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO, p, 0 ); in ssl_write_renegotiation_ext()
1905 p += 2; in ssl_write_renegotiation_ext()
1910 *p++ = 0x00; in ssl_write_renegotiation_ext()
1911 *p++ = ( ssl->verify_data_len * 2 + 1 ) & 0xFF; in ssl_write_renegotiation_ext()
1912 *p++ = ssl->verify_data_len * 2 & 0xFF; in ssl_write_renegotiation_ext()
1914 memcpy( p, ssl->peer_verify_data, ssl->verify_data_len ); in ssl_write_renegotiation_ext()
1915 p += ssl->verify_data_len; in ssl_write_renegotiation_ext()
1916 memcpy( p, ssl->own_verify_data, ssl->verify_data_len ); in ssl_write_renegotiation_ext()
1917 p += ssl->verify_data_len; in ssl_write_renegotiation_ext()
1922 *p++ = 0x00; in ssl_write_renegotiation_ext()
1923 *p++ = 0x01; in ssl_write_renegotiation_ext()
1924 *p++ = 0x00; in ssl_write_renegotiation_ext()
1927 *olen = p - buf; in ssl_write_renegotiation_ext()
1935 unsigned char *p = buf; in ssl_write_max_fragment_length_ext() local
1945 MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH, p, 0 ); in ssl_write_max_fragment_length_ext()
1946 p += 2; in ssl_write_max_fragment_length_ext()
1948 *p++ = 0x00; in ssl_write_max_fragment_length_ext()
1949 *p++ = 1; in ssl_write_max_fragment_length_ext()
1951 *p++ = ssl->session_negotiate->mfl_code; in ssl_write_max_fragment_length_ext()
1963 unsigned char *p = buf; in ssl_write_supported_point_formats_ext() local
1975 MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS, p, 0 ); in ssl_write_supported_point_formats_ext()
1976 p += 2; in ssl_write_supported_point_formats_ext()
1978 *p++ = 0x00; in ssl_write_supported_point_formats_ext()
1979 *p++ = 2; in ssl_write_supported_point_formats_ext()
1981 *p++ = 1; in ssl_write_supported_point_formats_ext()
1982 *p++ = MBEDTLS_ECP_PF_UNCOMPRESSED; in ssl_write_supported_point_formats_ext()
1994 unsigned char *p = buf; in ssl_write_ecjpake_kkpp_ext() local
2007 if( end - p < 4 ) in ssl_write_ecjpake_kkpp_ext()
2013 MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_ECJPAKE_KKPP, p, 0 ); in ssl_write_ecjpake_kkpp_ext()
2014 p += 2; in ssl_write_ecjpake_kkpp_ext()
2018 p + 2, end - p - 2, &kkpp_len, in ssl_write_ecjpake_kkpp_ext()
2029 p + 2, end - p - 2, &kkpp_len, in ssl_write_ecjpake_kkpp_ext()
2038 MBEDTLS_PUT_UINT16_BE( kkpp_len, p, 0 ); in ssl_write_ecjpake_kkpp_ext()
2039 p += 2; in ssl_write_ecjpake_kkpp_ext()
2119 unsigned char *p = ssl->out_msg + 4; in ssl_write_hello_verify_request() local
2133 mbedtls_ssl_write_version( p, ssl->conf->transport, ssl->tls_version ); in ssl_write_hello_verify_request()
2134 MBEDTLS_SSL_DEBUG_BUF( 3, "server version", p, 2 ); in ssl_write_hello_verify_request()
2135 p += 2; in ssl_write_hello_verify_request()
2145 cookie_len_byte = p++; in ssl_write_hello_verify_request()
2148 &p, ssl->out_buf + MBEDTLS_SSL_OUT_BUFFER_LEN, in ssl_write_hello_verify_request()
2155 *cookie_len_byte = (unsigned char)( p - ( cookie_len_byte + 1 ) ); in ssl_write_hello_verify_request()
2159 ssl->out_msglen = p - ssl->out_msg; in ssl_write_hello_verify_request()
2241 unsigned char *buf, *p; in ssl_write_server_hello() local
2270 p = buf + 4; in ssl_write_server_hello()
2272 mbedtls_ssl_write_version( p, ssl->conf->transport, ssl->tls_version ); in ssl_write_server_hello()
2273 p += 2; in ssl_write_server_hello()
2280 MBEDTLS_PUT_UINT32_BE( t, p, 0 ); in ssl_write_server_hello()
2281 p += 4; in ssl_write_server_hello()
2286 if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, p, 4 ) ) != 0 ) in ssl_write_server_hello()
2289 p += 4; in ssl_write_server_hello()
2292 if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, p, 28 ) ) != 0 ) in ssl_write_server_hello()
2295 p += 28; in ssl_write_server_hello()
2353 *p++ = (unsigned char) ssl->session_negotiate->id_len; in ssl_write_server_hello()
2354 memcpy( p, ssl->session_negotiate->id, ssl->session_negotiate->id_len ); in ssl_write_server_hello()
2355 p += ssl->session_negotiate->id_len; in ssl_write_server_hello()
2362 MBEDTLS_PUT_UINT16_BE( ssl->session_negotiate->ciphersuite, p, 0 ); in ssl_write_server_hello()
2363 p += 2; in ssl_write_server_hello()
2364 *p++ = MBEDTLS_BYTE_0( MBEDTLS_SSL_COMPRESS_NULL ); in ssl_write_server_hello()
2374 ssl_write_renegotiation_ext( ssl, p + 2 + ext_len, &olen ); in ssl_write_server_hello()
2378 ssl_write_max_fragment_length_ext( ssl, p + 2 + ext_len, &olen ); in ssl_write_server_hello()
2383 ssl_write_cid_ext( ssl, p + 2 + ext_len, &olen ); in ssl_write_server_hello()
2388 ssl_write_encrypt_then_mac_ext( ssl, p + 2 + ext_len, &olen ); in ssl_write_server_hello()
2393 ssl_write_extended_ms_ext( ssl, p + 2 + ext_len, &olen ); in ssl_write_server_hello()
2398 ssl_write_session_ticket_ext( ssl, p + 2 + ext_len, &olen ); in ssl_write_server_hello()
2408 ssl_write_supported_point_formats_ext( ssl, p + 2 + ext_len, &olen ); in ssl_write_server_hello()
2414 ssl_write_ecjpake_kkpp_ext( ssl, p + 2 + ext_len, &olen ); in ssl_write_server_hello()
2420 if( ( ret = mbedtls_ssl_write_alpn_ext( ssl, p + 2 + ext_len, end, &olen ) ) in ssl_write_server_hello()
2428 ssl_write_use_srtp_ext( ssl, p + 2 + ext_len, &olen ); in ssl_write_server_hello()
2437 MBEDTLS_PUT_UINT16_BE( ext_len, p, 0 ); in ssl_write_server_hello()
2438 p += 2 + ext_len; in ssl_write_server_hello()
2441 ssl->out_msglen = p - buf; in ssl_write_server_hello()
2480 unsigned char *buf, *p; in ssl_write_certificate_request() local
2516 p = buf + 4; in ssl_write_certificate_request()
2527 p[1 + ct_len++] = MBEDTLS_SSL_CERT_TYPE_RSA_SIGN; in ssl_write_certificate_request()
2530 p[1 + ct_len++] = MBEDTLS_SSL_CERT_TYPE_ECDSA_SIGN; in ssl_write_certificate_request()
2533 p[0] = (unsigned char) ct_len++; in ssl_write_certificate_request()
2534 p += ct_len; in ssl_write_certificate_request()
2568 MBEDTLS_PUT_UINT16_BE( *sig_alg, p, sa_len ); in ssl_write_certificate_request()
2573 MBEDTLS_PUT_UINT16_BE( sa_len, p, 0 ); in ssl_write_certificate_request()
2575 p += sa_len; in ssl_write_certificate_request()
2581 p += 2; in ssl_write_certificate_request()
2615 if( end < p || (size_t)( end - p ) < 2 + (size_t) dn_size ) in ssl_write_certificate_request()
2621 MBEDTLS_PUT_UINT16_BE( dn_size, p, 0 ); in ssl_write_certificate_request()
2622 p += 2; in ssl_write_certificate_request()
2623 memcpy( p, crt->subject_raw.p, dn_size ); in ssl_write_certificate_request()
2624 p += dn_size; in ssl_write_certificate_request()
2626 MBEDTLS_SSL_DEBUG_BUF( 3, "requested DN", p - dn_size, dn_size ); in ssl_write_certificate_request()
2633 ssl->out_msglen = p - buf; in ssl_write_certificate_request()
2929 if( ssl->conf->dhm_P.p == NULL || ssl->conf->dhm_G.p == NULL ) in ssl_prepare_server_key_exchange()
3016 uint8_t *p = ssl->out_msg + ssl->out_msglen; in ssl_prepare_server_key_exchange() local
3045 *p++ = MBEDTLS_ECP_TLS_NAMED_CURVE; in ssl_prepare_server_key_exchange()
3050 MBEDTLS_PUT_UINT16_BE( (*curve)->tls_id, p, 0 ); in ssl_prepare_server_key_exchange()
3051 p += 2; in ssl_prepare_server_key_exchange()
3073 unsigned char *own_pubkey = p + data_length_size; in ssl_prepare_server_key_exchange()
3091 *p = (uint8_t) len; in ssl_prepare_server_key_exchange()
3415 static int ssl_parse_client_dh_public( mbedtls_ssl_context *ssl, unsigned char **p, in ssl_parse_client_dh_public() argument
3424 if( *p + 2 > end ) in ssl_parse_client_dh_public()
3430 n = ( (*p)[0] << 8 ) | (*p)[1]; in ssl_parse_client_dh_public()
3431 *p += 2; in ssl_parse_client_dh_public()
3433 if( *p + n > end ) in ssl_parse_client_dh_public()
3439 if( ( ret = mbedtls_dhm_read_public( &ssl->handshake->dhm_ctx, *p, n ) ) != 0 ) in ssl_parse_client_dh_public()
3445 *p += n; in ssl_parse_client_dh_public()
3478 const unsigned char *p, in ssl_decrypt_encrypted_pms() argument
3509 if ( p + 2 > end ) { in ssl_decrypt_encrypted_pms()
3513 if( *p++ != MBEDTLS_BYTE_1( len ) || in ssl_decrypt_encrypted_pms()
3514 *p++ != MBEDTLS_BYTE_0( len ) ) in ssl_decrypt_encrypted_pms()
3520 if( p + len != end ) in ssl_decrypt_encrypted_pms()
3534 p, len ); in ssl_decrypt_encrypted_pms()
3562 ret = mbedtls_pk_decrypt( private_key, p, len, in ssl_decrypt_encrypted_pms()
3570 const unsigned char *p, in ssl_parse_encrypted_pms() argument
3592 ret = ssl_decrypt_encrypted_pms( ssl, p, end, in ssl_parse_encrypted_pms()
3658 static int ssl_parse_client_psk_identity( mbedtls_ssl_context *ssl, unsigned char **p, in ssl_parse_client_psk_identity() argument
3673 if( end - *p < 2 ) in ssl_parse_client_psk_identity()
3679 n = ( (*p)[0] << 8 ) | (*p)[1]; in ssl_parse_client_psk_identity()
3680 *p += 2; in ssl_parse_client_psk_identity()
3682 if( n == 0 || n > end - *p ) in ssl_parse_client_psk_identity()
3690 if( ssl->conf->f_psk( ssl->conf->p_psk, ssl, *p, n ) != 0 ) in ssl_parse_client_psk_identity()
3698 mbedtls_ct_memcmp( ssl->conf->psk_identity, *p, n ) != 0 ) in ssl_parse_client_psk_identity()
3706 MBEDTLS_SSL_DEBUG_BUF( 3, "Unknown PSK identity", *p, n ); in ssl_parse_client_psk_identity()
3712 *p += n; in ssl_parse_client_psk_identity()
3723 unsigned char *p, *end; in ssl_parse_client_key_exchange() local
3749 p = ssl->in_msg + mbedtls_ssl_hs_hdr_len( ssl ); in ssl_parse_client_key_exchange()
3767 if( ( ret = ssl_parse_client_dh_public( ssl, &p, end ) ) != 0 ) in ssl_parse_client_key_exchange()
3773 if( p != end ) in ssl_parse_client_key_exchange()
3803 size_t data_len = (size_t)( *p++ ); in ssl_parse_client_key_exchange()
3804 size_t buf_len = (size_t)( end - p ); in ssl_parse_client_key_exchange()
3826 memcpy( handshake->ecdh_psa_peerkey, p, data_len ); in ssl_parse_client_key_exchange()
3859 p, end - p) ) != 0 ) in ssl_parse_client_key_exchange()
3890 if( ( ret = ssl_parse_client_psk_identity( ssl, &p, end ) ) != 0 ) in ssl_parse_client_key_exchange()
3896 if( p != end ) in ssl_parse_client_key_exchange()
3925 p += ssl->conf->psk_identity_len + 2; in ssl_parse_client_key_exchange()
3929 if( ( ret = ssl_parse_client_psk_identity( ssl, &p, end ) ) != 0 ) in ssl_parse_client_key_exchange()
3935 if( ( ret = ssl_parse_encrypted_pms( ssl, p, end, 2 ) ) != 0 ) in ssl_parse_client_key_exchange()
3955 if( ( ret = ssl_parse_client_psk_identity( ssl, &p, end ) ) != 0 ) in ssl_parse_client_key_exchange()
3960 if( ( ret = ssl_parse_client_dh_public( ssl, &p, end ) ) != 0 ) in ssl_parse_client_key_exchange()
3966 if( p != end ) in ssl_parse_client_key_exchange()
4010 if( ( ret = ssl_parse_client_psk_identity( ssl, &p, end ) ) != 0 ) in ssl_parse_client_key_exchange()
4019 if( p >= end ) in ssl_parse_client_key_exchange()
4026 ecpoint_len = *(p++); in ssl_parse_client_key_exchange()
4027 if( (size_t)( end - p ) < ecpoint_len ) { in ssl_parse_client_key_exchange()
4039 memcpy( handshake->ecdh_psa_peerkey, p, ecpoint_len ); in ssl_parse_client_key_exchange()
4041 p += ecpoint_len; in ssl_parse_client_key_exchange()
4078 if( ( ret = ssl_parse_client_psk_identity( ssl, &p, end ) ) != 0 ) in ssl_parse_client_key_exchange()
4085 p, end - p ) ) != 0 ) in ssl_parse_client_key_exchange()
4107 if( ( ret = ssl_parse_encrypted_pms( ssl, p, end, 0 ) ) != 0 ) in ssl_parse_client_key_exchange()
4120 &ssl->handshake->psa_pake_ctx, p, end - p, in ssl_parse_client_key_exchange()
4131 p, end - p ); in ssl_parse_client_key_exchange()