mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 10:47:19 +02:00
mbedtls: replace low-level sha apis with md apis in esp_ssl_tls
This commit is contained in:
@ -4,6 +4,7 @@
|
|||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
#include "mbedtls/error.h"
|
||||||
#include "esp_mbedtls_dynamic_impl.h"
|
#include "esp_mbedtls_dynamic_impl.h"
|
||||||
|
|
||||||
int __real_mbedtls_ssl_write(mbedtls_ssl_context *ssl, unsigned char *buf, size_t len);
|
int __real_mbedtls_ssl_write(mbedtls_ssl_context *ssl, unsigned char *buf, size_t len);
|
||||||
@ -42,15 +43,17 @@ static int rx_done(mbedtls_ssl_context *ssl)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ssl_update_checksum_start( mbedtls_ssl_context *ssl,
|
static int ssl_update_checksum_start( mbedtls_ssl_context *ssl,
|
||||||
const unsigned char *buf, size_t len )
|
const unsigned char *buf, size_t len )
|
||||||
{
|
{
|
||||||
|
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||||
#if defined(MBEDTLS_SHA256_C)
|
#if defined(MBEDTLS_SHA256_C)
|
||||||
mbedtls_sha256_update( &ssl->handshake->fin_sha256, buf, len );
|
ret = mbedtls_md_update( &ssl->handshake->fin_sha256, buf, len );
|
||||||
#endif
|
#endif
|
||||||
#if defined(MBEDTLS_SHA512_C)
|
#if defined(MBEDTLS_SHA512_C)
|
||||||
mbedtls_sha512_update( &ssl->handshake->fin_sha384, buf, len );
|
ret = mbedtls_md_update( &ssl->handshake->fin_sha384, buf, len );
|
||||||
#endif
|
#endif
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ssl_handshake_params_init( mbedtls_ssl_handshake_params *handshake )
|
static void ssl_handshake_params_init( mbedtls_ssl_handshake_params *handshake )
|
||||||
@ -58,12 +61,18 @@ static void ssl_handshake_params_init( mbedtls_ssl_handshake_params *handshake )
|
|||||||
memset( handshake, 0, sizeof( mbedtls_ssl_handshake_params ) );
|
memset( handshake, 0, sizeof( mbedtls_ssl_handshake_params ) );
|
||||||
|
|
||||||
#if defined(MBEDTLS_SHA256_C)
|
#if defined(MBEDTLS_SHA256_C)
|
||||||
mbedtls_sha256_init( &handshake->fin_sha256 );
|
mbedtls_md_init( &handshake->fin_sha256 );
|
||||||
mbedtls_sha256_starts( &handshake->fin_sha256, 0 );
|
mbedtls_md_setup( &handshake->fin_sha256,
|
||||||
|
mbedtls_md_info_from_type(MBEDTLS_MD_SHA256),
|
||||||
|
0 );
|
||||||
|
mbedtls_md_starts( &handshake->fin_sha256 );
|
||||||
#endif
|
#endif
|
||||||
#if defined(MBEDTLS_SHA512_C)
|
#if defined(MBEDTLS_SHA512_C)
|
||||||
mbedtls_sha512_init( &handshake->fin_sha384 );
|
mbedtls_md_init( &handshake->fin_sha384 );
|
||||||
mbedtls_sha512_starts( &handshake->fin_sha384, 1 );
|
mbedtls_md_setup( &handshake->fin_sha384,
|
||||||
|
mbedtls_md_info_from_type(MBEDTLS_MD_SHA384),
|
||||||
|
0 );
|
||||||
|
mbedtls_md_starts( &handshake->fin_sha384 );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
handshake->update_checksum = ssl_update_checksum_start;
|
handshake->update_checksum = ssl_update_checksum_start;
|
||||||
|
Reference in New Issue
Block a user