mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-03-04 13:09:40 +00:00
mbedtls_ssl_cookie_check: zeroize expected cookie on cookie mismatch
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
b3f4e5b1e1
commit
69d3b86baa
|
@ -218,15 +218,20 @@ int mbedtls_ssl_cookie_check( void *p_ctx,
|
||||||
|
|
||||||
#if defined(MBEDTLS_THREADING_C)
|
#if defined(MBEDTLS_THREADING_C)
|
||||||
if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 )
|
if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 )
|
||||||
return( MBEDTLS_ERROR_ADD( MBEDTLS_ERR_SSL_INTERNAL_ERROR,
|
{
|
||||||
MBEDTLS_ERR_THREADING_MUTEX_ERROR ) );
|
ret = MBEDTLS_ERROR_ADD( MBEDTLS_ERR_SSL_INTERNAL_ERROR,
|
||||||
|
MBEDTLS_ERR_THREADING_MUTEX_ERROR );
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
return( ret );
|
goto exit;
|
||||||
|
|
||||||
if( mbedtls_ct_memcmp( cookie + 4, ref_hmac, sizeof( ref_hmac ) ) != 0 )
|
if( mbedtls_ct_memcmp( cookie + 4, ref_hmac, sizeof( ref_hmac ) ) != 0 )
|
||||||
return( -1 );
|
{
|
||||||
|
ret = -1;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(MBEDTLS_HAVE_TIME)
|
#if defined(MBEDTLS_HAVE_TIME)
|
||||||
cur_time = (unsigned long) mbedtls_time( NULL );
|
cur_time = (unsigned long) mbedtls_time( NULL );
|
||||||
|
@ -240,8 +245,13 @@ int mbedtls_ssl_cookie_check( void *p_ctx,
|
||||||
( (unsigned long) cookie[3] );
|
( (unsigned long) cookie[3] );
|
||||||
|
|
||||||
if( ctx->timeout != 0 && cur_time - cookie_time > ctx->timeout )
|
if( ctx->timeout != 0 && cur_time - cookie_time > ctx->timeout )
|
||||||
return( -1 );
|
{
|
||||||
|
ret = -1;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
return( 0 );
|
exit:
|
||||||
|
mbedtls_platform_zeroize( ref_hmac, sizeof( ref_hmac ) );
|
||||||
|
return( ret );
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_SSL_COOKIE_C */
|
#endif /* MBEDTLS_SSL_COOKIE_C */
|
||||||
|
|
Loading…
Reference in a new issue