Lines Matching refs:ctx
78 void mbedtls_ssl_cookie_init( mbedtls_ssl_cookie_ctx *ctx ) in mbedtls_ssl_cookie_init() argument
80 mbedtls_md_init( &ctx->hmac_ctx ); in mbedtls_ssl_cookie_init()
82 ctx->serial = 0; in mbedtls_ssl_cookie_init()
84 ctx->timeout = MBEDTLS_SSL_COOKIE_TIMEOUT; in mbedtls_ssl_cookie_init()
87 mbedtls_mutex_init( &ctx->mutex ); in mbedtls_ssl_cookie_init()
91 void mbedtls_ssl_cookie_set_timeout( mbedtls_ssl_cookie_ctx *ctx, unsigned long delay ) in mbedtls_ssl_cookie_set_timeout() argument
93 ctx->timeout = delay; in mbedtls_ssl_cookie_set_timeout()
96 void mbedtls_ssl_cookie_free( mbedtls_ssl_cookie_ctx *ctx ) in mbedtls_ssl_cookie_free() argument
98 mbedtls_md_free( &ctx->hmac_ctx ); in mbedtls_ssl_cookie_free()
101 mbedtls_mutex_init( &ctx->mutex ); in mbedtls_ssl_cookie_free()
104 mbedtls_zeroize( ctx, sizeof( mbedtls_ssl_cookie_ctx ) ); in mbedtls_ssl_cookie_free()
107 int mbedtls_ssl_cookie_setup( mbedtls_ssl_cookie_ctx *ctx, in mbedtls_ssl_cookie_setup() argument
117 ret = mbedtls_md_setup( &ctx->hmac_ctx, mbedtls_md_info_from_type( COOKIE_MD ), 1 ); in mbedtls_ssl_cookie_setup()
121 ret = mbedtls_md_hmac_starts( &ctx->hmac_ctx, key, sizeof( key ) ); in mbedtls_ssl_cookie_setup()
165 mbedtls_ssl_cookie_ctx *ctx = (mbedtls_ssl_cookie_ctx *) p_ctx; in mbedtls_ssl_cookie_write() local
168 if( ctx == NULL || cli_id == NULL ) in mbedtls_ssl_cookie_write()
177 t = ctx->serial++; in mbedtls_ssl_cookie_write()
187 if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 ) in mbedtls_ssl_cookie_write()
191 ret = ssl_cookie_hmac( &ctx->hmac_ctx, *p - 4, in mbedtls_ssl_cookie_write()
195 if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 ) in mbedtls_ssl_cookie_write()
213 mbedtls_ssl_cookie_ctx *ctx = (mbedtls_ssl_cookie_ctx *) p_ctx; in mbedtls_ssl_cookie_check() local
216 if( ctx == NULL || cli_id == NULL ) in mbedtls_ssl_cookie_check()
223 if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 ) in mbedtls_ssl_cookie_check()
227 if( ssl_cookie_hmac( &ctx->hmac_ctx, cookie, in mbedtls_ssl_cookie_check()
233 if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 ) in mbedtls_ssl_cookie_check()
247 cur_time = ctx->serial; in mbedtls_ssl_cookie_check()
255 if( ctx->timeout != 0 && cur_time - cookie_time > ctx->timeout ) in mbedtls_ssl_cookie_check()