1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-28 00:21:48 +03:00

Tidy up grouped MBEDTLS_BYTE_x macros

exchange groups of the byte reading macros with MBEDTLS_PUT_UINTxyz
and then shift the pointer afterwards. Easier to read as you can
see how big the data is that you are putting in, and in the case of
UINT32 AND UINT64 it saves some vertical space.

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
This commit is contained in:
Joe Subbiani
2021-08-23 11:35:25 +01:00
parent 94180e708f
commit a5cb0d24d4
3 changed files with 13 additions and 23 deletions

View File

@ -180,10 +180,7 @@ static int ecjpake_write_len_point( unsigned char **p,
if( ret != 0 )
return( ret );
(*p)[0] = MBEDTLS_BYTE_3( len );
(*p)[1] = MBEDTLS_BYTE_2( len );
(*p)[2] = MBEDTLS_BYTE_1( len );
(*p)[3] = MBEDTLS_BYTE_0( len );
MBEDTLS_PUT_UINT32_BE( len, *p, 0 );
*p += 4 + len;
@ -223,10 +220,8 @@ static int ecjpake_hash( const mbedtls_md_info_t *md_info,
if( end - p < 4 )
return( MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL );
*p++ = MBEDTLS_BYTE_3( id_len );
*p++ = MBEDTLS_BYTE_2( id_len );
*p++ = MBEDTLS_BYTE_1( id_len );
*p++ = MBEDTLS_BYTE_0( id_len );
MBEDTLS_PUT_UINT32_BE( id_len, p, 0 );
p += 4;
if( end < p || (size_t)( end - p ) < id_len )
return( MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL );