mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-24 05:45:41 +00:00
Fix GCC warning in ssl_calc_finished_tls_sha384
This commit fixes the same warning fixed by baeedbf9, but without wasting RAM. By casting `mbedtls_sha512_finish_ret()`, `padbuf` could be kept 48 bytes long without triggering any warnings. Signed-off-by: Rodrigo Dias Correa <rodrigo@correas.us>
This commit is contained in:
parent
ddcc0b7982
commit
d7853a847d
|
@ -5405,13 +5405,16 @@ static void ssl_calc_finished_tls_sha256(
|
||||||
#endif /* MBEDTLS_SHA256_C */
|
#endif /* MBEDTLS_SHA256_C */
|
||||||
|
|
||||||
#if defined(MBEDTLS_SHA512_C)
|
#if defined(MBEDTLS_SHA512_C)
|
||||||
|
|
||||||
|
typedef int (*finish_sha384_t)(mbedtls_sha512_context*, unsigned char[48]);
|
||||||
|
|
||||||
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 )
|
||||||
{
|
{
|
||||||
int len = 12;
|
int len = 12;
|
||||||
const char *sender;
|
const char *sender;
|
||||||
mbedtls_sha512_context sha512;
|
mbedtls_sha512_context sha512;
|
||||||
unsigned char padbuf[64];
|
unsigned char padbuf[48];
|
||||||
|
|
||||||
mbedtls_ssl_session *session = ssl->session_negotiate;
|
mbedtls_ssl_session *session = ssl->session_negotiate;
|
||||||
if( !session )
|
if( !session )
|
||||||
|
@ -5438,7 +5441,13 @@ static void ssl_calc_finished_tls_sha384(
|
||||||
? "client finished"
|
? "client finished"
|
||||||
: "server finished";
|
: "server finished";
|
||||||
|
|
||||||
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 );
|
||||||
|
|
||||||
ssl->handshake->tls_prf( session->master, 48, sender,
|
ssl->handshake->tls_prf( session->master, 48, sender,
|
||||||
padbuf, 48, buf, len );
|
padbuf, 48, buf, len );
|
||||||
|
|
Loading…
Reference in a new issue