diff options
author | Tamas Ban <tamas.ban@arm.com> | 2019-01-02 21:49:59 +0000 |
---|---|---|
committer | Tamas Ban <tamas.ban@arm.com> | 2019-01-28 11:50:24 +0100 |
commit | a69f801c43b7787775d411dbcfb0b13f59f13abf (patch) | |
tree | 665f40e29880ba838699ee260a531b3ea33eaa3b | |
parent | 428828a0a6e1e2e2f6d5d04fa538b2c7a480a79a (diff) | |
download | trusted-firmware-m-a69f801c43b7787775d411dbcfb0b13f59f13abf.tar.gz |
Platform: Add hardware version
Hardware version is a globally unique number in EAN-13+5
format identifying the GDSII that went to fabrication,
HW and ROM.
Change-Id: I6619f1f28f7b7a4c926c54248de10d1e3e739e4a
Signed-off-by: Tamas Ban <tamas.ban@arm.com>
-rw-r--r-- | platform/ext/target/mps2/an519/dummy_device_id.c | 16 | ||||
-rw-r--r-- | platform/ext/target/mps2/an521/dummy_device_id.c | 16 | ||||
-rw-r--r-- | platform/ext/target/musca_a/dummy_device_id.c | 16 | ||||
-rw-r--r-- | platform/ext/target/musca_b1/dummy_device_id.c | 16 | ||||
-rw-r--r-- | platform/include/tfm_plat_device_id.h | 28 |
5 files changed, 92 insertions, 0 deletions
diff --git a/platform/ext/target/mps2/an519/dummy_device_id.c b/platform/ext/target/mps2/an519/dummy_device_id.c index be428f087a..d282385081 100644 --- a/platform/ext/target/mps2/an519/dummy_device_id.c +++ b/platform/ext/target/mps2/an519/dummy_device_id.c @@ -30,6 +30,7 @@ static const uint8_t implementation_id[] = { 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, }; +static const uint8_t example_ean_13[] = "060456527282910010"; /** * \brief Copy the device specific ID to the destination buffer * @@ -90,3 +91,18 @@ enum tfm_plat_err_t tfm_plat_get_implementation_id(uint32_t *size, return TFM_PLAT_ERR_SUCCESS; } + +enum tfm_plat_err_t tfm_plat_get_hw_version(uint32_t *size, uint8_t *buf) +{ + const uint8_t *p_hw_version = example_ean_13; + uint32_t hw_version_size = sizeof(example_ean_13) - 1; + + if (*size < hw_version_size) { + return TFM_PLAT_ERR_SYSTEM_ERR; + } + + copy_id(buf, p_hw_version, hw_version_size); + *size = hw_version_size; + + return TFM_PLAT_ERR_SUCCESS; +} diff --git a/platform/ext/target/mps2/an521/dummy_device_id.c b/platform/ext/target/mps2/an521/dummy_device_id.c index be428f087a..d282385081 100644 --- a/platform/ext/target/mps2/an521/dummy_device_id.c +++ b/platform/ext/target/mps2/an521/dummy_device_id.c @@ -30,6 +30,7 @@ static const uint8_t implementation_id[] = { 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, }; +static const uint8_t example_ean_13[] = "060456527282910010"; /** * \brief Copy the device specific ID to the destination buffer * @@ -90,3 +91,18 @@ enum tfm_plat_err_t tfm_plat_get_implementation_id(uint32_t *size, return TFM_PLAT_ERR_SUCCESS; } + +enum tfm_plat_err_t tfm_plat_get_hw_version(uint32_t *size, uint8_t *buf) +{ + const uint8_t *p_hw_version = example_ean_13; + uint32_t hw_version_size = sizeof(example_ean_13) - 1; + + if (*size < hw_version_size) { + return TFM_PLAT_ERR_SYSTEM_ERR; + } + + copy_id(buf, p_hw_version, hw_version_size); + *size = hw_version_size; + + return TFM_PLAT_ERR_SUCCESS; +} diff --git a/platform/ext/target/musca_a/dummy_device_id.c b/platform/ext/target/musca_a/dummy_device_id.c index be428f087a..d282385081 100644 --- a/platform/ext/target/musca_a/dummy_device_id.c +++ b/platform/ext/target/musca_a/dummy_device_id.c @@ -30,6 +30,7 @@ static const uint8_t implementation_id[] = { 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, }; +static const uint8_t example_ean_13[] = "060456527282910010"; /** * \brief Copy the device specific ID to the destination buffer * @@ -90,3 +91,18 @@ enum tfm_plat_err_t tfm_plat_get_implementation_id(uint32_t *size, return TFM_PLAT_ERR_SUCCESS; } + +enum tfm_plat_err_t tfm_plat_get_hw_version(uint32_t *size, uint8_t *buf) +{ + const uint8_t *p_hw_version = example_ean_13; + uint32_t hw_version_size = sizeof(example_ean_13) - 1; + + if (*size < hw_version_size) { + return TFM_PLAT_ERR_SYSTEM_ERR; + } + + copy_id(buf, p_hw_version, hw_version_size); + *size = hw_version_size; + + return TFM_PLAT_ERR_SUCCESS; +} diff --git a/platform/ext/target/musca_b1/dummy_device_id.c b/platform/ext/target/musca_b1/dummy_device_id.c index be428f087a..d282385081 100644 --- a/platform/ext/target/musca_b1/dummy_device_id.c +++ b/platform/ext/target/musca_b1/dummy_device_id.c @@ -30,6 +30,7 @@ static const uint8_t implementation_id[] = { 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, }; +static const uint8_t example_ean_13[] = "060456527282910010"; /** * \brief Copy the device specific ID to the destination buffer * @@ -90,3 +91,18 @@ enum tfm_plat_err_t tfm_plat_get_implementation_id(uint32_t *size, return TFM_PLAT_ERR_SUCCESS; } + +enum tfm_plat_err_t tfm_plat_get_hw_version(uint32_t *size, uint8_t *buf) +{ + const uint8_t *p_hw_version = example_ean_13; + uint32_t hw_version_size = sizeof(example_ean_13) - 1; + + if (*size < hw_version_size) { + return TFM_PLAT_ERR_SYSTEM_ERR; + } + + copy_id(buf, p_hw_version, hw_version_size); + *size = hw_version_size; + + return TFM_PLAT_ERR_SUCCESS; +} diff --git a/platform/include/tfm_plat_device_id.h b/platform/include/tfm_plat_device_id.h index 350505cce7..dcce8378c4 100644 --- a/platform/include/tfm_plat_device_id.h +++ b/platform/include/tfm_plat_device_id.h @@ -14,6 +14,7 @@ * attributes of the device: * - Instance ID: Unique identifier of the device. * - Implementation ID: Original implementation signer of the attestation key. + * - Hardware version: Identify the GDSII that went to fabrication. */ /** @@ -43,6 +44,15 @@ extern "C" { #define IMPLEMENTATION_ID_MAX_SIZE (32u) /** + * \def HW_VERSION_MAX_SIZE + * + * \brief Maximum size of hardware version in bytes + * + * Recommended to use the European Article Number format: EAN-13+5 + */ +#define HW_VERSION_MAX_SIZE (18u) + +/** * \brief Get the UEID of the device. * * This mandatory claim represents the unique identifier of the instance. @@ -82,6 +92,24 @@ enum tfm_plat_err_t tfm_plat_get_instance_id(uint32_t *size, uint8_t *buf); enum tfm_plat_err_t tfm_plat_get_implementation_id(uint32_t *size, uint8_t *buf); +/** + * \brief Get the hardware version of the device. + * + * This optional claim provides metadata linking the token to the GDSII that + * went to fabrication for this instance. It is represented as CBOR text string. + * It is recommended to use for identification the format of the European + * Article Number: EAN-13+5. + * + * \param[in/out] size As an input value it indicates the size of the caller + * allocated buffer (in bytes) to store the HW version. At + * return its value is updated with the exact size of the + * HW version. + * \param[out] buf Pointer to the buffer to store the HW version + * + * \return Returns error code specified in \ref tfm_plat_err_t + */ +enum tfm_plat_err_t tfm_plat_get_hw_version(uint32_t *size, uint8_t *buf); + #ifdef __cplusplus } #endif |