Lines Matching refs:p

190     const unsigned char *p;  in ssl_parse_supported_groups_ext()  local
232 p = buf + 2; in ssl_parse_supported_groups_ext()
234 uint16_t curr_tls_id = MBEDTLS_GET_UINT16_BE(p, 0); in ssl_parse_supported_groups_ext()
243 p += 2; in ssl_parse_supported_groups_ext()
255 const unsigned char *p; in ssl_parse_supported_point_formats() local
265 p = buf + 1; in ssl_parse_supported_point_formats()
267 if (p[0] == MBEDTLS_ECP_PF_UNCOMPRESSED || in ssl_parse_supported_point_formats()
268 p[0] == MBEDTLS_ECP_PF_COMPRESSED) { in ssl_parse_supported_point_formats()
271 ssl->handshake->ecdh_ctx.point_format = p[0]; in ssl_parse_supported_point_formats()
277 p[0]); in ssl_parse_supported_point_formats()
279 MBEDTLS_SSL_DEBUG_MSG(4, ("point format selected: %d", p[0])); in ssl_parse_supported_point_formats()
284 p++; in ssl_parse_supported_point_formats()
899 unsigned char *buf, *p, *ext; in ssl_parse_client_hello() local
1525 for (i = 0, p = buf + ciph_offset + 2; i < ciph_len; i += 2, p += 2) { in ssl_parse_client_hello()
1526 if (p[0] == 0 && p[1] == MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO) { in ssl_parse_client_hello()
1598 for (j = 0, p = buf + ciph_offset + 2; j < ciph_len; j += 2, p += 2) { in ssl_parse_client_hello()
1600 if (MBEDTLS_GET_UINT16_BE(p, 0) != ciphersuites[i]) { in ssl_parse_client_hello()
1618 for (j = 0, p = buf + ciph_offset + 2; j < ciph_len; j += 2, p += 2) { in ssl_parse_client_hello()
1619 if (MBEDTLS_GET_UINT16_BE(p, 0) != ciphersuites[i]) { in ssl_parse_client_hello()
1689 unsigned char *p = buf; in ssl_write_cid_ext() local
1703 if (end < p || (size_t) (end - p) < (unsigned) (ssl->own_cid_len + 5)) { in ssl_write_cid_ext()
1715 MBEDTLS_PUT_UINT16_BE(MBEDTLS_TLS_EXT_CID, p, 0); in ssl_write_cid_ext()
1716 p += 2; in ssl_write_cid_ext()
1718 MBEDTLS_PUT_UINT16_BE(ext_len, p, 0); in ssl_write_cid_ext()
1719 p += 2; in ssl_write_cid_ext()
1721 *p++ = (uint8_t) ssl->own_cid_len; in ssl_write_cid_ext()
1722 memcpy(p, ssl->own_cid, ssl->own_cid_len); in ssl_write_cid_ext()
1733 unsigned char *p = buf; in ssl_write_encrypt_then_mac_ext() local
1764 MBEDTLS_PUT_UINT16_BE(MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC, p, 0); in ssl_write_encrypt_then_mac_ext()
1765 p += 2; in ssl_write_encrypt_then_mac_ext()
1767 *p++ = 0x00; in ssl_write_encrypt_then_mac_ext()
1768 *p++ = 0x00; in ssl_write_encrypt_then_mac_ext()
1779 unsigned char *p = buf; in ssl_write_extended_ms_ext() local
1789 MBEDTLS_PUT_UINT16_BE(MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET, p, 0); in ssl_write_extended_ms_ext()
1790 p += 2; in ssl_write_extended_ms_ext()
1792 *p++ = 0x00; in ssl_write_extended_ms_ext()
1793 *p++ = 0x00; in ssl_write_extended_ms_ext()
1804 unsigned char *p = buf; in ssl_write_session_ticket_ext() local
1813 MBEDTLS_PUT_UINT16_BE(MBEDTLS_TLS_EXT_SESSION_TICKET, p, 0); in ssl_write_session_ticket_ext()
1814 p += 2; in ssl_write_session_ticket_ext()
1816 *p++ = 0x00; in ssl_write_session_ticket_ext()
1817 *p++ = 0x00; in ssl_write_session_ticket_ext()
1827 unsigned char *p = buf; in ssl_write_renegotiation_ext() local
1836 MBEDTLS_PUT_UINT16_BE(MBEDTLS_TLS_EXT_RENEGOTIATION_INFO, p, 0); in ssl_write_renegotiation_ext()
1837 p += 2; in ssl_write_renegotiation_ext()
1841 *p++ = 0x00; in ssl_write_renegotiation_ext()
1842 *p++ = (ssl->verify_data_len * 2 + 1) & 0xFF; in ssl_write_renegotiation_ext()
1843 *p++ = ssl->verify_data_len * 2 & 0xFF; in ssl_write_renegotiation_ext()
1845 memcpy(p, ssl->peer_verify_data, ssl->verify_data_len); in ssl_write_renegotiation_ext()
1846 p += ssl->verify_data_len; in ssl_write_renegotiation_ext()
1847 memcpy(p, ssl->own_verify_data, ssl->verify_data_len); in ssl_write_renegotiation_ext()
1848 p += ssl->verify_data_len; in ssl_write_renegotiation_ext()
1852 *p++ = 0x00; in ssl_write_renegotiation_ext()
1853 *p++ = 0x01; in ssl_write_renegotiation_ext()
1854 *p++ = 0x00; in ssl_write_renegotiation_ext()
1857 *olen = p - buf; in ssl_write_renegotiation_ext()
1865 unsigned char *p = buf; in ssl_write_max_fragment_length_ext() local
1874 MBEDTLS_PUT_UINT16_BE(MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH, p, 0); in ssl_write_max_fragment_length_ext()
1875 p += 2; in ssl_write_max_fragment_length_ext()
1877 *p++ = 0x00; in ssl_write_max_fragment_length_ext()
1878 *p++ = 1; in ssl_write_max_fragment_length_ext()
1880 *p++ = ssl->session_negotiate->mfl_code; in ssl_write_max_fragment_length_ext()
1892 unsigned char *p = buf; in ssl_write_supported_point_formats_ext() local
1903 MBEDTLS_PUT_UINT16_BE(MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS, p, 0); in ssl_write_supported_point_formats_ext()
1904 p += 2; in ssl_write_supported_point_formats_ext()
1906 *p++ = 0x00; in ssl_write_supported_point_formats_ext()
1907 *p++ = 2; in ssl_write_supported_point_formats_ext()
1909 *p++ = 1; in ssl_write_supported_point_formats_ext()
1910 *p++ = MBEDTLS_ECP_PF_UNCOMPRESSED; in ssl_write_supported_point_formats_ext()
1922 unsigned char *p = buf; in ssl_write_ecjpake_kkpp_ext() local
1936 if (end - p < 4) { in ssl_write_ecjpake_kkpp_ext()
1941 MBEDTLS_PUT_UINT16_BE(MBEDTLS_TLS_EXT_ECJPAKE_KKPP, p, 0); in ssl_write_ecjpake_kkpp_ext()
1942 p += 2; in ssl_write_ecjpake_kkpp_ext()
1946 p + 2, end - p - 2, &kkpp_len, in ssl_write_ecjpake_kkpp_ext()
1956 p + 2, end - p - 2, &kkpp_len, in ssl_write_ecjpake_kkpp_ext()
1964 MBEDTLS_PUT_UINT16_BE(kkpp_len, p, 0); in ssl_write_ecjpake_kkpp_ext()
1965 p += 2; in ssl_write_ecjpake_kkpp_ext()
2039 unsigned char *p = ssl->out_msg + 4; in ssl_write_hello_verify_request() local
2053 mbedtls_ssl_write_version(p, ssl->conf->transport, ssl->tls_version); in ssl_write_hello_verify_request()
2054 MBEDTLS_SSL_DEBUG_BUF(3, "server version", p, 2); in ssl_write_hello_verify_request()
2055 p += 2; in ssl_write_hello_verify_request()
2064 cookie_len_byte = p++; in ssl_write_hello_verify_request()
2067 &p, ssl->out_buf + MBEDTLS_SSL_OUT_BUFFER_LEN, in ssl_write_hello_verify_request()
2073 *cookie_len_byte = (unsigned char) (p - (cookie_len_byte + 1)); in ssl_write_hello_verify_request()
2077 ssl->out_msglen = p - ssl->out_msg; in ssl_write_hello_verify_request()
2161 unsigned char *buf, *p; in ssl_write_server_hello() local
2188 p = buf + 4; in ssl_write_server_hello()
2190 mbedtls_ssl_write_version(p, ssl->conf->transport, ssl->tls_version); in ssl_write_server_hello()
2191 p += 2; in ssl_write_server_hello()
2198 MBEDTLS_PUT_UINT32_BE(t, p, 0); in ssl_write_server_hello()
2199 p += 4; in ssl_write_server_hello()
2204 if ((ret = ssl->conf->f_rng(ssl->conf->p_rng, p, 4)) != 0) { in ssl_write_server_hello()
2208 p += 4; in ssl_write_server_hello()
2211 if ((ret = ssl->conf->f_rng(ssl->conf->p_rng, p, 28)) != 0) { in ssl_write_server_hello()
2215 p += 28; in ssl_write_server_hello()
2268 *p++ = (unsigned char) ssl->session_negotiate->id_len; in ssl_write_server_hello()
2269 memcpy(p, ssl->session_negotiate->id, ssl->session_negotiate->id_len); in ssl_write_server_hello()
2270 p += ssl->session_negotiate->id_len; in ssl_write_server_hello()
2277 MBEDTLS_PUT_UINT16_BE(ssl->session_negotiate->ciphersuite, p, 0); in ssl_write_server_hello()
2278 p += 2; in ssl_write_server_hello()
2279 *p++ = MBEDTLS_BYTE_0(MBEDTLS_SSL_COMPRESS_NULL); in ssl_write_server_hello()
2289 ssl_write_renegotiation_ext(ssl, p + 2 + ext_len, &olen); in ssl_write_server_hello()
2293 ssl_write_max_fragment_length_ext(ssl, p + 2 + ext_len, &olen); in ssl_write_server_hello()
2298 ssl_write_cid_ext(ssl, p + 2 + ext_len, &olen); in ssl_write_server_hello()
2303 ssl_write_encrypt_then_mac_ext(ssl, p + 2 + ext_len, &olen); in ssl_write_server_hello()
2308 ssl_write_extended_ms_ext(ssl, p + 2 + ext_len, &olen); in ssl_write_server_hello()
2313 ssl_write_session_ticket_ext(ssl, p + 2 + ext_len, &olen); in ssl_write_server_hello()
2322 ssl_write_supported_point_formats_ext(ssl, p + 2 + ext_len, &olen); in ssl_write_server_hello()
2328 ssl_write_ecjpake_kkpp_ext(ssl, p + 2 + ext_len, &olen); in ssl_write_server_hello()
2334 if ((ret = mbedtls_ssl_write_alpn_ext(ssl, p + 2 + ext_len, end, &olen)) in ssl_write_server_hello()
2343 ssl_write_use_srtp_ext(ssl, p + 2 + ext_len, &olen); in ssl_write_server_hello()
2351 MBEDTLS_PUT_UINT16_BE(ext_len, p, 0); in ssl_write_server_hello()
2352 p += 2 + ext_len; in ssl_write_server_hello()
2355 ssl->out_msglen = p - buf; in ssl_write_server_hello()
2393 unsigned char *buf, *p; in ssl_write_certificate_request() local
2428 p = buf + 4; in ssl_write_certificate_request()
2439 p[1 + ct_len++] = MBEDTLS_SSL_CERT_TYPE_RSA_SIGN; in ssl_write_certificate_request()
2442 p[1 + ct_len++] = MBEDTLS_SSL_CERT_TYPE_ECDSA_SIGN; in ssl_write_certificate_request()
2445 p[0] = (unsigned char) ct_len++; in ssl_write_certificate_request()
2446 p += ct_len; in ssl_write_certificate_request()
2482 MBEDTLS_PUT_UINT16_BE(*sig_alg, p, sa_len); in ssl_write_certificate_request()
2487 MBEDTLS_PUT_UINT16_BE(sa_len, p, 0); in ssl_write_certificate_request()
2489 p += sa_len; in ssl_write_certificate_request()
2495 p += 2; in ssl_write_certificate_request()
2527 if (end < p || (size_t) (end - p) < 2 + (size_t) dn_size) { in ssl_write_certificate_request()
2532 MBEDTLS_PUT_UINT16_BE(dn_size, p, 0); in ssl_write_certificate_request()
2533 p += 2; in ssl_write_certificate_request()
2534 memcpy(p, crt->subject_raw.p, dn_size); in ssl_write_certificate_request()
2535 p += dn_size; in ssl_write_certificate_request()
2537 MBEDTLS_SSL_DEBUG_BUF(3, "requested DN", p - dn_size, dn_size); in ssl_write_certificate_request()
2544 ssl->out_msglen = p - buf; in ssl_write_certificate_request()
2835 if (ssl->conf->dhm_P.p == NULL || ssl->conf->dhm_G.p == NULL) { in ssl_prepare_server_key_exchange()
2922 uint8_t *p = ssl->out_msg + ssl->out_msglen; in ssl_prepare_server_key_exchange() local
2952 *p++ = MBEDTLS_ECP_TLS_NAMED_CURVE; in ssl_prepare_server_key_exchange()
2957 MBEDTLS_PUT_UINT16_BE(*curr_tls_id, p, 0); in ssl_prepare_server_key_exchange()
2958 p += 2; in ssl_prepare_server_key_exchange()
2979 unsigned char *own_pubkey = p + data_length_size; in ssl_prepare_server_key_exchange()
2996 *p = (uint8_t) len; in ssl_prepare_server_key_exchange()
3304 static int ssl_parse_client_dh_public(mbedtls_ssl_context *ssl, unsigned char **p, in ssl_parse_client_dh_public() argument
3313 if (*p + 2 > end) { in ssl_parse_client_dh_public()
3318 n = ((*p)[0] << 8) | (*p)[1]; in ssl_parse_client_dh_public()
3319 *p += 2; in ssl_parse_client_dh_public()
3321 if (*p + n > end) { in ssl_parse_client_dh_public()
3326 if ((ret = mbedtls_dhm_read_public(&ssl->handshake->dhm_ctx, *p, n)) != 0) { in ssl_parse_client_dh_public()
3331 *p += n; in ssl_parse_client_dh_public()
3363 const unsigned char *p, in ssl_decrypt_encrypted_pms() argument
3393 if (p + 2 > end) { in ssl_decrypt_encrypted_pms()
3397 if (*p++ != MBEDTLS_BYTE_1(len) || in ssl_decrypt_encrypted_pms()
3398 *p++ != MBEDTLS_BYTE_0(len)) { in ssl_decrypt_encrypted_pms()
3403 if (p + len != end) { in ssl_decrypt_encrypted_pms()
3415 p, len); in ssl_decrypt_encrypted_pms()
3441 ret = mbedtls_pk_decrypt(private_key, p, len, in ssl_decrypt_encrypted_pms()
3449 const unsigned char *p, in ssl_parse_encrypted_pms() argument
3471 ret = ssl_decrypt_encrypted_pms(ssl, p, end, in ssl_parse_encrypted_pms()
3538 static int ssl_parse_client_psk_identity(mbedtls_ssl_context *ssl, unsigned char **p, in ssl_parse_client_psk_identity() argument
3552 if (end - *p < 2) { in ssl_parse_client_psk_identity()
3557 n = ((*p)[0] << 8) | (*p)[1]; in ssl_parse_client_psk_identity()
3558 *p += 2; in ssl_parse_client_psk_identity()
3560 if (n == 0 || n > end - *p) { in ssl_parse_client_psk_identity()
3566 if (ssl->conf->f_psk(ssl->conf->p_psk, ssl, *p, n) != 0) { in ssl_parse_client_psk_identity()
3573 mbedtls_ct_memcmp(ssl->conf->psk_identity, *p, n) != 0) { in ssl_parse_client_psk_identity()
3579 MBEDTLS_SSL_DEBUG_BUF(3, "Unknown PSK identity", *p, n); in ssl_parse_client_psk_identity()
3585 *p += n; in ssl_parse_client_psk_identity()
3596 unsigned char *p, *end; in ssl_parse_client_key_exchange() local
3619 p = ssl->in_msg + mbedtls_ssl_hs_hdr_len(ssl); in ssl_parse_client_key_exchange()
3634 if ((ret = ssl_parse_client_dh_public(ssl, &p, end)) != 0) { in ssl_parse_client_key_exchange()
3639 if (p != end) { in ssl_parse_client_key_exchange()
3665 size_t data_len = (size_t) (*p++); in ssl_parse_client_key_exchange()
3666 size_t buf_len = (size_t) (end - p); in ssl_parse_client_key_exchange()
3686 memcpy(handshake->ecdh_psa_peerkey, p, data_len); in ssl_parse_client_key_exchange()
3717 p, end - p)) != 0) { in ssl_parse_client_key_exchange()
3744 if ((ret = ssl_parse_client_psk_identity(ssl, &p, end)) != 0) { in ssl_parse_client_key_exchange()
3749 if (p != end) { in ssl_parse_client_key_exchange()
3773 p += ssl->conf->psk_identity_len + 2; in ssl_parse_client_key_exchange()
3776 if ((ret = ssl_parse_client_psk_identity(ssl, &p, end)) != 0) { in ssl_parse_client_key_exchange()
3781 if ((ret = ssl_parse_encrypted_pms(ssl, p, end, 2)) != 0) { in ssl_parse_client_key_exchange()
3797 if ((ret = ssl_parse_client_psk_identity(ssl, &p, end)) != 0) { in ssl_parse_client_key_exchange()
3801 if ((ret = ssl_parse_client_dh_public(ssl, &p, end)) != 0) { in ssl_parse_client_key_exchange()
3806 if (p != end) { in ssl_parse_client_key_exchange()
3845 if ((ret = ssl_parse_client_psk_identity(ssl, &p, end)) != 0) { in ssl_parse_client_key_exchange()
3853 if (p >= end) { in ssl_parse_client_key_exchange()
3859 ecpoint_len = *(p++); in ssl_parse_client_key_exchange()
3860 if ((size_t) (end - p) < ecpoint_len) { in ssl_parse_client_key_exchange()
3872 memcpy(handshake->ecdh_psa_peerkey, p, ecpoint_len); in ssl_parse_client_key_exchange()
3874 p += ecpoint_len; in ssl_parse_client_key_exchange()
3912 if ((ret = ssl_parse_client_psk_identity(ssl, &p, end)) != 0) { in ssl_parse_client_key_exchange()
3918 p, end - p)) != 0) { in ssl_parse_client_key_exchange()
3936 if ((ret = ssl_parse_encrypted_pms(ssl, p, end, 0)) != 0) { in ssl_parse_client_key_exchange()
3946 &ssl->handshake->psa_pake_ctx, p, end - p, in ssl_parse_client_key_exchange()
3956 p, end - p); in ssl_parse_client_key_exchange()