Lines Matching refs:g_env
391 const coap_gnutls_env_t *g_env = (const coap_gnutls_env_t *)c_session->tls; in coap_dtls_get_tls() local
393 return g_env->g_session; in coap_dtls_get_tls()
755 coap_gnutls_env_t *g_env = (coap_gnutls_env_t *)c_session->tls; in cert_verify_gnutls() local
920 if (!g_env->sent_alert) { in cert_verify_gnutls()
922 g_env->sent_alert = 1; in cert_verify_gnutls()
1473 coap_gnutls_env_t *g_env = (coap_gnutls_env_t *)c_session->tls; in post_client_hello_gnutls_psk() local
1535 g_env->sent_alert = 1; in post_client_hello_gnutls_psk()
1554 g_env->sent_alert = 1; in post_client_hello_gnutls_psk()
1560 G_CHECK(gnutls_credentials_set(g_env->g_session, GNUTLS_CRD_PSK, in post_client_hello_gnutls_psk()
1588 coap_gnutls_env_t *g_env = (coap_gnutls_env_t *)c_session->tls; in post_client_hello_gnutls_pki() local
1649 g_env->sent_alert = 1; in post_client_hello_gnutls_pki()
1669 g_env->sent_alert = 1; in post_client_hello_gnutls_pki()
1675 G_CHECK(gnutls_credentials_set(g_env->g_session, GNUTLS_CRD_CERTIFICATE, in post_client_hello_gnutls_pki()
1693 setup_client_ssl_session(coap_session_t *c_session, coap_gnutls_env_t *g_env) in setup_client_ssl_session() argument
1702 G_CHECK(gnutls_psk_allocate_client_credentials(&g_env->psk_cl_credentials), in setup_client_ssl_session()
1704 gnutls_psk_set_client_credentials_function(g_env->psk_cl_credentials, in setup_client_ssl_session()
1706 G_CHECK(gnutls_credentials_set(g_env->g_session, GNUTLS_CRD_PSK, in setup_client_ssl_session()
1707 g_env->psk_cl_credentials), in setup_client_ssl_session()
1711 G_CHECK(gnutls_server_name_set(g_env->g_session, GNUTLS_NAME_DNS, in setup_client_ssl_session()
1730 ret = gnutls_priority_set_direct(g_env->g_session, in setup_client_ssl_session()
1752 G_CHECK(setup_pki_credentials(&g_env->pki_credentials, g_env->g_session, in setup_client_ssl_session()
1757 G_CHECK(gnutls_credentials_set(g_env->g_session, GNUTLS_CRD_CERTIFICATE, in setup_client_ssl_session()
1758 g_env->pki_credentials), in setup_client_ssl_session()
1762 G_CHECK(gnutls_alpn_set_protocols(g_env->g_session, in setup_client_ssl_session()
1768 G_CHECK(gnutls_server_name_set(g_env->g_session, GNUTLS_NAME_DNS, in setup_client_ssl_session()
1858 setup_server_ssl_session(coap_session_t *c_session, coap_gnutls_env_t *g_env) in setup_server_ssl_session() argument
1867 &g_env->psk_sv_credentials, in setup_server_ssl_session()
1871 G_CHECK(gnutls_credentials_set(g_env->g_session, in setup_server_ssl_session()
1873 g_env->psk_sv_credentials), in setup_server_ssl_session()
1875 gnutls_handshake_set_post_client_hello_function(g_env->g_session, in setup_server_ssl_session()
1881 G_CHECK(setup_pki_credentials(&g_env->pki_credentials, g_env->g_session, in setup_server_ssl_session()
1887 gnutls_certificate_server_set_request(g_env->g_session, in setup_server_ssl_session()
1891 gnutls_certificate_server_set_request(g_env->g_session, in setup_server_ssl_session()
1895 gnutls_certificate_server_set_request(g_env->g_session, in setup_server_ssl_session()
1899 gnutls_handshake_set_post_client_hello_function(g_env->g_session, in setup_server_ssl_session()
1902 G_CHECK(gnutls_credentials_set(g_env->g_session, GNUTLS_CRD_CERTIFICATE, in setup_server_ssl_session()
1903 g_env->pki_credentials), in setup_server_ssl_session()
1993 coap_gnutls_env_t *g_env = (coap_gnutls_env_t *)c_session->tls; in receive_timeout() local
1996 if (c_session->proto == COAP_PROTO_DTLS && g_env && in receive_timeout()
1997 g_env->coap_ssl_data.pdu_len > 0) { in receive_timeout()
2005 if (!(g_env && g_env->doing_dtls_timeout)) { in receive_timeout()
2023 coap_gnutls_env_t *g_env = (coap_gnutls_env_t *)c_session->tls; in coap_dtls_new_gnutls_env() local
2031 if (g_env) in coap_dtls_new_gnutls_env()
2032 return g_env; in coap_dtls_new_gnutls_env()
2034 g_env = gnutls_malloc(sizeof(coap_gnutls_env_t)); in coap_dtls_new_gnutls_env()
2035 if (!g_env) in coap_dtls_new_gnutls_env()
2038 memset(g_env, 0, sizeof(coap_gnutls_env_t)); in coap_dtls_new_gnutls_env()
2040 G_CHECK(gnutls_init(&g_env->g_session, flags), "gnutls_init"); in coap_dtls_new_gnutls_env()
2042 gnutls_transport_set_pull_function(g_env->g_session, coap_dgram_read); in coap_dtls_new_gnutls_env()
2043 gnutls_transport_set_push_function(g_env->g_session, coap_dgram_write); in coap_dtls_new_gnutls_env()
2044 gnutls_transport_set_pull_timeout_function(g_env->g_session, receive_timeout); in coap_dtls_new_gnutls_env()
2046 gnutls_transport_set_ptr(g_env->g_session, c_session); in coap_dtls_new_gnutls_env()
2048 G_CHECK(gnutls_priority_set(g_env->g_session, g_context->priority_cache), in coap_dtls_new_gnutls_env()
2052 G_CHECK(setup_server_ssl_session(c_session, g_env), in coap_dtls_new_gnutls_env()
2056 G_CHECK(setup_client_ssl_session(c_session, g_env), in coap_dtls_new_gnutls_env()
2060 gnutls_handshake_set_timeout(g_env->g_session, in coap_dtls_new_gnutls_env()
2062 gnutls_dtls_set_timeouts(g_env->g_session, COAP_DTLS_RETRANSMIT_MS, in coap_dtls_new_gnutls_env()
2065 return g_env; in coap_dtls_new_gnutls_env()
2068 if (g_env) in coap_dtls_new_gnutls_env()
2069 gnutls_free(g_env); in coap_dtls_new_gnutls_env()
2075 coap_gnutls_env_t *g_env, in coap_dtls_free_gnutls_env() argument
2078 if (g_env) { in coap_dtls_free_gnutls_env()
2082 if (free_bye != COAP_FREE_BYE_NONE && !g_env->sent_alert) { in coap_dtls_free_gnutls_env()
2084 gnutls_bye(g_env->g_session, free_bye == COAP_FREE_BYE_AS_UDP ? in coap_dtls_free_gnutls_env()
2087 gnutls_deinit(g_env->g_session); in coap_dtls_free_gnutls_env()
2088 g_env->g_session = NULL; in coap_dtls_free_gnutls_env()
2091 g_env->psk_cl_credentials != NULL) { in coap_dtls_free_gnutls_env()
2092 gnutls_psk_free_client_credentials(g_env->psk_cl_credentials); in coap_dtls_free_gnutls_env()
2093 g_env->psk_cl_credentials = NULL; in coap_dtls_free_gnutls_env()
2097 if (g_env->psk_sv_credentials != NULL) in coap_dtls_free_gnutls_env()
2098 gnutls_psk_free_server_credentials(g_env->psk_sv_credentials); in coap_dtls_free_gnutls_env()
2099 g_env->psk_sv_credentials = NULL; in coap_dtls_free_gnutls_env()
2105 gnutls_certificate_free_credentials(g_env->pki_credentials); in coap_dtls_free_gnutls_env()
2106 g_env->pki_credentials = NULL; in coap_dtls_free_gnutls_env()
2108 gnutls_free(g_env->coap_ssl_data.cookie_key.data); in coap_dtls_free_gnutls_env()
2109 gnutls_free(g_env); in coap_dtls_free_gnutls_env()
2114 coap_gnutls_env_t *g_env = in coap_dtls_new_server_session() local
2117 gnutls_transport_set_ptr(g_env->g_session, c_session); in coap_dtls_new_server_session()
2119 return g_env; in coap_dtls_new_server_session()
2142 do_gnutls_handshake(coap_session_t *c_session, coap_gnutls_env_t *g_env) { in do_gnutls_handshake() argument
2145 ret = gnutls_handshake(g_env->g_session); in do_gnutls_handshake()
2148 g_env->established = 1; in do_gnutls_handshake()
2168 g_env->sent_alert = 1; in do_gnutls_handshake()
2169 log_last_alert(c_session, g_env->g_session); in do_gnutls_handshake()
2176 log_last_alert(c_session, g_env->g_session); in do_gnutls_handshake()
2187 G_ACTION(gnutls_alert_send(g_env->g_session, GNUTLS_AL_FATAL, in do_gnutls_handshake()
2189 g_env->sent_alert = 1; in do_gnutls_handshake()
2198 G_ACTION(gnutls_alert_send(g_env->g_session, GNUTLS_AL_FATAL, in do_gnutls_handshake()
2200 g_env->sent_alert = 1; in do_gnutls_handshake()
2205 if (g_env->sent_alert) { in do_gnutls_handshake()
2218 if (!g_env->sent_alert) { in do_gnutls_handshake()
2219 G_ACTION(gnutls_alert_send(g_env->g_session, GNUTLS_AL_FATAL, in do_gnutls_handshake()
2221 g_env->sent_alert = 1; in do_gnutls_handshake()
2245 coap_gnutls_env_t *g_env = coap_dtls_new_gnutls_env(c_session, GNUTLS_CLIENT); in coap_dtls_new_client_session() local
2248 if (g_env) { in coap_dtls_new_client_session()
2249 ret = do_gnutls_handshake(c_session, g_env); in coap_dtls_new_client_session()
2252 g_env, in coap_dtls_new_client_session()
2258 return g_env; in coap_dtls_new_client_session()
2273 coap_gnutls_env_t *g_env = (coap_gnutls_env_t *)c_session->tls; in coap_dtls_session_update_mtu() local
2276 if (g_env) in coap_dtls_session_update_mtu()
2277 G_CHECK(gnutls_dtls_set_data_mtu(g_env->g_session, in coap_dtls_session_update_mtu()
2292 coap_gnutls_env_t *g_env = (coap_gnutls_env_t *)c_session->tls; in coap_dtls_send() local
2294 assert(g_env != NULL); in coap_dtls_send()
2297 if (g_env->established) { in coap_dtls_send()
2298 ret = gnutls_record_send(g_env->g_session, data, data_len); in coap_dtls_send()
2307 g_env->sent_alert = 1; in coap_dtls_send()
2308 log_last_alert(c_session, g_env->g_session); in coap_dtls_send()
2326 ret = do_gnutls_handshake(c_session, g_env); in coap_dtls_send()
2355 coap_gnutls_env_t *g_env = (coap_gnutls_env_t *)c_session->tls; in coap_dtls_get_timeout() local
2358 if (g_env && g_env->g_session) { in coap_dtls_get_timeout()
2359 unsigned int rem_ms = gnutls_dtls_get_timeout(g_env->g_session); in coap_dtls_get_timeout()
2368 if (g_env->last_timeout + COAP_DTLS_RETRANSMIT_COAP_TICKS > now) in coap_dtls_get_timeout()
2369 return g_env->last_timeout + COAP_DTLS_RETRANSMIT_COAP_TICKS; in coap_dtls_get_timeout()
2372 g_env->last_timeout = now; in coap_dtls_get_timeout()
2380 coap_gnutls_env_t *g_env = (coap_gnutls_env_t *)c_session->tls; in coap_dtls_handle_timeout() local
2382 assert(g_env != NULL && c_session->state == COAP_SESSION_STATE_HANDSHAKE); in coap_dtls_handle_timeout()
2383 g_env->doing_dtls_timeout = 1; in coap_dtls_handle_timeout()
2385 (do_gnutls_handshake(c_session, g_env) < 0)) { in coap_dtls_handle_timeout()
2387 g_env->doing_dtls_timeout = 0; in coap_dtls_handle_timeout()
2391 g_env->doing_dtls_timeout = 0; in coap_dtls_handle_timeout()
2405 coap_gnutls_env_t *g_env = (coap_gnutls_env_t *)c_session->tls; in coap_dtls_receive() local
2407 coap_ssl_t *ssl_data = &g_env->coap_ssl_data; in coap_dtls_receive()
2411 assert(g_env != NULL); in coap_dtls_receive()
2420 if (g_env->established) { in coap_dtls_receive()
2424 gnutls_transport_set_ptr(g_env->g_session, c_session); in coap_dtls_receive()
2427 ret = gnutls_record_recv(g_env->g_session, pdu, (int)sizeof(pdu)); in coap_dtls_receive()
2438 g_env->sent_alert = 1; in coap_dtls_receive()
2439 log_last_alert(c_session, g_env->g_session); in coap_dtls_receive()
2444 log_last_alert(c_session, g_env->g_session); in coap_dtls_receive()
2457 ret = do_gnutls_handshake(c_session, g_env); in coap_dtls_receive()
2463 if (ssl_data->pdu_len && !g_env->sent_alert) { in coap_dtls_receive()
2465 ret = do_gnutls_handshake(c_session, g_env); in coap_dtls_receive()
2504 coap_gnutls_env_t *g_env = (coap_gnutls_env_t *)c_session->tls; in coap_dtls_hello() local
2508 if (!g_env) { in coap_dtls_hello()
2509 g_env = coap_dtls_new_gnutls_env(c_session, GNUTLS_SERVER); in coap_dtls_hello()
2510 if (g_env) { in coap_dtls_hello()
2511 c_session->tls = g_env; in coap_dtls_hello()
2512 gnutls_key_generate(&g_env->coap_ssl_data.cookie_key, in coap_dtls_hello()
2527 ret = gnutls_dtls_cookie_verify(&g_env->coap_ssl_data.cookie_key, in coap_dtls_hello()
2534 gnutls_dtls_cookie_send(&g_env->coap_ssl_data.cookie_key, in coap_dtls_hello()
2542 gnutls_dtls_prestate_set(g_env->g_session, &prestate); in coap_dtls_hello()
2545 ssl_data = &g_env->coap_ssl_data; in coap_dtls_hello()
2549 ret = do_gnutls_handshake(c_session, g_env); in coap_dtls_hello()
2557 g_env, COAP_FREE_BYE_NONE); in coap_dtls_hello()
2662 coap_gnutls_env_t *g_env = gnutls_malloc(sizeof(coap_gnutls_env_t)); in coap_tls_new_client_session() local
2672 if (!g_env) { in coap_tls_new_client_session()
2675 memset(g_env, 0, sizeof(coap_gnutls_env_t)); in coap_tls_new_client_session()
2678 G_CHECK(gnutls_init(&g_env->g_session, flags), "gnutls_init"); in coap_tls_new_client_session()
2680 gnutls_transport_set_pull_function(g_env->g_session, coap_sock_read); in coap_tls_new_client_session()
2681 gnutls_transport_set_push_function(g_env->g_session, coap_sock_write); in coap_tls_new_client_session()
2682 gnutls_transport_set_pull_timeout_function(g_env->g_session, receive_timeout); in coap_tls_new_client_session()
2684 gnutls_transport_set_ptr(g_env->g_session, c_session); in coap_tls_new_client_session()
2686 gnutls_priority_set(g_env->g_session, g_context->priority_cache); in coap_tls_new_client_session()
2687 setup_client_ssl_session(c_session, g_env); in coap_tls_new_client_session()
2689 gnutls_handshake_set_timeout(g_env->g_session, GNUTLS_DEFAULT_HANDSHAKE_TIMEOUT); in coap_tls_new_client_session()
2691 c_session->tls = g_env; in coap_tls_new_client_session()
2692 ret = do_gnutls_handshake(c_session, g_env); in coap_tls_new_client_session()
2698 return g_env; in coap_tls_new_client_session()
2701 if (g_env) in coap_tls_new_client_session()
2702 gnutls_free(g_env); in coap_tls_new_client_session()
2707 coap_gnutls_env_t *g_env = gnutls_malloc(sizeof(coap_gnutls_env_t)); in coap_tls_new_server_session() local
2717 if (!g_env) in coap_tls_new_server_session()
2719 memset(g_env, 0, sizeof(coap_gnutls_env_t)); in coap_tls_new_server_session()
2722 G_CHECK(gnutls_init(&g_env->g_session, flags), "gnutls_init"); in coap_tls_new_server_session()
2724 gnutls_transport_set_pull_function(g_env->g_session, coap_sock_read); in coap_tls_new_server_session()
2725 gnutls_transport_set_push_function(g_env->g_session, coap_sock_write); in coap_tls_new_server_session()
2726 gnutls_transport_set_pull_timeout_function(g_env->g_session, receive_timeout); in coap_tls_new_server_session()
2728 gnutls_transport_set_ptr(g_env->g_session, c_session); in coap_tls_new_server_session()
2730 setup_server_ssl_session(c_session, g_env); in coap_tls_new_server_session()
2732 gnutls_priority_set(g_env->g_session, g_context->priority_cache); in coap_tls_new_server_session()
2733 gnutls_handshake_set_timeout(g_env->g_session, in coap_tls_new_server_session()
2736 c_session->tls = g_env; in coap_tls_new_server_session()
2737 ret = do_gnutls_handshake(c_session, g_env); in coap_tls_new_server_session()
2741 return g_env; in coap_tls_new_server_session()
2762 coap_gnutls_env_t *g_env = (coap_gnutls_env_t *)c_session->tls; in coap_tls_write() local
2764 assert(g_env != NULL); in coap_tls_write()
2767 if (g_env->established) { in coap_tls_write()
2768 ret = gnutls_record_send(g_env->g_session, data, data_len); in coap_tls_write()
2783 g_env->sent_alert = 1; in coap_tls_write()
2784 log_last_alert(c_session, g_env->g_session); in coap_tls_write()
2802 ret = do_gnutls_handshake(c_session, g_env); in coap_tls_write()
2836 coap_gnutls_env_t *g_env = (coap_gnutls_env_t *)c_session->tls; in coap_tls_read() local
2839 if (!g_env) in coap_tls_read()
2843 if (!g_env->established && !g_env->sent_alert) { in coap_tls_read()
2844 ret = do_gnutls_handshake(c_session, g_env); in coap_tls_read()
2851 if (c_session->state != COAP_SESSION_STATE_NONE && g_env->established) { in coap_tls_read()
2852 ret = gnutls_record_recv(g_env->g_session, data, (int)data_len); in coap_tls_read()
2867 g_env->sent_alert = 1; in coap_tls_read()
2868 log_last_alert(c_session, g_env->g_session); in coap_tls_read()
2873 log_last_alert(c_session, g_env->g_session); in coap_tls_read()