Move GET/PUT_UINT16_LE macros to common.h
Although these only appear in one file: psa_crypto_storage.c
it is tidy to give it the same prefix as the UINT32 macros
and to store them in the fame file
Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
diff --git a/library/psa_crypto_storage.c b/library/psa_crypto_storage.c
index dd56e97..b925227 100644
--- a/library/psa_crypto_storage.c
+++ b/library/psa_crypto_storage.c
@@ -234,25 +234,6 @@
return( PSA_SUCCESS );
}
-/*
- * 16-bit integer manipulation macros (little endian)
- */
-#ifndef GET_UINT16_LE
-#define GET_UINT16_LE( n, b, i ) \
-{ \
- (n) = ( (uint16_t) (b)[(i) ] ) \
- | ( (uint16_t) (b)[(i) + 1] << 8 ); \
-}
-#endif
-
-#ifndef PUT_UINT16_LE
-#define PUT_UINT16_LE( n, b, i ) \
-{ \
- (b)[(i) ] = (unsigned char) ( ( (n) ) & 0xFF ); \
- (b)[(i) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \
-}
-#endif
-
/**
* Persistent key storage magic header.
*/
@@ -281,8 +262,8 @@
memcpy( storage_format->magic, PSA_KEY_STORAGE_MAGIC_HEADER, PSA_KEY_STORAGE_MAGIC_HEADER_LENGTH );
MBEDTLS_PUT_UINT32_LE( 0, storage_format->version, 0 );
MBEDTLS_PUT_UINT32_LE( attr->lifetime, storage_format->lifetime, 0 );
- PUT_UINT16_LE( (uint16_t) attr->type, storage_format->type, 0 );
- PUT_UINT16_LE( (uint16_t) attr->bits, storage_format->bits, 0 );
+ MBEDTLS_PUT_UINT16_LE( (uint16_t) attr->type, storage_format->type, 0 );
+ MBEDTLS_PUT_UINT16_LE( (uint16_t) attr->bits, storage_format->bits, 0 );
MBEDTLS_PUT_UINT32_LE( attr->policy.usage, storage_format->policy, 0 );
MBEDTLS_PUT_UINT32_LE( attr->policy.alg, storage_format->policy, sizeof( uint32_t ) );
MBEDTLS_PUT_UINT32_LE( attr->policy.alg2, storage_format->policy, 2 * sizeof( uint32_t ) );
@@ -338,8 +319,8 @@
}
MBEDTLS_GET_UINT32_LE( attr->lifetime, storage_format->lifetime, 0 );
- GET_UINT16_LE( attr->type, storage_format->type, 0 );
- GET_UINT16_LE( attr->bits, storage_format->bits, 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 ) );