Remove a kludge for the output size of mbedtls_sha512_finish_ret
Remove a kludge to avoid a warning in GCC 11 when calling mbedtls_sha512_finish_ret with a 48-byte output buffer. This is correct since we're calculating SHA-384. When mbedtls_sha512_finish_ret's output parameter was declared as a 64-byte array, GCC 11 -Wstringop-overflow emitted a well-meaning, but inaccurate buffer overflow warning, which we tried to work around (successfully with beta releases but unsuccessfully with GCC 11.1.0 as released). Now that the output parameter is declared as a pointer, no workaround is necessary. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
e02e02f203
commit
3e3a6789d1
1 changed files with 1 additions and 9 deletions
|
@ -2897,8 +2897,6 @@ static void ssl_calc_finished_tls_sha256(
|
||||||
|
|
||||||
#if defined(MBEDTLS_SHA512_C)
|
#if defined(MBEDTLS_SHA512_C)
|
||||||
|
|
||||||
typedef int (*finish_sha384_t)(mbedtls_sha512_context*, unsigned char*);
|
|
||||||
|
|
||||||
static void ssl_calc_finished_tls_sha384(
|
static void ssl_calc_finished_tls_sha384(
|
||||||
mbedtls_ssl_context *ssl, unsigned char *buf, int from )
|
mbedtls_ssl_context *ssl, unsigned char *buf, int from )
|
||||||
{
|
{
|
||||||
|
@ -2957,13 +2955,7 @@ static void ssl_calc_finished_tls_sha384(
|
||||||
MBEDTLS_SSL_DEBUG_BUF( 4, "finished sha512 state", (unsigned char *)
|
MBEDTLS_SSL_DEBUG_BUF( 4, "finished sha512 state", (unsigned char *)
|
||||||
sha512.state, sizeof( sha512.state ) );
|
sha512.state, sizeof( sha512.state ) );
|
||||||
#endif
|
#endif
|
||||||
/*
|
mbedtls_sha512_finish_ret( &sha512, padbuf );
|
||||||
* For SHA-384, we can save 16 bytes by keeping padbuf 48 bytes long.
|
|
||||||
* However, to avoid stringop-overflow warning in gcc, we have to cast
|
|
||||||
* mbedtls_sha512_finish_ret().
|
|
||||||
*/
|
|
||||||
finish_sha384_t finish = (finish_sha384_t)mbedtls_sha512_finish_ret;
|
|
||||||
finish( &sha512, padbuf );
|
|
||||||
|
|
||||||
mbedtls_sha512_free( &sha512 );
|
mbedtls_sha512_free( &sha512 );
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue