Platform: Add tfm_ prefix in the platform HAL
This patch adds the tfm_ prefix in all the platform HAL files,
interfaces and HAL targets' implementation.
It also aligns the files with the coding style.
Change-Id: Ic1b1f80b20c1e8a19e6b8e56ee158b42c11df63c
Signed-off-by: Marc Moreno <marc.morenoberengue@arm.com>
diff --git a/platform/ext/target/mps2/an519/dummy_crypto_keys.c b/platform/ext/target/mps2/an519/dummy_crypto_keys.c
index 315e216..80cf3c8 100644
--- a/platform/ext/target/mps2/an519/dummy_crypto_keys.c
+++ b/platform/ext/target/mps2/an519/dummy_crypto_keys.c
@@ -14,15 +14,15 @@
* limitations under the License.
*/
-#include "platform/include/plat_crypto_keys.h"
+#include "platform/include/tfm_plat_crypto_keys.h"
#define TFM_KEY_LEN_BYTES 16
-static uint8_t sample_tfm_key[TFM_KEY_LEN_BYTES] =
+static const uint8_t sample_tfm_key[TFM_KEY_LEN_BYTES] =
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, \
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
-enum tfm_plat_errno_t plat_get_crypto_huk(uint8_t* key, uint32_t size)
+enum tfm_plat_errno_t tfm_plat_get_crypto_huk(uint8_t *key, uint32_t size)
{
/* FIXME: this function should be implemented by platform vendor. For the
* security of the storage system, it is critical to use a hardware unique
@@ -32,15 +32,15 @@
* software stub has been implemented in this case.
*/
uint32_t i;
- uint8_t* p_dst = key;
- uint8_t* p_huk = sample_tfm_key;
+ uint8_t *p_dst = key;
+ const uint8_t *p_huk = sample_tfm_key;
if(size > TFM_KEY_LEN_BYTES) {
return TFM_PLAT_ERRNO_SYSTEM_ERR;
}
for (i = size; i > 0; i--) {
- *((uint8_t*)p_dst) = *((uint8_t*)p_huk);
+ *p_dst = *p_huk;
p_huk++;
p_dst++;
}
diff --git a/platform/ext/target/mps2/an521/dummy_crypto_keys.c b/platform/ext/target/mps2/an521/dummy_crypto_keys.c
index 80a8f28..5691eeb 100644
--- a/platform/ext/target/mps2/an521/dummy_crypto_keys.c
+++ b/platform/ext/target/mps2/an521/dummy_crypto_keys.c
@@ -14,33 +14,33 @@
* limitations under the License.
*/
-#include "platform/include/plat_crypto_keys.h"
+#include "platform/include/tfm_plat_crypto_keys.h"
#define TFM_KEY_LEN_BYTES 16
-static uint8_t sample_tfm_key[TFM_KEY_LEN_BYTES] =
+static const uint8_t sample_tfm_key[TFM_KEY_LEN_BYTES] =
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, \
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
-enum tfm_plat_errno_t plat_get_crypto_huk(uint8_t* key, uint32_t size)
+enum tfm_plat_errno_t tfm_plat_get_crypto_huk(uint8_t *key, uint32_t size)
{
/* FIXME: this function should be implemented by platform vendor. For the
* security of the storage system, it is critical to use a hardware unique
* key.
*
- * SSE-200 does not have any available hardware unique key engine, so a
+ * AN521 does not have any available hardware unique key engine, so a
* software stub has been implemented in this case.
*/
uint32_t i;
- uint8_t* p_dst = key;
- uint8_t* p_huk = sample_tfm_key;
+ uint8_t *p_dst = key;
+ const uint8_t *p_huk = sample_tfm_key;
if(size > TFM_KEY_LEN_BYTES) {
return TFM_PLAT_ERRNO_SYSTEM_ERR;
}
for (i = size; i > 0; i--) {
- *((uint8_t*)p_dst) = *((uint8_t*)p_huk);
+ *p_dst = *p_huk;
p_huk++;
p_dst++;
}
diff --git a/platform/ext/target/musca_a/dummy_crypto_keys.c b/platform/ext/target/musca_a/dummy_crypto_keys.c
index 80a8f28..553b123 100644
--- a/platform/ext/target/musca_a/dummy_crypto_keys.c
+++ b/platform/ext/target/musca_a/dummy_crypto_keys.c
@@ -14,33 +14,33 @@
* limitations under the License.
*/
-#include "platform/include/plat_crypto_keys.h"
+#include "platform/include/tfm_plat_crypto_keys.h"
#define TFM_KEY_LEN_BYTES 16
-static uint8_t sample_tfm_key[TFM_KEY_LEN_BYTES] =
+static const uint8_t sample_tfm_key[TFM_KEY_LEN_BYTES] =
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, \
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
-enum tfm_plat_errno_t plat_get_crypto_huk(uint8_t* key, uint32_t size)
+enum tfm_plat_errno_t tfm_plat_get_crypto_huk(uint8_t *key, uint32_t size)
{
/* FIXME: this function should be implemented by platform vendor. For the
* security of the storage system, it is critical to use a hardware unique
* key.
*
- * SSE-200 does not have any available hardware unique key engine, so a
+ * Musca A does not have any available hardware unique key engine, so a
* software stub has been implemented in this case.
*/
uint32_t i;
- uint8_t* p_dst = key;
- uint8_t* p_huk = sample_tfm_key;
+ uint8_t *p_dst = key;
+ const uint8_t *p_huk = sample_tfm_key;
if(size > TFM_KEY_LEN_BYTES) {
return TFM_PLAT_ERRNO_SYSTEM_ERR;
}
for (i = size; i > 0; i--) {
- *((uint8_t*)p_dst) = *((uint8_t*)p_huk);
+ *p_dst = *p_huk;
p_huk++;
p_dst++;
}
diff --git a/platform/include/plat_crypto_keys.h b/platform/include/tfm_plat_crypto_keys.h
similarity index 62%
rename from platform/include/plat_crypto_keys.h
rename to platform/include/tfm_plat_crypto_keys.h
index 3cd03dd..328e8eb 100644
--- a/platform/include/plat_crypto_keys.h
+++ b/platform/include/tfm_plat_crypto_keys.h
@@ -1,23 +1,24 @@
/*
- * Copyright (c) 2017, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
-#ifndef __PLAT_CRYPTO_KEYS__
-#define __PLAT_CRYPTO_KEYS__
+#ifndef __TFM_PLAT_CRYPTO_KEYS_H__
+#define __TFM_PLAT_CRYPTO_KEYS_H__
/**
* \note The interfaces defined in this file must be implemented for each
* SoC.
*/
+
+#include <stdint.h>
+#include "tfm_plat_defs.h"
+
#ifdef __cplusplus
extern "C" {
#endif
-#include <stdint.h>
-#include "plat_defs.h"
-
/**
* \brief Gets hardware unique key for encryption
*
@@ -26,10 +27,10 @@
*
* \return Returns error code specified in \ref tfm_plat_errno_t
*/
-enum tfm_plat_errno_t plat_get_crypto_huk(uint8_t* key, uint32_t size);
+enum tfm_plat_errno_t tfm_plat_get_crypto_huk(uint8_t *key, uint32_t size);
#ifdef __cplusplus
}
#endif
-#endif /* __PLAT_CRYPTO_KEYS__ */
+#endif /* __TFM_PLAT_CRYPTO_KEYS_H__ */
diff --git a/platform/include/plat_defs.h b/platform/include/tfm_plat_defs.h
similarity index 66%
rename from platform/include/plat_defs.h
rename to platform/include/tfm_plat_defs.h
index a19478f..eeaf32f 100644
--- a/platform/include/plat_defs.h
+++ b/platform/include/tfm_plat_defs.h
@@ -1,19 +1,16 @@
/*
- * Copyright (c) 2017, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
-#ifndef __PLAT_DEFS_H__
-#define __PLAT_DEFS_H__
+#ifndef __TFM_PLAT_DEFS_H__
+#define __TFM_PLAT_DEFS_H__
/**
* \note The interfaces defined in this file must be implemented for each
* target.
*/
-#ifdef __cplusplus
-extern "C" {
-#endif
#include <stdint.h>
#include <limits.h>
@@ -25,8 +22,4 @@
TFM_PLAT_ERRNO_FORCE_INT_SIZE = INT_MAX
};
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __PLAT_DEFS_H__ */
+#endif /* __TFM_PLAT_DEFS_H__ */
diff --git a/secure_fw/services/secure_storage/crypto/sst_crypto_interface.c b/secure_fw/services/secure_storage/crypto/sst_crypto_interface.c
index 05e8107..8447f03 100644
--- a/secure_fw/services/secure_storage/crypto/sst_crypto_interface.c
+++ b/secure_fw/services/secure_storage/crypto/sst_crypto_interface.c
@@ -15,7 +15,7 @@
#define MBEDTLS_CONFIG_FILE "tfm_mbedtls_config.h"
#include "mbedtls/gcm.h"
#include "mbedtls/memory_buffer_alloc.h"
-#include "platform/include/plat_crypto_keys.h"
+#include "platform/include/tfm_plat_crypto_keys.h"
/* FIXME: most of this implementation will be replaced by crypto service API
* calls
@@ -57,7 +57,7 @@
* To be fixed in later revisions. Currently, just use the
* same HUK (derived) key for all the crypto operations.
*/
- plat_get_crypto_huk(key, key_len);
+ tfm_plat_get_crypto_huk(key, key_len);
return PSA_SST_ERR_SUCCESS;
}