Lines Matching refs:p
213 dtls_peer_t *p = NULL; in dtls_get_peer() local
216 HASH_FIND_PEER(ctx->peers, session, p); in dtls_get_peer()
218 for (p = list_head(ctx->peers); p; p = list_item_next(p)) in dtls_get_peer()
219 if (dtls_session_equals(&p->session, session)) in dtls_get_peer()
220 return p; in dtls_get_peer()
223 return p; in dtls_get_peer()
1185 uint8 *p, *start; in dtls_prepare_record() local
1194 p = dtls_set_record_header(type, security, sendbuf); in dtls_prepare_record()
1195 start = p; in dtls_prepare_record()
1208 memcpy(p, data_array[i], data_len_array[i]); in dtls_prepare_record()
1209 p += data_len_array[i]; in dtls_prepare_record()
1269 memcpy(p, &DTLS_RECORD_HEADER(sendbuf)->epoch, 8); in dtls_prepare_record()
1270 p += 8; in dtls_prepare_record()
1280 memcpy(p, data_array[i], data_len_array[i]); in dtls_prepare_record()
1281 p += data_len_array[i]; in dtls_prepare_record()
1546 uint8 *p = buf; in dtls_verify_peer() local
1586 dtls_int_to_uint16(p, DTLS_VERSION); in dtls_verify_peer()
1587 p += sizeof(uint16); in dtls_verify_peer()
1589 dtls_int_to_uint8(p, DTLS_COOKIE_LENGTH); in dtls_verify_peer()
1590 p += sizeof(uint8); in dtls_verify_peer()
1592 assert(p == mycookie); in dtls_verify_peer()
1594 p += DTLS_COOKIE_LENGTH; in dtls_verify_peer()
1600 buf, p - buf, 0); in dtls_verify_peer()
1742 uint8 *p; in dtls_send_server_hello() local
1753 p = buf; in dtls_send_server_hello()
1756 dtls_int_to_uint16(p, DTLS_VERSION); in dtls_send_server_hello()
1757 p += sizeof(uint16); in dtls_send_server_hello()
1765 memcpy(p, handshake->tmp.random.server, DTLS_RANDOM_LENGTH); in dtls_send_server_hello()
1766 p += DTLS_RANDOM_LENGTH; in dtls_send_server_hello()
1768 *p++ = 0; /* no session id */ in dtls_send_server_hello()
1772 dtls_int_to_uint16(p, handshake->cipher); in dtls_send_server_hello()
1773 p += sizeof(uint16); in dtls_send_server_hello()
1776 *p++ = compression_methods[handshake->compression]; in dtls_send_server_hello()
1781 dtls_int_to_uint16(p, extension_size - 2); in dtls_send_server_hello()
1782 p += sizeof(uint16); in dtls_send_server_hello()
1787 dtls_int_to_uint16(p, TLS_EXT_CLIENT_CERTIFICATE_TYPE); in dtls_send_server_hello()
1788 p += sizeof(uint16); in dtls_send_server_hello()
1791 dtls_int_to_uint16(p, 1); in dtls_send_server_hello()
1792 p += sizeof(uint16); in dtls_send_server_hello()
1794 dtls_int_to_uint8(p, TLS_CERT_TYPE_RAW_PUBLIC_KEY); in dtls_send_server_hello()
1795 p += sizeof(uint8); in dtls_send_server_hello()
1798 dtls_int_to_uint16(p, TLS_EXT_SERVER_CERTIFICATE_TYPE); in dtls_send_server_hello()
1799 p += sizeof(uint16); in dtls_send_server_hello()
1802 dtls_int_to_uint16(p, 1); in dtls_send_server_hello()
1803 p += sizeof(uint16); in dtls_send_server_hello()
1805 dtls_int_to_uint8(p, TLS_CERT_TYPE_RAW_PUBLIC_KEY); in dtls_send_server_hello()
1806 p += sizeof(uint8); in dtls_send_server_hello()
1809 dtls_int_to_uint16(p, TLS_EXT_EC_POINT_FORMATS); in dtls_send_server_hello()
1810 p += sizeof(uint16); in dtls_send_server_hello()
1813 dtls_int_to_uint16(p, 2); in dtls_send_server_hello()
1814 p += sizeof(uint16); in dtls_send_server_hello()
1817 dtls_int_to_uint8(p, 1); in dtls_send_server_hello()
1818 p += sizeof(uint8); in dtls_send_server_hello()
1820 dtls_int_to_uint8(p, TLS_EXT_EC_POINT_FORMATS_UNCOMPRESSED); in dtls_send_server_hello()
1821 p += sizeof(uint8); in dtls_send_server_hello()
1824 assert(p - buf <= sizeof(buf)); in dtls_send_server_hello()
1829 buf, p - buf); in dtls_send_server_hello()
1838 uint8 *p; in dtls_send_certificate_ecdsa() local
1843 p = buf; in dtls_send_certificate_ecdsa()
1845 dtls_int_to_uint24(p, 94); /* certificates length */ in dtls_send_certificate_ecdsa()
1846 p += sizeof(uint24); in dtls_send_certificate_ecdsa()
1848 dtls_int_to_uint24(p, 91); /* length of this certificate */ in dtls_send_certificate_ecdsa()
1849 p += sizeof(uint24); in dtls_send_certificate_ecdsa()
1851 memcpy(p, &cert_asn1_header, sizeof(cert_asn1_header)); in dtls_send_certificate_ecdsa()
1852 p += sizeof(cert_asn1_header); in dtls_send_certificate_ecdsa()
1854 memcpy(p, key->pub_key_x, DTLS_EC_KEY_SIZE); in dtls_send_certificate_ecdsa()
1855 p += DTLS_EC_KEY_SIZE; in dtls_send_certificate_ecdsa()
1857 memcpy(p, key->pub_key_y, DTLS_EC_KEY_SIZE); in dtls_send_certificate_ecdsa()
1858 p += DTLS_EC_KEY_SIZE; in dtls_send_certificate_ecdsa()
1860 assert(p - buf <= sizeof(buf)); in dtls_send_certificate_ecdsa()
1863 buf, p - buf); in dtls_send_certificate_ecdsa()
1867 dtls_add_ecdsa_signature_elem(uint8 *p, uint32_t *point_r, uint32_t *point_s) in dtls_add_ecdsa_signature_elem() argument
1875 len_r = dtls_ec_key_from_uint32_asn1(point_r, DTLS_EC_KEY_SIZE, p + R_KEY_OFFSET); in dtls_add_ecdsa_signature_elem()
1876 len_s = dtls_ec_key_from_uint32_asn1(point_s, DTLS_EC_KEY_SIZE, p + S_KEY_OFFSET(len_r)); in dtls_add_ecdsa_signature_elem()
1882 dtls_int_to_uint8(p, TLS_EXT_SIG_HASH_ALGO_SHA256); in dtls_add_ecdsa_signature_elem()
1883 p += sizeof(uint8); in dtls_add_ecdsa_signature_elem()
1886 dtls_int_to_uint8(p, TLS_EXT_SIG_HASH_ALGO_ECDSA); in dtls_add_ecdsa_signature_elem()
1887 p += sizeof(uint8); in dtls_add_ecdsa_signature_elem()
1890 dtls_int_to_uint16(p, len_r + len_s + 2 + 2 + 2); in dtls_add_ecdsa_signature_elem()
1891 p += sizeof(uint16); in dtls_add_ecdsa_signature_elem()
1894 dtls_int_to_uint8(p, 0x30); in dtls_add_ecdsa_signature_elem()
1895 p += sizeof(uint8); in dtls_add_ecdsa_signature_elem()
1897 dtls_int_to_uint8(p, len_r + len_s + 2 + 2); in dtls_add_ecdsa_signature_elem()
1898 p += sizeof(uint8); in dtls_add_ecdsa_signature_elem()
1901 dtls_int_to_uint8(p, 0x02); in dtls_add_ecdsa_signature_elem()
1902 p += sizeof(uint8); in dtls_add_ecdsa_signature_elem()
1904 dtls_int_to_uint8(p, len_r); in dtls_add_ecdsa_signature_elem()
1905 p += sizeof(uint8); in dtls_add_ecdsa_signature_elem()
1908 p += len_r; in dtls_add_ecdsa_signature_elem()
1911 dtls_int_to_uint8(p, 0x02); in dtls_add_ecdsa_signature_elem()
1912 p += sizeof(uint8); in dtls_add_ecdsa_signature_elem()
1914 dtls_int_to_uint8(p, len_s); in dtls_add_ecdsa_signature_elem()
1915 p += sizeof(uint8); in dtls_add_ecdsa_signature_elem()
1918 p += len_s; in dtls_add_ecdsa_signature_elem()
1920 return p; in dtls_add_ecdsa_signature_elem()
1930 uint8 *p; in dtls_send_server_key_exchange_ecdh() local
1941 p = buf; in dtls_send_server_key_exchange_ecdh()
1943 key_params = p; in dtls_send_server_key_exchange_ecdh()
1945 dtls_int_to_uint8(p, 3); in dtls_send_server_key_exchange_ecdh()
1946 p += sizeof(uint8); in dtls_send_server_key_exchange_ecdh()
1949 dtls_int_to_uint16(p, TLS_EXT_ELLIPTIC_CURVES_SECP256R1); in dtls_send_server_key_exchange_ecdh()
1950 p += sizeof(uint16); in dtls_send_server_key_exchange_ecdh()
1952 dtls_int_to_uint8(p, 1 + 2 * DTLS_EC_KEY_SIZE); in dtls_send_server_key_exchange_ecdh()
1953 p += sizeof(uint8); in dtls_send_server_key_exchange_ecdh()
1956 dtls_int_to_uint8(p, 4); in dtls_send_server_key_exchange_ecdh()
1957 p += sizeof(uint8); in dtls_send_server_key_exchange_ecdh()
1960 ephemeral_pub_x = p; in dtls_send_server_key_exchange_ecdh()
1961 p += DTLS_EC_KEY_SIZE; in dtls_send_server_key_exchange_ecdh()
1964 ephemeral_pub_y = p; in dtls_send_server_key_exchange_ecdh()
1965 p += DTLS_EC_KEY_SIZE; in dtls_send_server_key_exchange_ecdh()
1975 key_params, p - key_params, in dtls_send_server_key_exchange_ecdh()
1978 p = dtls_add_ecdsa_signature_elem(p, point_r, point_s); in dtls_send_server_key_exchange_ecdh()
1980 assert(p - buf <= sizeof(buf)); in dtls_send_server_key_exchange_ecdh()
1983 buf, p - buf); in dtls_send_server_key_exchange_ecdh()
1993 uint8 *p; in dtls_send_server_key_exchange_psk() local
1995 p = buf; in dtls_send_server_key_exchange_psk()
2004 dtls_int_to_uint16(p, len); in dtls_send_server_key_exchange_psk()
2005 p += sizeof(uint16); in dtls_send_server_key_exchange_psk()
2007 memcpy(p, psk_hint, len); in dtls_send_server_key_exchange_psk()
2008 p += len; in dtls_send_server_key_exchange_psk()
2010 assert(p - buf <= sizeof(buf)); in dtls_send_server_key_exchange_psk()
2013 buf, p - buf); in dtls_send_server_key_exchange_psk()
2022 uint8 *p; in dtls_send_server_certificate_request() local
2027 p = buf; in dtls_send_server_certificate_request()
2030 dtls_int_to_uint8(p, 1); in dtls_send_server_certificate_request()
2031 p += sizeof(uint8); in dtls_send_server_certificate_request()
2034 dtls_int_to_uint8(p, TLS_CLIENT_CERTIFICATE_TYPE_ECDSA_SIGN); in dtls_send_server_certificate_request()
2035 p += sizeof(uint8); in dtls_send_server_certificate_request()
2038 dtls_int_to_uint16(p, 2); in dtls_send_server_certificate_request()
2039 p += sizeof(uint16); in dtls_send_server_certificate_request()
2042 dtls_int_to_uint8(p, TLS_EXT_SIG_HASH_ALGO_SHA256); in dtls_send_server_certificate_request()
2043 p += sizeof(uint8); in dtls_send_server_certificate_request()
2046 dtls_int_to_uint8(p, TLS_EXT_SIG_HASH_ALGO_ECDSA); in dtls_send_server_certificate_request()
2047 p += sizeof(uint8); in dtls_send_server_certificate_request()
2050 dtls_int_to_uint16(p, 0); in dtls_send_server_certificate_request()
2051 p += sizeof(uint16); in dtls_send_server_certificate_request()
2053 assert(p - buf <= sizeof(buf)); in dtls_send_server_certificate_request()
2056 buf, p - buf); in dtls_send_server_certificate_request()
2167 uint8 *p; in dtls_send_client_key_exchange() local
2170 p = buf; in dtls_send_client_key_exchange()
2193 memcpy(handshake->keyx.psk.identity, p + sizeof(uint16), len); in dtls_send_client_key_exchange()
2195 dtls_int_to_uint16(p, handshake->keyx.psk.id_length); in dtls_send_client_key_exchange()
2196 p += sizeof(uint16); in dtls_send_client_key_exchange()
2198 memcpy(p, handshake->keyx.psk.identity, handshake->keyx.psk.id_length); in dtls_send_client_key_exchange()
2199 p += handshake->keyx.psk.id_length; in dtls_send_client_key_exchange()
2209 dtls_int_to_uint8(p, 1 + 2 * DTLS_EC_KEY_SIZE); in dtls_send_client_key_exchange()
2210 p += sizeof(uint8); in dtls_send_client_key_exchange()
2213 dtls_int_to_uint8(p, 4); in dtls_send_client_key_exchange()
2214 p += sizeof(uint8); in dtls_send_client_key_exchange()
2216 ephemeral_pub_x = p; in dtls_send_client_key_exchange()
2217 p += DTLS_EC_KEY_SIZE; in dtls_send_client_key_exchange()
2218 ephemeral_pub_y = p; in dtls_send_client_key_exchange()
2219 p += DTLS_EC_KEY_SIZE; in dtls_send_client_key_exchange()
2233 assert(p - buf <= sizeof(buf)); in dtls_send_client_key_exchange()
2236 buf, p - buf); in dtls_send_client_key_exchange()
2247 uint8 *p; in dtls_send_certificate_verify_ecdh() local
2256 p = buf; in dtls_send_certificate_verify_ecdh()
2267 p = dtls_add_ecdsa_signature_elem(p, point_r, point_s); in dtls_send_certificate_verify_ecdh()
2269 assert(p - buf <= sizeof(buf)); in dtls_send_certificate_verify_ecdh()
2272 buf, p - buf); in dtls_send_certificate_verify_ecdh()
2284 uint8 *p = buf; in dtls_send_finished() local
2295 p, DTLS_FIN_LENGTH); in dtls_send_finished()
2297 dtls_debug_dump("server finished MAC", p, DTLS_FIN_LENGTH); in dtls_send_finished()
2299 p += DTLS_FIN_LENGTH; in dtls_send_finished()
2301 assert(p - buf <= sizeof(buf)); in dtls_send_finished()
2304 buf, p - buf); in dtls_send_finished()
2311 uint8 *p = buf; in dtls_send_client_hello() local
2329 dtls_int_to_uint16(p, DTLS_VERSION); in dtls_send_client_hello()
2330 p += sizeof(uint16); in dtls_send_client_hello()
2346 memcpy(p, handshake->tmp.random.client, DTLS_RANDOM_LENGTH); in dtls_send_client_hello()
2347 p += DTLS_RANDOM_LENGTH; in dtls_send_client_hello()
2350 dtls_int_to_uint8(p, 0); in dtls_send_client_hello()
2351 p += sizeof(uint8); in dtls_send_client_hello()
2354 dtls_int_to_uint8(p, cookie_length); in dtls_send_client_hello()
2355 p += sizeof(uint8); in dtls_send_client_hello()
2357 memcpy(p, cookie, cookie_length); in dtls_send_client_hello()
2358 p += cookie_length; in dtls_send_client_hello()
2362 dtls_int_to_uint16(p, cipher_size - 2); in dtls_send_client_hello()
2363 p += sizeof(uint16); in dtls_send_client_hello()
2366 dtls_int_to_uint16(p, TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8); in dtls_send_client_hello()
2367 p += sizeof(uint16); in dtls_send_client_hello()
2370 dtls_int_to_uint16(p, TLS_PSK_WITH_AES_128_CCM_8); in dtls_send_client_hello()
2371 p += sizeof(uint16); in dtls_send_client_hello()
2375 dtls_int_to_uint8(p, 1); in dtls_send_client_hello()
2376 p += sizeof(uint8); in dtls_send_client_hello()
2378 dtls_int_to_uint8(p, TLS_COMPRESSION_NULL); in dtls_send_client_hello()
2379 p += sizeof(uint8); in dtls_send_client_hello()
2383 dtls_int_to_uint16(p, extension_size - 2); in dtls_send_client_hello()
2384 p += sizeof(uint16); in dtls_send_client_hello()
2389 dtls_int_to_uint16(p, TLS_EXT_CLIENT_CERTIFICATE_TYPE); in dtls_send_client_hello()
2390 p += sizeof(uint16); in dtls_send_client_hello()
2393 dtls_int_to_uint16(p, 2); in dtls_send_client_hello()
2394 p += sizeof(uint16); in dtls_send_client_hello()
2397 dtls_int_to_uint8(p, 1); in dtls_send_client_hello()
2398 p += sizeof(uint8); in dtls_send_client_hello()
2400 dtls_int_to_uint8(p, TLS_CERT_TYPE_RAW_PUBLIC_KEY); in dtls_send_client_hello()
2401 p += sizeof(uint8); in dtls_send_client_hello()
2404 dtls_int_to_uint16(p, TLS_EXT_SERVER_CERTIFICATE_TYPE); in dtls_send_client_hello()
2405 p += sizeof(uint16); in dtls_send_client_hello()
2408 dtls_int_to_uint16(p, 2); in dtls_send_client_hello()
2409 p += sizeof(uint16); in dtls_send_client_hello()
2412 dtls_int_to_uint8(p, 1); in dtls_send_client_hello()
2413 p += sizeof(uint8); in dtls_send_client_hello()
2415 dtls_int_to_uint8(p, TLS_CERT_TYPE_RAW_PUBLIC_KEY); in dtls_send_client_hello()
2416 p += sizeof(uint8); in dtls_send_client_hello()
2419 dtls_int_to_uint16(p, TLS_EXT_ELLIPTIC_CURVES); in dtls_send_client_hello()
2420 p += sizeof(uint16); in dtls_send_client_hello()
2423 dtls_int_to_uint16(p, 4); in dtls_send_client_hello()
2424 p += sizeof(uint16); in dtls_send_client_hello()
2427 dtls_int_to_uint16(p, 2); in dtls_send_client_hello()
2428 p += sizeof(uint16); in dtls_send_client_hello()
2430 dtls_int_to_uint16(p, TLS_EXT_ELLIPTIC_CURVES_SECP256R1); in dtls_send_client_hello()
2431 p += sizeof(uint16); in dtls_send_client_hello()
2434 dtls_int_to_uint16(p, TLS_EXT_EC_POINT_FORMATS); in dtls_send_client_hello()
2435 p += sizeof(uint16); in dtls_send_client_hello()
2438 dtls_int_to_uint16(p, 2); in dtls_send_client_hello()
2439 p += sizeof(uint16); in dtls_send_client_hello()
2442 dtls_int_to_uint8(p, 1); in dtls_send_client_hello()
2443 p += sizeof(uint8); in dtls_send_client_hello()
2445 dtls_int_to_uint8(p, TLS_EXT_EC_POINT_FORMATS_UNCOMPRESSED); in dtls_send_client_hello()
2446 p += sizeof(uint8); in dtls_send_client_hello()
2449 assert(p - buf <= sizeof(buf)); in dtls_send_client_hello()
2456 buf, p - buf, cookie_length != 0); in dtls_send_client_hello()
3803 dtls_peer_t *p; in dtls_free_context() local
3813 HASH_ITER(hh, ctx->peers, p, tmp) { in dtls_free_context()
3814 dtls_destroy_peer(ctx, p, 1); in dtls_free_context()
3818 for (p = list_head(ctx->peers); p; p = list_item_next(p)) in dtls_free_context()
3819 dtls_destroy_peer(ctx, p, 1); in dtls_free_context()