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/aes.c b/library/aes.c
index db726fe..7a44a78 100644
--- a/library/aes.c
+++ b/library/aes.c
@@ -567,7 +567,7 @@
 
     for( i = 0; i < ( keybits >> 5 ); i++ )
     {
-        MBEDTLS_GET_UINT32_LE( RK[i], key, i << 2 );
+        RK[i] = MBEDTLS_GET_UINT32_LE( key, i << 2 );
     }
 
     switch( ctx->nr )
@@ -850,10 +850,10 @@
         uint32_t Y[4];
     } t;
 
-    MBEDTLS_GET_UINT32_LE( t.X[0], input,  0 ); t.X[0] ^= *RK++;
-    MBEDTLS_GET_UINT32_LE( t.X[1], input,  4 ); t.X[1] ^= *RK++;
-    MBEDTLS_GET_UINT32_LE( t.X[2], input,  8 ); t.X[2] ^= *RK++;
-    MBEDTLS_GET_UINT32_LE( t.X[3], input, 12 ); t.X[3] ^= *RK++;
+    t.X[0] = MBEDTLS_GET_UINT32_LE( input,  0 ); t.X[0] ^= *RK++;
+    t.X[1] = MBEDTLS_GET_UINT32_LE( input,  4 ); t.X[1] ^= *RK++;
+    t.X[2] = MBEDTLS_GET_UINT32_LE( input,  8 ); t.X[2] ^= *RK++;
+    t.X[3] = MBEDTLS_GET_UINT32_LE( input, 12 ); t.X[3] ^= *RK++;
 
     for( i = ( ctx->nr >> 1 ) - 1; i > 0; i-- )
     {
@@ -914,10 +914,10 @@
         uint32_t Y[4];
     } t;
 
-    MBEDTLS_GET_UINT32_LE( t.X[0], input,  0 ); t.X[0] ^= *RK++;
-    MBEDTLS_GET_UINT32_LE( t.X[1], input,  4 ); t.X[1] ^= *RK++;
-    MBEDTLS_GET_UINT32_LE( t.X[2], input,  8 ); t.X[2] ^= *RK++;
-    MBEDTLS_GET_UINT32_LE( t.X[3], input, 12 ); t.X[3] ^= *RK++;
+    t.X[0] = MBEDTLS_GET_UINT32_LE( input,  0 ); t.X[0] ^= *RK++;
+    t.X[1] = MBEDTLS_GET_UINT32_LE( input,  4 ); t.X[1] ^= *RK++;
+    t.X[2] = MBEDTLS_GET_UINT32_LE( input,  8 ); t.X[2] ^= *RK++;
+    t.X[3] = MBEDTLS_GET_UINT32_LE( input, 12 ); t.X[3] ^= *RK++;
 
     for( i = ( ctx->nr >> 1 ) - 1; i > 0; i-- )
     {
diff --git a/library/aria.c b/library/aria.c
index f4aa641..320f775 100644
--- a/library/aria.c
+++ b/library/aria.c
@@ -434,21 +434,21 @@
         return( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA );
 
     /* Copy key to W0 (and potential remainder to W1) */
-    MBEDTLS_GET_UINT32_LE( w[0][0], key,  0 );
-    MBEDTLS_GET_UINT32_LE( w[0][1], key,  4 );
-    MBEDTLS_GET_UINT32_LE( w[0][2], key,  8 );
-    MBEDTLS_GET_UINT32_LE( w[0][3], key, 12 );
+    w[0][0] = MBEDTLS_GET_UINT32_LE( key,  0 );
+    w[0][1] = MBEDTLS_GET_UINT32_LE( key,  4 );
+    w[0][2] = MBEDTLS_GET_UINT32_LE( key,  8 );
+    w[0][3] = MBEDTLS_GET_UINT32_LE( key, 12 );
 
     memset( w[1], 0, 16 );
     if( keybits >= 192 )
     {
-        MBEDTLS_GET_UINT32_LE( w[1][0], key, 16 );  // 192 bit key
-        MBEDTLS_GET_UINT32_LE( w[1][1], key, 20 );
+        w[1][0] = MBEDTLS_GET_UINT32_LE( key, 16 );  // 192 bit key
+        w[1][1] = MBEDTLS_GET_UINT32_LE( key, 20 );
     }
     if( keybits == 256 )
     {
-        MBEDTLS_GET_UINT32_LE( w[1][2], key, 24 );  // 256 bit key
-        MBEDTLS_GET_UINT32_LE( w[1][3], key, 28 );
+        w[1][2] = MBEDTLS_GET_UINT32_LE( key, 24 );  // 256 bit key
+        w[1][3] = MBEDTLS_GET_UINT32_LE( key, 28 );
     }
 
     i = ( keybits - 128 ) >> 6;             // index: 0, 1, 2
@@ -525,10 +525,10 @@
     ARIA_VALIDATE_RET( input != NULL );
     ARIA_VALIDATE_RET( output != NULL );
 
-    MBEDTLS_GET_UINT32_LE( a, input,  0 );
-    MBEDTLS_GET_UINT32_LE( b, input,  4 );
-    MBEDTLS_GET_UINT32_LE( c, input,  8 );
-    MBEDTLS_GET_UINT32_LE( d, input, 12 );
+    a = MBEDTLS_GET_UINT32_LE( input,  0 );
+    b = MBEDTLS_GET_UINT32_LE( input,  4 );
+    c = MBEDTLS_GET_UINT32_LE( input,  8 );
+    d = MBEDTLS_GET_UINT32_LE( input, 12 );
 
     i = 0;
     while( 1 )
diff --git a/library/camellia.c b/library/camellia.c
index 9aab7ab..4d6b468 100644
--- a/library/camellia.c
+++ b/library/camellia.c
@@ -353,8 +353,8 @@
      * Prepare SIGMA values
      */
     for( i = 0; i < 6; i++ ) {
-        MBEDTLS_GET_UINT32_BE( SIGMA[i][0], SIGMA_CHARS[i], 0 );
-        MBEDTLS_GET_UINT32_BE( SIGMA[i][1], SIGMA_CHARS[i], 4 );
+        SIGMA[i][0] = MBEDTLS_GET_UINT32_BE( SIGMA_CHARS[i], 0 );
+        SIGMA[i][1] = MBEDTLS_GET_UINT32_BE( SIGMA_CHARS[i], 4 );
     }
 
     /*
@@ -365,7 +365,7 @@
 
     /* Store KL, KR */
     for( i = 0; i < 8; i++ )
-        MBEDTLS_GET_UINT32_BE( KC[i], t, i * 4 );
+        KC[i] = MBEDTLS_GET_UINT32_BE( t, i * 4 );
 
     /* Generate KA */
     for( i = 0; i < 4; ++i )
@@ -491,10 +491,10 @@
     NR = ctx->nr;
     RK = ctx->rk;
 
-    MBEDTLS_GET_UINT32_BE( X[0], input,  0 );
-    MBEDTLS_GET_UINT32_BE( X[1], input,  4 );
-    MBEDTLS_GET_UINT32_BE( X[2], input,  8 );
-    MBEDTLS_GET_UINT32_BE( X[3], input, 12 );
+    X[0] = MBEDTLS_GET_UINT32_BE( input,  0 );
+    X[1] = MBEDTLS_GET_UINT32_BE( input,  4 );
+    X[2] = MBEDTLS_GET_UINT32_BE( input,  8 );
+    X[3] = MBEDTLS_GET_UINT32_BE( input, 12 );
 
     X[0] ^= *RK++;
     X[1] ^= *RK++;
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 ) );
 
diff --git a/library/common.h b/library/common.h
index 5115465..4ecc016 100644
--- a/library/common.h
+++ b/library/common.h
@@ -78,38 +78,45 @@
 #define MBEDTLS_BYTE_3( x ) ( (uint8_t) ( ( ( x ) >> 24 ) & 0xff ) )
 
 /**
- * 32-bit integer manipulation macros
+ * 32-bit integer manipulation GET macros (big endian)
  *
- * \brief   Using GET-
- *          From input data, take the most significant bytes
- *          and concatonate them as you shift along
- *          Using PUT-
- *          Read from a 32 bit integer and store each byte
- *          in memory, offset by a byte each, resulting in
- *          each byte being adjacent in memory.
+ * \brief   Use this to assign an unsigned 32 bit integer
+ *          by taking data stored adjacent in memory that
+ *          can be accessed via on offset
+ *          Big Endian is used when wanting to
+ *          transmit the most signifcant bits first
  *
- * \param   n   32 bit integer where data is accessed via
- *              PUT or stored using GET
+ * \param   data    The data used to translate to a 32 bit
+ *                  integer
+ * \param   offset  the shift in bytes to access the next byte
+ *                  of data
+ */
+#ifndef MBEDTLS_GET_UINT32_BE
+#define MBEDTLS_GET_UINT32_BE( data , offset )              \
+    (                                                       \
+          ( (uint32_t) ( data )[( offset )    ] << 24 )     \
+        | ( (uint32_t) ( data )[( offset ) + 1] << 16 )     \
+        | ( (uint32_t) ( data )[( offset ) + 2] <<  8 )     \
+        | ( (uint32_t) ( data )[( offset ) + 3]       )     \
+    )
+#endif
+
+/**
+ * 32-bit integer manipulation PUT macros (big endian)
+ *
+ * \brief   Read from a 32 bit integer and store each byte
+ *          in memory, offset by a specified amount, resulting
+ *          in each byte being adjacent in memory.
+ *          Big Endian is used when wanting to
+ *          transmit the most signifcant bits first
+ *
+ * \param   n   32 bit integer where data is accessed
  * \param   b   const unsigned char array of data to be
  *              manipulated
  * \param   i   offset in bytes, In the case of UINT32, i
  *              would increment by 4 every use assuming
  *              the data is being stored in the same location
  */
-
-/**
- * 32-bit integer manipulation macros (big endian)
- */
-#ifndef MBEDTLS_GET_UINT32_BE
-#define MBEDTLS_GET_UINT32_BE(n,b,i)                    \
-    do {                                                \
-        (n) = ( (uint32_t) (b)[(i)    ] << 24 )         \
-            | ( (uint32_t) (b)[(i) + 1] << 16 )         \
-            | ( (uint32_t) (b)[(i) + 2] <<  8 )         \
-            | ( (uint32_t) (b)[(i) + 3]       );        \
-    } while( 0 )
-#endif
-
 #ifndef MBEDTLS_PUT_UINT32_BE
 #define MBEDTLS_PUT_UINT32_BE(n,b,i)                    \
     do {                                                \
@@ -121,18 +128,45 @@
 #endif
 
 /**
- * 32-bit integer manipulation macros (little endian)
+ * 32-bit integer manipulation GET macros (little endian)
+ *
+ * \brief   Use this to assign an unsigned 32 bit integer
+ *          by taking data stored adjacent in memory that
+ *          can be accessed via on offset
+ *          Little Endian is used when wanting to
+ *          transmit the least signifcant bits first
+ *
+ * \param   data    The data used to translate to a 32 bit
+ *                  integer
+ * \param   offset  the shift in bytes to access the next byte
+ *                  of data
  */
 #ifndef MBEDTLS_GET_UINT32_LE
-#define MBEDTLS_GET_UINT32_LE(n,b,i)                    \
-    do {                                                \
-        (n) = ( (uint32_t) (b)[(i)    ]       )         \
-            | ( (uint32_t) (b)[(i) + 1] <<  8 )         \
-            | ( (uint32_t) (b)[(i) + 2] << 16 )         \
-            | ( (uint32_t) (b)[(i) + 3] << 24 );        \
-    } while( 0 )
+#define MBEDTLS_GET_UINT32_LE( data, offset )              \
+    (                                                      \
+          ( (uint32_t) ( data )[( offset )    ]       )    \
+        | ( (uint32_t) ( data )[( offset ) + 1] <<  8 )    \
+        | ( (uint32_t) ( data )[( offset ) + 2] << 16 )    \
+        | ( (uint32_t) ( data )[( offset ) + 3] << 24 )    \
+    )
 #endif
 
+/**
+ * 32-bit integer manipulation PUT macros (little endian)
+ *
+ * \brief   Read from a 32 bit integer and store each byte
+ *          in memory, offset by a specified amount, resulting
+ *          in each byte being adjacent in memory.
+ *          Little Endian is used when wanting to
+ *          transmit the least signifcant bits first
+ *
+ * \param   n   32 bit integer where data is accessed
+ * \param   b   const unsigned char array of data to be
+ *              manipulated
+ * \param   i   offset in bytes, In the case of UINT32, i
+ *              would increment by 4 every use assuming
+ *              the data is being stored in the same location
+ */
 #ifndef MBEDTLS_PUT_UINT32_LE
 #define MBEDTLS_PUT_UINT32_LE(n,b,i)                                \
     do {                                                            \
@@ -144,46 +178,43 @@
 #endif
 
 /**
- * 32-bit integer conversion from bytes (little endian)
+ * 16-bit integer manipulation GET macros (little endian)
+ *
+ * \brief   Use this to assign an unsigned 16 bit integer
+ *          by taking data stored adjacent in memory that
+ *          can be accessed via on offset
+ *          Little Endian is used when wanting to
+ *          transmit the least signifcant bits first
+ *
+ * \param   data    The data used to translate to a 16 bit
+ *                  integer
+ * \param   offset  the shit in bytes to access the next byte
+ *                  of data
  */
-#define MBEDTLS_BYTES_TO_U32_LE( data, offset )                 \
-    ( (uint32_t) (data)[offset]                                 \
-      | (uint32_t) ( (uint32_t) (data)[( offset ) + 1] << 8 )   \
-      | (uint32_t) ( (uint32_t) (data)[( offset ) + 2] << 16 )  \
-      | (uint32_t) ( (uint32_t) (data)[( offset ) + 3] << 24 )  \
+#ifndef MBEDTLS_GET_UINT16_LE
+#define MBEDTLS_GET_UINT16_LE( data, offset )               \
+    (                                                       \
+          ( (uint16_t) ( data )[( offset )    ]       )     \
+        | ( (uint16_t) ( data )[( offset ) + 1] <<  8 )     \
     )
+#endif
 
 /**
- * 16-bit integer manipulation macros
+ * 16-bit integer manipulation PUT macros (little endian)
  *
- * \brief   Using GET-
- *          From input data, take the most significant bytes
- *          and concatonate them as you shift along
- *          Using PUT-
- *          Read from a 16 bit integer and store each byte
- *          in memory, offset by a byte each, resulting in
- *          each byte being adjacent in memory.
+ * \brief   Read from a 16 bit integer and store each byte
+ *          in memory, offset by a specified amount, resulting
+ *          in each byte being adjacent in memory.
+ *          Little Endian is used when wanting to
+ *          transmit the least signifcant bits first
  *
- * \param   n   16 bit integer where data is accessed via
- *              PUT or stored using GET
+ * \param   n   16 bit integer where data is accessed
  * \param   b   const unsigned char array of data to be
  *              manipulated
  * \param   i   offset in bytes, In the case of UINT16, i
  *              would increment by 2 every use assuming
  *              the data is being stored in the same location
  */
-
-/**
- * 16-bit integer manipulation macros (little endian)
- */
-#ifndef MBEDTLS_GET_UINT16_LE
-#define MBEDTLS_GET_UINT16_LE( n, b, i )                \
-{                                                       \
-    (n) = ( (uint16_t) (b)[(i)    ]       )             \
-        | ( (uint16_t) (b)[(i) + 1] <<  8 );            \
-}
-#endif
-
 #ifndef MBEDTLS_PUT_UINT16_LE
 #define MBEDTLS_PUT_UINT16_LE( n, b, i )                        \
 {                                                               \
diff --git a/library/des.c b/library/des.c
index 9281747..7f90faa 100644
--- a/library/des.c
+++ b/library/des.c
@@ -400,8 +400,8 @@
     int i;
     uint32_t X, Y, T;
 
-    MBEDTLS_GET_UINT32_BE( X, key, 0 );
-    MBEDTLS_GET_UINT32_BE( Y, key, 4 );
+    X = MBEDTLS_GET_UINT32_BE( key, 0 );
+    Y = MBEDTLS_GET_UINT32_BE( key, 4 );
 
     /*
      * Permuted Choice 1
@@ -610,8 +610,8 @@
 
     SK = ctx->sk;
 
-    MBEDTLS_GET_UINT32_BE( X, input, 0 );
-    MBEDTLS_GET_UINT32_BE( Y, input, 4 );
+    X = MBEDTLS_GET_UINT32_BE( input, 0 );
+    Y = MBEDTLS_GET_UINT32_BE( input, 4 );
 
     DES_IP( X, Y );
 
@@ -697,8 +697,8 @@
 
     SK = ctx->sk;
 
-    MBEDTLS_GET_UINT32_BE( X, input, 0 );
-    MBEDTLS_GET_UINT32_BE( Y, input, 4 );
+    X = MBEDTLS_GET_UINT32_BE( input, 0 );
+    Y = MBEDTLS_GET_UINT32_BE( input, 4 );
 
     DES_IP( X, Y );
 
diff --git a/library/gcm.c b/library/gcm.c
index 3caeed2..910646b 100644
--- a/library/gcm.c
+++ b/library/gcm.c
@@ -88,12 +88,12 @@
         return( ret );
 
     /* pack h as two 64-bits ints, big-endian */
-    MBEDTLS_GET_UINT32_BE( hi, h,  0  );
-    MBEDTLS_GET_UINT32_BE( lo, h,  4  );
+    hi = MBEDTLS_GET_UINT32_BE( h,  0  );
+    lo = MBEDTLS_GET_UINT32_BE( h,  4  );
     vh = (uint64_t) hi << 32 | lo;
 
-    MBEDTLS_GET_UINT32_BE( hi, h,  8  );
-    MBEDTLS_GET_UINT32_BE( lo, h,  12 );
+    hi = MBEDTLS_GET_UINT32_BE( h,  8  );
+    lo = MBEDTLS_GET_UINT32_BE( h,  12 );
     vl = (uint64_t) hi << 32 | lo;
 
     /* 8 = 1000 corresponds to 1 in GF(2^128) */
diff --git a/library/md5.c b/library/md5.c
index e8d0021..a9bbcb4 100644
--- a/library/md5.c
+++ b/library/md5.c
@@ -87,22 +87,22 @@
         uint32_t X[16], A, B, C, D;
     } local;
 
-    MBEDTLS_GET_UINT32_LE( local.X[ 0], data,  0 );
-    MBEDTLS_GET_UINT32_LE( local.X[ 1], data,  4 );
-    MBEDTLS_GET_UINT32_LE( local.X[ 2], data,  8 );
-    MBEDTLS_GET_UINT32_LE( local.X[ 3], data, 12 );
-    MBEDTLS_GET_UINT32_LE( local.X[ 4], data, 16 );
-    MBEDTLS_GET_UINT32_LE( local.X[ 5], data, 20 );
-    MBEDTLS_GET_UINT32_LE( local.X[ 6], data, 24 );
-    MBEDTLS_GET_UINT32_LE( local.X[ 7], data, 28 );
-    MBEDTLS_GET_UINT32_LE( local.X[ 8], data, 32 );
-    MBEDTLS_GET_UINT32_LE( local.X[ 9], data, 36 );
-    MBEDTLS_GET_UINT32_LE( local.X[10], data, 40 );
-    MBEDTLS_GET_UINT32_LE( local.X[11], data, 44 );
-    MBEDTLS_GET_UINT32_LE( local.X[12], data, 48 );
-    MBEDTLS_GET_UINT32_LE( local.X[13], data, 52 );
-    MBEDTLS_GET_UINT32_LE( local.X[14], data, 56 );
-    MBEDTLS_GET_UINT32_LE( local.X[15], data, 60 );
+    local.X[ 0] = MBEDTLS_GET_UINT32_LE( data,  0 );
+    local.X[ 1] = MBEDTLS_GET_UINT32_LE( data,  4 );
+    local.X[ 2] = MBEDTLS_GET_UINT32_LE( data,  8 );
+    local.X[ 3] = MBEDTLS_GET_UINT32_LE( data, 12 );
+    local.X[ 4] = MBEDTLS_GET_UINT32_LE( data, 16 );
+    local.X[ 5] = MBEDTLS_GET_UINT32_LE( data, 20 );
+    local.X[ 6] = MBEDTLS_GET_UINT32_LE( data, 24 );
+    local.X[ 7] = MBEDTLS_GET_UINT32_LE( data, 28 );
+    local.X[ 8] = MBEDTLS_GET_UINT32_LE( data, 32 );
+    local.X[ 9] = MBEDTLS_GET_UINT32_LE( data, 36 );
+    local.X[10] = MBEDTLS_GET_UINT32_LE( data, 40 );
+    local.X[11] = MBEDTLS_GET_UINT32_LE( data, 44 );
+    local.X[12] = MBEDTLS_GET_UINT32_LE( data, 48 );
+    local.X[13] = MBEDTLS_GET_UINT32_LE( data, 52 );
+    local.X[14] = MBEDTLS_GET_UINT32_LE( data, 56 );
+    local.X[15] = MBEDTLS_GET_UINT32_LE( data, 60 );
 
 #define S(x,n)                                                          \
     ( ( (x) << (n) ) | ( ( (x) & 0xFFFFFFFF) >> ( 32 - (n) ) ) )
diff --git a/library/nist_kw.c b/library/nist_kw.c
index b8f9239..e2ab256 100644
--- a/library/nist_kw.c
+++ b/library/nist_kw.c
@@ -454,7 +454,7 @@
             ret = MBEDTLS_ERR_CIPHER_AUTH_FAILED;
         }
 
-        MBEDTLS_GET_UINT32_BE( Plen, A, KW_SEMIBLOCK_LENGTH / 2 );
+        Plen = MBEDTLS_GET_UINT32_BE( A, KW_SEMIBLOCK_LENGTH / 2 );
 
         /*
          * Plen is the length of the plaintext, when the input is valid.
diff --git a/library/poly1305.c b/library/poly1305.c
index 3c0b7c6..f195742 100644
--- a/library/poly1305.c
+++ b/library/poly1305.c
@@ -122,10 +122,10 @@
     for( i = 0U; i < nblocks; i++ )
     {
         /* The input block is treated as a 128-bit little-endian integer */
-        d0   = MBEDTLS_BYTES_TO_U32_LE( input, offset + 0  );
-        d1   = MBEDTLS_BYTES_TO_U32_LE( input, offset + 4  );
-        d2   = MBEDTLS_BYTES_TO_U32_LE( input, offset + 8  );
-        d3   = MBEDTLS_BYTES_TO_U32_LE( input, offset + 12 );
+        d0   = MBEDTLS_GET_UINT32_LE( input, offset + 0  );
+        d1   = MBEDTLS_GET_UINT32_LE( input, offset + 4  );
+        d2   = MBEDTLS_GET_UINT32_LE( input, offset + 8  );
+        d3   = MBEDTLS_GET_UINT32_LE( input, offset + 12 );
 
         /* Compute: acc += (padded) block as a 130-bit integer */
         d0  += (uint64_t) acc0;
@@ -290,15 +290,15 @@
     POLY1305_VALIDATE_RET( key != NULL );
 
     /* r &= 0x0ffffffc0ffffffc0ffffffc0fffffff */
-    ctx->r[0] = MBEDTLS_BYTES_TO_U32_LE( key, 0 )  & 0x0FFFFFFFU;
-    ctx->r[1] = MBEDTLS_BYTES_TO_U32_LE( key, 4 )  & 0x0FFFFFFCU;
-    ctx->r[2] = MBEDTLS_BYTES_TO_U32_LE( key, 8 )  & 0x0FFFFFFCU;
-    ctx->r[3] = MBEDTLS_BYTES_TO_U32_LE( key, 12 ) & 0x0FFFFFFCU;
+    ctx->r[0] = MBEDTLS_GET_UINT32_LE( key, 0 )  & 0x0FFFFFFFU;
+    ctx->r[1] = MBEDTLS_GET_UINT32_LE( key, 4 )  & 0x0FFFFFFCU;
+    ctx->r[2] = MBEDTLS_GET_UINT32_LE( key, 8 )  & 0x0FFFFFFCU;
+    ctx->r[3] = MBEDTLS_GET_UINT32_LE( key, 12 ) & 0x0FFFFFFCU;
 
-    ctx->s[0] = MBEDTLS_BYTES_TO_U32_LE( key, 16 );
-    ctx->s[1] = MBEDTLS_BYTES_TO_U32_LE( key, 20 );
-    ctx->s[2] = MBEDTLS_BYTES_TO_U32_LE( key, 24 );
-    ctx->s[3] = MBEDTLS_BYTES_TO_U32_LE( key, 28 );
+    ctx->s[0] = MBEDTLS_GET_UINT32_LE( key, 16 );
+    ctx->s[1] = MBEDTLS_GET_UINT32_LE( key, 20 );
+    ctx->s[2] = MBEDTLS_GET_UINT32_LE( key, 24 );
+    ctx->s[3] = MBEDTLS_GET_UINT32_LE( key, 28 );
 
     /* Initial accumulator state */
     ctx->acc[0] = 0U;
diff --git a/library/psa_crypto_storage.c b/library/psa_crypto_storage.c
index 07c2cdf..c6660b9 100644
--- a/library/psa_crypto_storage.c
+++ b/library/psa_crypto_storage.c
@@ -293,11 +293,11 @@
     if( status != PSA_SUCCESS )
         return( status );
 
-    MBEDTLS_GET_UINT32_LE( version, storage_format->version, 0 );
+    version = MBEDTLS_GET_UINT32_LE( storage_format->version, 0 );
     if( version != 0 )
         return( PSA_ERROR_DATA_INVALID );
 
-    MBEDTLS_GET_UINT32_LE( *key_data_length, storage_format->data_len, 0 );
+    *key_data_length = MBEDTLS_GET_UINT32_LE( storage_format->data_len, 0 );
     if( *key_data_length > ( storage_data_length - sizeof(*storage_format) ) ||
         *key_data_length > PSA_CRYPTO_MAX_STORAGE_SIZE )
         return( PSA_ERROR_DATA_INVALID );
@@ -314,12 +314,12 @@
         memcpy( *key_data, storage_format->key_data, *key_data_length );
     }
 
-    MBEDTLS_GET_UINT32_LE( attr->lifetime, storage_format->lifetime, 0 );
-    MBEDTLS_GET_UINT16_LE( attr->type, storage_format->type, 0 );
-    MBEDTLS_GET_UINT16_LE( attr->bits, storage_format->bits, 0 );
-    MBEDTLS_GET_UINT32_LE( attr->policy.usage, storage_format->policy, 0 );
-    MBEDTLS_GET_UINT32_LE( attr->policy.alg, storage_format->policy, sizeof( uint32_t ) );
-    MBEDTLS_GET_UINT32_LE( attr->policy.alg2, storage_format->policy, 2 * sizeof( uint32_t ) );
+    attr->lifetime = MBEDTLS_GET_UINT32_LE( storage_format->lifetime, 0 );
+    attr->type = MBEDTLS_GET_UINT16_LE( storage_format->type, 0 );
+    attr->bits = MBEDTLS_GET_UINT16_LE( storage_format->bits, 0 );
+    attr->policy.usage = MBEDTLS_GET_UINT32_LE( storage_format->policy, 0 );
+    attr->policy.alg = MBEDTLS_GET_UINT32_LE( storage_format->policy, sizeof( uint32_t ) );
+    attr->policy.alg2 = MBEDTLS_GET_UINT32_LE( storage_format->policy, 2 * sizeof( uint32_t ) );
 
     return( PSA_SUCCESS );
 }
diff --git a/library/ripemd160.c b/library/ripemd160.c
index 2bed107..41d8387 100644
--- a/library/ripemd160.c
+++ b/library/ripemd160.c
@@ -92,22 +92,22 @@
         uint32_t A, B, C, D, E, Ap, Bp, Cp, Dp, Ep, X[16];
     } local;
 
-    MBEDTLS_GET_UINT32_LE( local.X[ 0], data,  0 );
-    MBEDTLS_GET_UINT32_LE( local.X[ 1], data,  4 );
-    MBEDTLS_GET_UINT32_LE( local.X[ 2], data,  8 );
-    MBEDTLS_GET_UINT32_LE( local.X[ 3], data, 12 );
-    MBEDTLS_GET_UINT32_LE( local.X[ 4], data, 16 );
-    MBEDTLS_GET_UINT32_LE( local.X[ 5], data, 20 );
-    MBEDTLS_GET_UINT32_LE( local.X[ 6], data, 24 );
-    MBEDTLS_GET_UINT32_LE( local.X[ 7], data, 28 );
-    MBEDTLS_GET_UINT32_LE( local.X[ 8], data, 32 );
-    MBEDTLS_GET_UINT32_LE( local.X[ 9], data, 36 );
-    MBEDTLS_GET_UINT32_LE( local.X[10], data, 40 );
-    MBEDTLS_GET_UINT32_LE( local.X[11], data, 44 );
-    MBEDTLS_GET_UINT32_LE( local.X[12], data, 48 );
-    MBEDTLS_GET_UINT32_LE( local.X[13], data, 52 );
-    MBEDTLS_GET_UINT32_LE( local.X[14], data, 56 );
-    MBEDTLS_GET_UINT32_LE( local.X[15], data, 60 );
+    local.X[ 0] = MBEDTLS_GET_UINT32_LE( data,  0 );
+    local.X[ 1] = MBEDTLS_GET_UINT32_LE( data,  4 );
+    local.X[ 2] = MBEDTLS_GET_UINT32_LE( data,  8 );
+    local.X[ 3] = MBEDTLS_GET_UINT32_LE( data, 12 );
+    local.X[ 4] = MBEDTLS_GET_UINT32_LE( data, 16 );
+    local.X[ 5] = MBEDTLS_GET_UINT32_LE( data, 20 );
+    local.X[ 6] = MBEDTLS_GET_UINT32_LE( data, 24 );
+    local.X[ 7] = MBEDTLS_GET_UINT32_LE( data, 28 );
+    local.X[ 8] = MBEDTLS_GET_UINT32_LE( data, 32 );
+    local.X[ 9] = MBEDTLS_GET_UINT32_LE( data, 36 );
+    local.X[10] = MBEDTLS_GET_UINT32_LE( data, 40 );
+    local.X[11] = MBEDTLS_GET_UINT32_LE( data, 44 );
+    local.X[12] = MBEDTLS_GET_UINT32_LE( data, 48 );
+    local.X[13] = MBEDTLS_GET_UINT32_LE( data, 52 );
+    local.X[14] = MBEDTLS_GET_UINT32_LE( data, 56 );
+    local.X[15] = MBEDTLS_GET_UINT32_LE( data, 60 );
 
     local.A = local.Ap = ctx->state[0];
     local.B = local.Bp = ctx->state[1];
diff --git a/library/sha1.c b/library/sha1.c
index da61f65..6fc9371 100644
--- a/library/sha1.c
+++ b/library/sha1.c
@@ -103,22 +103,22 @@
     SHA1_VALIDATE_RET( ctx != NULL );
     SHA1_VALIDATE_RET( (const unsigned char *)data != NULL );
 
-    MBEDTLS_GET_UINT32_BE( local.W[ 0], data,  0 );
-    MBEDTLS_GET_UINT32_BE( local.W[ 1], data,  4 );
-    MBEDTLS_GET_UINT32_BE( local.W[ 2], data,  8 );
-    MBEDTLS_GET_UINT32_BE( local.W[ 3], data, 12 );
-    MBEDTLS_GET_UINT32_BE( local.W[ 4], data, 16 );
-    MBEDTLS_GET_UINT32_BE( local.W[ 5], data, 20 );
-    MBEDTLS_GET_UINT32_BE( local.W[ 6], data, 24 );
-    MBEDTLS_GET_UINT32_BE( local.W[ 7], data, 28 );
-    MBEDTLS_GET_UINT32_BE( local.W[ 8], data, 32 );
-    MBEDTLS_GET_UINT32_BE( local.W[ 9], data, 36 );
-    MBEDTLS_GET_UINT32_BE( local.W[10], data, 40 );
-    MBEDTLS_GET_UINT32_BE( local.W[11], data, 44 );
-    MBEDTLS_GET_UINT32_BE( local.W[12], data, 48 );
-    MBEDTLS_GET_UINT32_BE( local.W[13], data, 52 );
-    MBEDTLS_GET_UINT32_BE( local.W[14], data, 56 );
-    MBEDTLS_GET_UINT32_BE( local.W[15], data, 60 );
+    local.W[ 0] = MBEDTLS_GET_UINT32_BE( data,  0 );
+    local.W[ 1] = MBEDTLS_GET_UINT32_BE( data,  4 );
+    local.W[ 2] = MBEDTLS_GET_UINT32_BE( data,  8 );
+    local.W[ 3] = MBEDTLS_GET_UINT32_BE( data, 12 );
+    local.W[ 4] = MBEDTLS_GET_UINT32_BE( data, 16 );
+    local.W[ 5] = MBEDTLS_GET_UINT32_BE( data, 20 );
+    local.W[ 6] = MBEDTLS_GET_UINT32_BE( data, 24 );
+    local.W[ 7] = MBEDTLS_GET_UINT32_BE( data, 28 );
+    local.W[ 8] = MBEDTLS_GET_UINT32_BE( data, 32 );
+    local.W[ 9] = MBEDTLS_GET_UINT32_BE( data, 36 );
+    local.W[10] = MBEDTLS_GET_UINT32_BE( data, 40 );
+    local.W[11] = MBEDTLS_GET_UINT32_BE( data, 44 );
+    local.W[12] = MBEDTLS_GET_UINT32_BE( data, 48 );
+    local.W[13] = MBEDTLS_GET_UINT32_BE( data, 52 );
+    local.W[14] = MBEDTLS_GET_UINT32_BE( data, 56 );
+    local.W[15] = MBEDTLS_GET_UINT32_BE( data, 60 );
 
 #define S(x,n) (((x) << (n)) | (((x) & 0xFFFFFFFF) >> (32 - (n))))
 
diff --git a/library/sha256.c b/library/sha256.c
index fb66340..c3573f8 100644
--- a/library/sha256.c
+++ b/library/sha256.c
@@ -190,7 +190,7 @@
     for( i = 0; i < 64; i++ )
     {
         if( i < 16 )
-            MBEDTLS_GET_UINT32_BE( local.W[i], data, 4 * i );
+            local.W[i] = MBEDTLS_GET_UINT32_BE( data, 4 * i );
         else
             R( i );
 
@@ -205,7 +205,7 @@
     }
 #else /* MBEDTLS_SHA256_SMALLER */
     for( i = 0; i < 16; i++ )
-        MBEDTLS_GET_UINT32_BE( local.W[i], data, 4 * i );
+        local.W[i] = MBEDTLS_GET_UINT32_BE( data, 4 * i );
 
     for( i = 0; i < 16; i += 8 )
     {