mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-13 18:15:36 +00:00
Move compress_buf allocation to derive_keys
This commit is contained in:
parent
707728dfca
commit
a1abb26094
|
@ -978,23 +978,10 @@ static int ssl_populate_transform( mbedtls_ssl_context *ssl )
|
||||||
|
|
||||||
mbedtls_platform_zeroize( keyblk, sizeof( keyblk ) );
|
mbedtls_platform_zeroize( keyblk, sizeof( keyblk ) );
|
||||||
|
|
||||||
|
/* Initialize Zlib contexts */
|
||||||
#if defined(MBEDTLS_ZLIB_SUPPORT)
|
#if defined(MBEDTLS_ZLIB_SUPPORT)
|
||||||
// Initialize compression
|
|
||||||
//
|
|
||||||
if( session->compression == MBEDTLS_SSL_COMPRESS_DEFLATE )
|
if( session->compression == MBEDTLS_SSL_COMPRESS_DEFLATE )
|
||||||
{
|
{
|
||||||
if( ssl->compress_buf == NULL )
|
|
||||||
{
|
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 3, ( "Allocating compression buffer" ) );
|
|
||||||
ssl->compress_buf = mbedtls_calloc( 1, MBEDTLS_SSL_COMPRESS_BUFFER_LEN );
|
|
||||||
if( ssl->compress_buf == NULL )
|
|
||||||
{
|
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc(%d bytes) failed",
|
|
||||||
MBEDTLS_SSL_COMPRESS_BUFFER_LEN ) );
|
|
||||||
return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 3, ( "Initializing zlib states" ) );
|
MBEDTLS_SSL_DEBUG_MSG( 3, ( "Initializing zlib states" ) );
|
||||||
|
|
||||||
memset( &transform->ctx_deflate, 0, sizeof( transform->ctx_deflate ) );
|
memset( &transform->ctx_deflate, 0, sizeof( transform->ctx_deflate ) );
|
||||||
|
@ -1194,6 +1181,22 @@ int mbedtls_ssl_derive_keys( mbedtls_ssl_context *ssl )
|
||||||
mbedtls_platform_zeroize( ssl->handshake->randbytes,
|
mbedtls_platform_zeroize( ssl->handshake->randbytes,
|
||||||
sizeof( ssl->handshake->randbytes ) );
|
sizeof( ssl->handshake->randbytes ) );
|
||||||
|
|
||||||
|
/* Allocate compression buffer */
|
||||||
|
#if defined(MBEDTLS_ZLIB_SUPPORT)
|
||||||
|
if( session->compression == MBEDTLS_SSL_COMPRESS_DEFLATE &&
|
||||||
|
ssl->compress_buf == NULL )
|
||||||
|
{
|
||||||
|
MBEDTLS_SSL_DEBUG_MSG( 3, ( "Allocating compression buffer" ) );
|
||||||
|
ssl->compress_buf = mbedtls_calloc( 1, MBEDTLS_SSL_COMPRESS_BUFFER_LEN );
|
||||||
|
if( ssl->compress_buf == NULL )
|
||||||
|
{
|
||||||
|
MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc(%d bytes) failed",
|
||||||
|
MBEDTLS_SSL_COMPRESS_BUFFER_LEN ) );
|
||||||
|
return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= derive keys" ) );
|
MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= derive keys" ) );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
|
|
Loading…
Reference in a new issue