GET macros use a target variable
The GET macros used to write to a macro parameter, but now
they can be used to assign a value to the desired variable
rather than pass it in as an argument and have it modified
in the macro function.
Due to this MBEDTLS_BYTES_TO_U32_LE is the same as
MBEDTLS_GET_UINT32_LE and was there for replaced in the
appropriate files and removed from common.h
Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
diff --git a/library/chacha20.c b/library/chacha20.c
index d0d5741..7015f99 100644
--- a/library/chacha20.c
+++ b/library/chacha20.c
@@ -205,14 +205,14 @@
ctx->state[3] = 0x6b206574;
/* Set key */
- ctx->state[4] = MBEDTLS_BYTES_TO_U32_LE( key, 0 );
- ctx->state[5] = MBEDTLS_BYTES_TO_U32_LE( key, 4 );
- ctx->state[6] = MBEDTLS_BYTES_TO_U32_LE( key, 8 );
- ctx->state[7] = MBEDTLS_BYTES_TO_U32_LE( key, 12 );
- ctx->state[8] = MBEDTLS_BYTES_TO_U32_LE( key, 16 );
- ctx->state[9] = MBEDTLS_BYTES_TO_U32_LE( key, 20 );
- ctx->state[10] = MBEDTLS_BYTES_TO_U32_LE( key, 24 );
- ctx->state[11] = MBEDTLS_BYTES_TO_U32_LE( key, 28 );
+ ctx->state[4] = MBEDTLS_GET_UINT32_LE( key, 0 );
+ ctx->state[5] = MBEDTLS_GET_UINT32_LE( key, 4 );
+ ctx->state[6] = MBEDTLS_GET_UINT32_LE( key, 8 );
+ ctx->state[7] = MBEDTLS_GET_UINT32_LE( key, 12 );
+ ctx->state[8] = MBEDTLS_GET_UINT32_LE( key, 16 );
+ ctx->state[9] = MBEDTLS_GET_UINT32_LE( key, 20 );
+ ctx->state[10] = MBEDTLS_GET_UINT32_LE( key, 24 );
+ ctx->state[11] = MBEDTLS_GET_UINT32_LE( key, 28 );
return( 0 );
}
@@ -228,9 +228,9 @@
ctx->state[12] = counter;
/* Nonce */
- ctx->state[13] = MBEDTLS_BYTES_TO_U32_LE( nonce, 0 );
- ctx->state[14] = MBEDTLS_BYTES_TO_U32_LE( nonce, 4 );
- ctx->state[15] = MBEDTLS_BYTES_TO_U32_LE( nonce, 8 );
+ ctx->state[13] = MBEDTLS_GET_UINT32_LE( nonce, 0 );
+ ctx->state[14] = MBEDTLS_GET_UINT32_LE( nonce, 4 );
+ ctx->state[15] = MBEDTLS_GET_UINT32_LE( nonce, 8 );
mbedtls_platform_zeroize( ctx->keystream8, sizeof( ctx->keystream8 ) );