Replace instances of byte reading macros with PUT

Instances of a group of byte reading macros which are equivilant to
MBEDTLS_PUT_UINTx_yz

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
This commit is contained in:
Joe Subbiani 2021-07-16 15:02:55 +01:00
parent ad1115a3fd
commit 6627fb284a
3 changed files with 4 additions and 24 deletions

View File

@ -164,10 +164,7 @@ static void chacha20_block( const uint32_t initial_state[16],
{
size_t offset = i * 4U;
keystream[offset ] = MBEDTLS_BYTE_0( working_state[i] );
keystream[offset + 1U] = MBEDTLS_BYTE_1( working_state[i] );
keystream[offset + 2U] = MBEDTLS_BYTE_2( working_state[i] );
keystream[offset + 3U] = MBEDTLS_BYTE_3( working_state[i] );
MBEDTLS_PUT_UINT32_LE(working_state[i], keystream, offset);
}
mbedtls_platform_zeroize( working_state, sizeof( working_state ) );

View File

@ -263,22 +263,8 @@ int mbedtls_chachapoly_finish( mbedtls_chachapoly_context *ctx,
/* The lengths of the AAD and ciphertext are processed by
* Poly1305 as the final 128-bit block, encoded as little-endian integers.
*/
len_block[ 0] = MBEDTLS_BYTE_0( ctx->aad_len );
len_block[ 1] = MBEDTLS_BYTE_1( ctx->aad_len );
len_block[ 2] = MBEDTLS_BYTE_2( ctx->aad_len );
len_block[ 3] = MBEDTLS_BYTE_3( ctx->aad_len );
len_block[ 4] = MBEDTLS_BYTE_4( ctx->aad_len );
len_block[ 5] = MBEDTLS_BYTE_5( ctx->aad_len );
len_block[ 6] = MBEDTLS_BYTE_6( ctx->aad_len );
len_block[ 7] = MBEDTLS_BYTE_7( ctx->aad_len );
len_block[ 8] = MBEDTLS_BYTE_0( ctx->ciphertext_len );
len_block[ 9] = MBEDTLS_BYTE_1( ctx->ciphertext_len );
len_block[10] = MBEDTLS_BYTE_2( ctx->ciphertext_len );
len_block[11] = MBEDTLS_BYTE_3( ctx->ciphertext_len );
len_block[12] = MBEDTLS_BYTE_4( ctx->ciphertext_len );
len_block[13] = MBEDTLS_BYTE_5( ctx->ciphertext_len );
len_block[14] = MBEDTLS_BYTE_6( ctx->ciphertext_len );
len_block[15] = MBEDTLS_BYTE_7( ctx->ciphertext_len );
MBEDTLS_PUT_UINT64_LE(ctx->aad_len, len_block, 0);
MBEDTLS_PUT_UINT64_LE(ctx->ciphertext_len, len_block, 8);
ret = mbedtls_poly1305_update( &ctx->poly1305_ctx, len_block, 16U );
if( ret != 0 )

View File

@ -166,10 +166,7 @@ int mbedtls_ssl_cookie_write( void *p_ctx,
t = ctx->serial++;
#endif
(*p)[0] = MBEDTLS_BYTE_3( t );
(*p)[1] = MBEDTLS_BYTE_2( t );
(*p)[2] = MBEDTLS_BYTE_1( t );
(*p)[3] = MBEDTLS_BYTE_0( t );
MBEDTLS_PUT_UINT32_BE(t, *p, 0);
*p += 4;
#if defined(MBEDTLS_THREADING_C)