diff --git a/README.md b/README.md index 7db13cdc..b8052a16 100644 --- a/README.md +++ b/README.md @@ -62,9 +62,9 @@ Reference implementation for most common STSE applicative use case can be found Following applicative project can be used as reference for STSELib integration and usage. - STSAFE-A - - [stsafe-a-sdk](https://github.com/STMicroelectronics/STSAFE-A120-sdk) - - [wolfssl-examples](https://github.com/wolfSSL/wolfssl-examples/tree/master/stsafe) developed and maintained by [WolfSSL](https://www.wolfssl.com/) - - [Zephyr_st-stsafe-a1xx](https://github.com/catie-aq/zephyr_st-stsafe-a1xx) developed and maintained by [CATIE](https://www.catie.fr/language/en/home/) + - [stsafe-a-sdk](https://github.com/STMicroelectronics/STSAFE-A120-sdk) + - [wolfssl-examples](https://github.com/wolfSSL/wolfssl-examples/tree/master/stsafe) developed and maintained by [WolfSSL](https://www.wolfssl.com/) + - [Zephyr_st-stsafe-a1xx](https://github.com/catie-aq/zephyr_st-stsafe-a1xx) developed and maintained by [CATIE](https://www.catie.fr/language/en/home/) - STSAFE-L diff --git a/api/stse_aes.c b/api/stse_aes.c index f881e6e5..f019f9da 100644 --- a/api/stse_aes.c +++ b/api/stse_aes.c @@ -15,6 +15,9 @@ * *****************************************************************************/ +/* Includes ------------------------------------------------------------------*/ +#include + #include "api/stse_aes.h" stse_ReturnCode_t stse_aes_ecb_encrypt( diff --git a/api/stse_asymmetric_keys_management.c b/api/stse_asymmetric_keys_management.c index d14f7bcd..91ec0437 100644 --- a/api/stse_asymmetric_keys_management.c +++ b/api/stse_asymmetric_keys_management.c @@ -16,6 +16,8 @@ *****************************************************************************/ /* Includes ------------------------------------------------------------------*/ +#include +#include #include "api/stse_asymmetric_keys_management.h" diff --git a/api/stse_data_storage.c b/api/stse_data_storage.c index 4f43d8f3..b2231ae6 100644 --- a/api/stse_data_storage.c +++ b/api/stse_data_storage.c @@ -43,7 +43,7 @@ stse_ReturnCode_t stse_data_storage_get_partitioning_table( stse_Handler_t *pSTSE, PLAT_UI8 total_partition_count, stsafea_data_partition_record_t *pPartitioning_table, - PLAT_UI16 Partitioning_table_length) { + PLAT_UI16 partitioning_table_size) { stse_ReturnCode_t ret = STSE_API_INCOMPATIBLE_DEVICE_TYPE; @@ -51,7 +51,7 @@ stse_ReturnCode_t stse_data_storage_get_partitioning_table( #ifdef STSE_CONF_STSAFE_L_SUPPORT if (pSTSE->device_type != STSAFE_L010) { #endif /* STSE_CONF_STSAFE_L_SUPPORT */ - ret = stsafea_get_data_partitions_configuration(pSTSE, total_partition_count, pPartitioning_table, Partitioning_table_length); + ret = stsafea_get_data_partitions_configuration(pSTSE, total_partition_count, pPartitioning_table, partitioning_table_size); #ifdef STSE_CONF_STSAFE_L_SUPPORT } #endif /* STSE_CONF_STSAFE_L_SUPPORT */ @@ -111,7 +111,6 @@ stse_ReturnCode_t stse_data_storage_read_data_zone( case STSAFE_A100: case STSAFE_A110: case STSAFE_A120: - case STSAFE_A200: ret = stsafea_read_data_zone( pSTSE, zone, @@ -181,7 +180,6 @@ stse_ReturnCode_t stse_data_storage_update_data_zone( case STSAFE_A100: case STSAFE_A110: case STSAFE_A120: - case STSAFE_A200: ret = stsafea_update_data_zone( pSTSE, zone, @@ -242,7 +240,6 @@ stse_ReturnCode_t stse_data_storage_decrement_counter_zone( case STSAFE_A100: case STSAFE_A110: case STSAFE_A120: - case STSAFE_A200: ret = stsafea_decrement_counter_zone( pSTSE, zone, @@ -315,7 +312,6 @@ stse_ReturnCode_t stse_data_storage_read_counter_zone( case STSAFE_A100: case STSAFE_A110: case STSAFE_A120: - case STSAFE_A200: ret = stsafea_read_counter_zone( pSTSE, zone, diff --git a/api/stse_data_storage.h b/api/stse_data_storage.h index b883f831..c8b4ce12 100644 --- a/api/stse_data_storage.h +++ b/api/stse_data_storage.h @@ -49,7 +49,7 @@ stse_ReturnCode_t stse_data_storage_get_total_partition_count( * \param[in] pSTSE Pointer to target STSE handler * \param[in] total_partition_count Total partition count * \param[out] pPartitioning_table Pointer to the partition table buffer - * \param[in] Partitioning_table_length Length of the partition table to be received + * \param[in] partitioning_table_size Size (in bytes) of the partition table (@p pPartitioning_table) to be received * \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise * \details \include{doc} stse_data_storage_get_partitioning_table.dox */ @@ -57,7 +57,7 @@ stse_ReturnCode_t stse_data_storage_get_partitioning_table( stse_Handler_t *pSTSE, PLAT_UI8 total_partition_count, stsafea_data_partition_record_t *pPartitioning_table, - PLAT_UI16 Partitioning_table_length); + PLAT_UI16 partitioning_table_size); /*! * \brief Read one memory zone of the STSE device diff --git a/api/stse_derive_keys.c b/api/stse_derive_keys.c index 5ae0428d..40c4e64a 100644 --- a/api/stse_derive_keys.c +++ b/api/stse_derive_keys.c @@ -15,6 +15,10 @@ * *****************************************************************************/ +/* Includes ------------------------------------------------------------------*/ +#include +#include + #include "api/stse_derive_keys.h" stse_ReturnCode_t stse_derive_key( diff --git a/api/stse_device_authentication.c b/api/stse_device_authentication.c index 23fc560c..bceafe2d 100644 --- a/api/stse_device_authentication.c +++ b/api/stse_device_authentication.c @@ -16,6 +16,7 @@ *****************************************************************************/ /* Includes ------------------------------------------------------------------*/ +#include #include "api/stse_device_authentication.h" #include "api/stse_ecc.h" diff --git a/api/stse_device_management.c b/api/stse_device_management.c index 50854700..a8ba4f77 100644 --- a/api/stse_device_management.c +++ b/api/stse_device_management.c @@ -16,6 +16,8 @@ *****************************************************************************/ /* Includes ------------------------------------------------------------------*/ +#include + #include "api/stse_device_management.h" /* Exported variables --------------------------------------------------------*/ @@ -122,7 +124,6 @@ stse_ReturnCode_t stse_device_enter_hibernate(stse_Handler_t *pSTSE, #ifdef STSE_CONF_STSAFE_A_SUPPORT case STSAFE_A100: case STSAFE_A110: - case STSAFE_A200: ret = stsafea_hibernate(pSTSE, wake_up_mode); break; case STSAFE_A120: @@ -154,7 +155,6 @@ stse_ReturnCode_t stse_device_power_on(stse_Handler_t *pSTSE) { case STSAFE_A100: case STSAFE_A110: case STSAFE_A120: - case STSAFE_A200: stse_platform_Delay_ms(stsafea_boot_time[pSTSE->device_type]); break; #endif /* STSE_CONF_STSAFE_A_SUPPORT */ @@ -200,7 +200,6 @@ stse_ReturnCode_t stse_device_echo(stse_Handler_t *pSTSE, PLAT_UI8 *pIn, PLAT_UI case STSAFE_A100: case STSAFE_A110: case STSAFE_A120: - case STSAFE_A200: return stsafea_echo(pSTSE, pIn, pOut, size); #endif /* STSE_CONF_STSAFE_A_SUPPORT */ default: @@ -315,7 +314,6 @@ stse_ReturnCode_t stse_device_reset(stse_Handler_t *pSTSE) { case STSAFE_A100: case STSAFE_A110: case STSAFE_A120: - case STSAFE_A200: ret = stsafea_reset(pSTSE); break; #endif /* STSE_CONF_STSAFE_A_SUPPORT */ diff --git a/api/stse_ecc.c b/api/stse_ecc.c index 33256e60..1308baa1 100644 --- a/api/stse_ecc.c +++ b/api/stse_ecc.c @@ -15,14 +15,17 @@ * *****************************************************************************/ +/* Includes ------------------------------------------------------------------*/ +#include + #include "api/stse_ecc.h" stse_ReturnCode_t stse_ecc_verify_signature( stse_Handler_t *pSTSE, stse_ecc_key_type_t key_type, - PLAT_UI8 *pPublic_key, - PLAT_UI8 *pSignature, - PLAT_UI8 *pMessage, + const PLAT_UI8 *pPublic_key, + const PLAT_UI8 *pSignature, + const PLAT_UI8 *pMessage, PLAT_UI16 message_length, PLAT_UI8 eddsa_variant, PLAT_UI8 *pSignature_validity) { @@ -81,7 +84,6 @@ stse_ReturnCode_t stse_ecc_generate_signature( case STSAFE_A100: case STSAFE_A110: case STSAFE_A120: - case STSAFE_A200: ret = stsafea_ecc_generate_signature(pSTSE, slot_number, key_type, pMessage, message_length, pSignature); break; #endif /* STSE_CONF_STSAFE_A_SUPPORT */ diff --git a/api/stse_ecc.h b/api/stse_ecc.h index 75838b15..5f07d903 100644 --- a/api/stse_ecc.h +++ b/api/stse_ecc.h @@ -60,9 +60,9 @@ stse_ReturnCode_t stse_ecc_verify_signature( stse_Handler_t *pSTSE, stse_ecc_key_type_t key_type, - PLAT_UI8 *pPublic_key, - PLAT_UI8 *pSignature, - PLAT_UI8 *pMessage, + const PLAT_UI8 *pPublic_key, + const PLAT_UI8 *pSignature, + const PLAT_UI8 *pMessage, PLAT_UI16 message_length, PLAT_UI8 eddsa_variant, PLAT_UI8 *pSignature_validity); diff --git a/api/stse_hash.c b/api/stse_hash.c index a96a3637..5ab213e8 100644 --- a/api/stse_hash.c +++ b/api/stse_hash.c @@ -15,6 +15,9 @@ * *****************************************************************************/ +/* Includes ------------------------------------------------------------------*/ +#include + #include "api/stse_hash.h" #include "services/stsafea/stsafea_frame_transfer.h" #include "services/stsafea/stsafea_hash.h" diff --git a/api/stse_mac.c b/api/stse_mac.c index 70b33170..1d9756b2 100644 --- a/api/stse_mac.c +++ b/api/stse_mac.c @@ -15,6 +15,9 @@ * *****************************************************************************/ +/* Includes ------------------------------------------------------------------*/ +#include + #include "api/stse_mac.h" stse_ReturnCode_t stse_cmac_hmac_compute( diff --git a/api/stse_random.c b/api/stse_random.c index 1bd879f3..6e6a4836 100644 --- a/api/stse_random.c +++ b/api/stse_random.c @@ -15,6 +15,9 @@ * *****************************************************************************/ +/* Includes ------------------------------------------------------------------*/ +#include + #include "api/stse_random.h" stse_ReturnCode_t stse_generate_random( diff --git a/api/stse_symmetric_keys_management.c b/api/stse_symmetric_keys_management.c index a79e2da1..cb8b1e5b 100644 --- a/api/stse_symmetric_keys_management.c +++ b/api/stse_symmetric_keys_management.c @@ -16,9 +16,11 @@ *****************************************************************************/ /* Includes ------------------------------------------------------------------*/ +#include +#include -#include "api/stse_symmetric_keys_management.h" #include "api/stse_asymmetric_keys_management.h" +#include "api/stse_symmetric_keys_management.h" #include "services/stsafea/stsafea_public_key_slots.h" #define STSAFEA_HOST_KEY_WRAPPING_AUTHENTICATION_TAG_LENGTH STSE_KEK_ENVELOPE_MAC_SIZE @@ -103,7 +105,7 @@ static stse_ReturnCode_t stse_start_volatile_KEK_session( memset(stsafe_ecdhe_public_key, 0, pub_key_size); memset(host_ecdhe_public_key, 0, pub_key_size); memset(host_ecdhe_private_key, 0, priv_key_size); - stsafea_session_clear_context(pSession); + stse_session_erase_context(pSession); return ret; } @@ -118,7 +120,7 @@ static stse_ReturnCode_t stse_start_volatile_KEK_session( if (ret != STSE_OK) { memset(stsafe_ecdhe_public_key, 0, pub_key_size); memset(host_ecdhe_public_key, 0, pub_key_size); - stsafea_session_clear_context(pSession); + stse_session_erase_context(pSession); return (STSE_UNEXPECTED_ERROR); } @@ -144,7 +146,7 @@ static stse_ReturnCode_t stse_start_volatile_KEK_session( memset(host_ecdhe_public_key, 0, pub_key_size); if (ret != STSE_OK) { - stsafea_session_clear_context(pSession); + stse_session_erase_context(pSession); return (STSE_UNEXPECTED_ERROR); } @@ -305,7 +307,7 @@ static stse_ReturnCode_t stse_start_volatile_KEK_session_authenticated( memset(host_ecdhe_public_key, 0, pub_key_size); memset(host_ecdhe_private_key, 0, ecdhe_priv_key_size); memset(pTBS, 0, tbs_length); - stsafea_session_clear_context(pSession); + stse_session_erase_context(pSession); return ret; } @@ -322,7 +324,7 @@ static stse_ReturnCode_t stse_start_volatile_KEK_session_authenticated( memset(stsafe_ecdhe_public_key, 0, pub_key_size); memset(host_ecdhe_public_key, 0, pub_key_size); memset(host_ecdhe_private_key, 0, ecdhe_priv_key_size); - stsafea_session_clear_context(pSession); + stse_session_erase_context(pSession); return ret; } @@ -336,7 +338,7 @@ static stse_ReturnCode_t stse_start_volatile_KEK_session_authenticated( if (ret != STSE_OK) { memset(stsafe_ecdhe_public_key, 0, pub_key_size); memset(host_ecdhe_public_key, 0, pub_key_size); - stsafea_session_clear_context(pSession); + stse_session_erase_context(pSession); return (STSE_UNEXPECTED_ERROR); } @@ -363,7 +365,7 @@ static stse_ReturnCode_t stse_start_volatile_KEK_session_authenticated( memset(shared_secret, 0, stse_ecc_info_table[ecc_key_type].shared_secret_size); if (ret != STSE_OK) { - stsafea_session_clear_context(pSession); + stse_session_erase_context(pSession); return (STSE_UNEXPECTED_ERROR); } @@ -387,7 +389,7 @@ static stse_ReturnCode_t stse_stop_volatile_KEK_session(stse_Handler_t *pSTSE, s } /* - Clear KEK session context on local host */ - stsafea_session_clear_context(pSession); + stse_session_erase_context(pSession); /* - Clear KEK session context in target SE */ ret = stsafea_stop_volatile_KEK_session(pSTSE); @@ -547,7 +549,7 @@ stse_ReturnCode_t stse_host_key_provisioning_wrapped( PLAT_UI8 host_key_envelope[host_keys_envelope_length]; stse_session_t volatile_KEK_session; - stsafea_session_clear_context(&volatile_KEK_session); + stse_session_erase_context(&volatile_KEK_session); /* - Start volatile KEK */ ret = stse_start_volatile_KEK_session( @@ -634,7 +636,7 @@ stse_ReturnCode_t stse_host_key_provisioning_wrapped_authenticated( PLAT_UI8 host_key_envelope[host_keys_envelope_length]; stse_session_t volatile_KEK_session; - stsafea_session_clear_context(&volatile_KEK_session); + stse_session_erase_context(&volatile_KEK_session); /* - Start volatile KEK Authenticated */ ret = stse_start_volatile_KEK_session_authenticated( @@ -1208,7 +1210,7 @@ stse_ReturnCode_t stse_write_symmetric_key_wrapped( } stse_session_t volatile_KEK_session; - stsafea_session_clear_context(&volatile_KEK_session); + stse_session_erase_context(&volatile_KEK_session); /* - Start Volatile KEK session */ ret = stse_start_volatile_KEK_session(pSTSE, &volatile_KEK_session, kek_session_ecc_type); @@ -1291,7 +1293,7 @@ stse_ReturnCode_t stse_write_symmetric_key_wrapped_authenticated( } stse_session_t volatile_KEK_session; - stsafea_session_clear_context(&volatile_KEK_session); + stse_session_erase_context(&volatile_KEK_session); /* - Start volatile KEK Authenticated */ ret = stse_start_volatile_KEK_session_authenticated( diff --git a/certificate/stse_certificate_crypto.c b/certificate/stse_certificate_crypto.c index 3945b62e..c0fb27a8 100644 --- a/certificate/stse_certificate_crypto.c +++ b/certificate/stse_certificate_crypto.c @@ -15,9 +15,13 @@ ****************************************************************************** */ -#include "certificate/stse_certificate_crypto.h" +/* Includes ------------------------------------------------------------------*/ +#include +#include + #include "api/stse_ecc.h" #include "api/stse_hash.h" +#include "certificate/stse_certificate_crypto.h" stse_ReturnCode_t stse_certificate_verify_cert_signature(const stse_certificate_t *parent, const stse_certificate_t *child) { stse_ReturnCode_t ret; diff --git a/core/stse_device.c b/core/stse_device.c index 4bcd299c..5d779f3c 100644 --- a/core/stse_device.c +++ b/core/stse_device.c @@ -1,7 +1,7 @@ /*! * ****************************************************************************** * \file stse_device.c - * \brief STSAFE Frame layer (sources) + * \brief STSELib api for device (sources) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -29,14 +29,17 @@ stse_ReturnCode_t stse_set_default_handler_value(stse_Handler_t *pStseHandler) { memset(&pStseHandler->perso_info, 0, sizeof(pStseHandler->perso_info)); pStseHandler->pActive_host_session = NULL; pStseHandler->pActive_other_session = NULL; +#if defined(STSE_CONF_STSAFE_A_SUPPORT) || \ + (defined(STSE_CONF_STSAFE_L_SUPPORT) && defined(STSE_CONF_USE_I2C)) pStseHandler->io.BusRecvStart = stse_platform_i2c_receive_start; pStseHandler->io.BusRecvContinue = stse_platform_i2c_receive_continue; pStseHandler->io.BusRecvStop = stse_platform_i2c_receive_stop; pStseHandler->io.BusSendStart = stse_platform_i2c_send_start; pStseHandler->io.BusSendContinue = stse_platform_i2c_send_continue; pStseHandler->io.BusSendStop = stse_platform_i2c_send_stop; - pStseHandler->io.IOLineGet = NULL; pStseHandler->io.BusWake = stse_platform_i2c_wake; +#endif /* STSE_CONF_STSAFE_A_SUPPORT || (STSE_CONF_STSAFE_L_SUPPORT && defined(STSE_CONF_USE_I2C) */ + pStseHandler->io.IOLineGet = NULL; pStseHandler->io.BusRecovery = NULL; pStseHandler->io.PowerLineOff = stse_platform_power_off; pStseHandler->io.PowerLineOn = stse_platform_power_on; diff --git a/core/stse_device.h b/core/stse_device.h index e3235147..2ab4df9e 100644 --- a/core/stse_device.h +++ b/core/stse_device.h @@ -1,7 +1,7 @@ /*! * ****************************************************************************** * \file stse_device.h - * \brief STSE device (header) + * \brief STSELib api for device (header) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -52,7 +52,6 @@ typedef enum stse_device_t { STSAFE_A100, /*!< STSAFE-A100 target device */ STSAFE_A110, /*!< STSAFE-A110 target device */ STSAFE_A120, /*!< STSAFE-A120 target device */ - STSAFE_A200, /*!< STSAFE-A200 target device */ #endif /* STSE_CONF_STSAFE_A_SUPPORT */ #ifdef STSE_CONF_STSAFE_L_SUPPORT STSAFE_L010 /*!< STSAFE-L010 target device */ diff --git a/core/stse_frame.c b/core/stse_frame.c index b6421848..e8f92db2 100644 --- a/core/stse_frame.c +++ b/core/stse_frame.c @@ -1,7 +1,7 @@ /*! * ****************************************************************************** * \file stse_frame.c - * \brief STSAFE Frame layer (sources) + * \brief STSELib api for frame layer (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -16,6 +16,10 @@ ****************************************************************************** */ +/* Includes ------------------------------------------------------------------*/ +#include +#include + #include "core/stse_frame.h" stse_ReturnCode_t stse_frame_crc16_compute(stse_frame_t *pFrame, PLAT_UI16 *pCrc) { diff --git a/core/stse_frame.h b/core/stse_frame.h index 36b874b3..58249acc 100644 --- a/core/stse_frame.h +++ b/core/stse_frame.h @@ -1,7 +1,7 @@ /*! * ****************************************************************************** * \file stse_frame.h - * \brief STSAFE Frame layer (header) + * \brief STSELib api for frame layer (header) * \author STMicroelectronics - CS application team * ****************************************************************************** diff --git a/core/stse_generic_typedef.c b/core/stse_generic_typedef.c index 334c2f44..12bab7d4 100644 --- a/core/stse_generic_typedef.c +++ b/core/stse_generic_typedef.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stse_generic_typedef.c - * \brief STSE Generic typedefs (source) + * \brief STSELib generic typedefs (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -16,6 +16,9 @@ ****************************************************************************** */ +/* Includes ------------------------------------------------------------------*/ +#include + #include "core/stse_generic_typedef.h" const stse_ecc_info_t stse_ecc_info_table[] = @@ -27,91 +30,84 @@ const stse_ecc_info_t stse_ecc_info_table[] = { #ifdef STSE_CONF_ECC_NIST_P_256 [STSE_ECC_KT_NIST_P_256] = {/* NIST P 256 */ - .curve_id_total_length = (STSE_NIST_P_256_ID_VALUE_SIZE + STSE_ECC_CURVE_ID_LENGTH_SIZE), - .curve_id = {{UI16_B1(STSE_NIST_P_256_ID_VALUE_SIZE), UI16_B0(STSE_NIST_P_256_ID_VALUE_SIZE)}, - STSE_NIST_P_256_ID_VALUE}, - .coordinate_or_key_size = (STSE_NIST_P_256_X_COORDINATE_VALUE_SIZE), - .public_key_size = (STSE_NIST_P_256_X_COORDINATE_VALUE_SIZE + STSE_NIST_P_256_Y_COORDINATE_VALUE_SIZE), - .private_key_size = (STSE_NIST_P_256_PRIVATE_KEY_SIZE), - .shared_secret_size = (STSE_NIST_P_256_X_COORDINATE_VALUE_SIZE), - .signature_size = (STSE_NIST_P_256_SIGNATURE_R_VALUE_SIZE + STSE_NIST_P_256_SIGNATURE_S_VALUE_SIZE)}, + .curve_id_total_length = (STSE_NIST_P_256_ID_VALUE_SIZE + STSE_ECC_CURVE_ID_LENGTH_SIZE), + .curve_id = {{UI16_B1(STSE_NIST_P_256_ID_VALUE_SIZE), UI16_B0(STSE_NIST_P_256_ID_VALUE_SIZE)}, + STSE_NIST_P_256_ID_VALUE}, + .coordinate_or_key_size = (STSE_NIST_P_256_X_COORDINATE_VALUE_SIZE), + .public_key_size = (STSE_NIST_P_256_X_COORDINATE_VALUE_SIZE + STSE_NIST_P_256_Y_COORDINATE_VALUE_SIZE), + .private_key_size = (STSE_NIST_P_256_PRIVATE_KEY_SIZE), + .shared_secret_size = (STSE_NIST_P_256_X_COORDINATE_VALUE_SIZE), + .signature_size = (STSE_NIST_P_256_SIGNATURE_R_VALUE_SIZE + STSE_NIST_P_256_SIGNATURE_S_VALUE_SIZE)}, #endif #ifdef STSE_CONF_ECC_NIST_P_384 [STSE_ECC_KT_NIST_P_384] = {/* NIST P_384 */ - .curve_id_total_length = (STSE_NIST_P_384_ID_VALUE_SIZE + STSE_ECC_CURVE_ID_LENGTH_SIZE), - .curve_id = {{UI16_B1(STSE_NIST_P_384_ID_VALUE_SIZE), UI16_B0(STSE_NIST_P_384_ID_VALUE_SIZE)}, - STSE_NIST_P_384_ID_VALUE}, - .coordinate_or_key_size = (STSE_NIST_P_384_X_COORDINATE_VALUE_SIZE), - .public_key_size = (STSE_NIST_P_384_X_COORDINATE_VALUE_SIZE + STSE_NIST_P_384_Y_COORDINATE_VALUE_SIZE), - .private_key_size = (STSE_NIST_P_384_PRIVATE_KEY_SIZE), - .shared_secret_size = (STSE_NIST_P_384_X_COORDINATE_VALUE_SIZE), - .signature_size = (STSE_NIST_P_384_SIGNATURE_R_VALUE_SIZE + STSE_NIST_P_384_SIGNATURE_S_VALUE_SIZE)}, + .curve_id_total_length = (STSE_NIST_P_384_ID_VALUE_SIZE + STSE_ECC_CURVE_ID_LENGTH_SIZE), + .curve_id = {{UI16_B1(STSE_NIST_P_384_ID_VALUE_SIZE), UI16_B0(STSE_NIST_P_384_ID_VALUE_SIZE)}, STSE_NIST_P_384_ID_VALUE}, + .coordinate_or_key_size = (STSE_NIST_P_384_X_COORDINATE_VALUE_SIZE), + .public_key_size = (STSE_NIST_P_384_X_COORDINATE_VALUE_SIZE + STSE_NIST_P_384_Y_COORDINATE_VALUE_SIZE), + .private_key_size = (STSE_NIST_P_384_PRIVATE_KEY_SIZE), + .shared_secret_size = (STSE_NIST_P_384_X_COORDINATE_VALUE_SIZE), + .signature_size = (STSE_NIST_P_384_SIGNATURE_R_VALUE_SIZE + STSE_NIST_P_384_SIGNATURE_S_VALUE_SIZE)}, #endif #ifdef STSE_CONF_ECC_NIST_P_521 [STSE_ECC_KT_NIST_P_521] = {/* NIST P 521 */ - .curve_id_total_length = (STSE_NIST_P_521_ID_VALUE_SIZE + STSE_ECC_CURVE_ID_LENGTH_SIZE), - .curve_id = {{UI16_B1(STSE_NIST_P_521_ID_VALUE_SIZE), UI16_B0(STSE_NIST_P_521_ID_VALUE_SIZE)}, - STSE_NIST_P_521_ID_VALUE}, - .coordinate_or_key_size = (STSE_NIST_P_521_X_COORDINATE_VALUE_SIZE), - .public_key_size = (STSE_NIST_P_521_X_COORDINATE_VALUE_SIZE + STSE_NIST_P_521_Y_COORDINATE_VALUE_SIZE), - .private_key_size = (STSE_NIST_P_521_PRIVATE_KEY_SIZE), - .shared_secret_size = (STSE_NIST_P_521_X_COORDINATE_VALUE_SIZE), - .signature_size = (STSE_NIST_P_521_SIGNATURE_R_VALUE_SIZE + STSE_NIST_P_521_SIGNATURE_S_VALUE_SIZE)}, + .curve_id_total_length = (STSE_NIST_P_521_ID_VALUE_SIZE + STSE_ECC_CURVE_ID_LENGTH_SIZE), + .curve_id = {{UI16_B1(STSE_NIST_P_521_ID_VALUE_SIZE), UI16_B0(STSE_NIST_P_521_ID_VALUE_SIZE)}, STSE_NIST_P_521_ID_VALUE}, + .coordinate_or_key_size = (STSE_NIST_P_521_X_COORDINATE_VALUE_SIZE), + .public_key_size = (STSE_NIST_P_521_X_COORDINATE_VALUE_SIZE + STSE_NIST_P_521_Y_COORDINATE_VALUE_SIZE), + .private_key_size = (STSE_NIST_P_521_PRIVATE_KEY_SIZE), + .shared_secret_size = (STSE_NIST_P_521_X_COORDINATE_VALUE_SIZE), + .signature_size = (STSE_NIST_P_521_SIGNATURE_R_VALUE_SIZE + STSE_NIST_P_521_SIGNATURE_S_VALUE_SIZE)}, #endif #ifdef STSE_CONF_ECC_BRAINPOOL_P_256 [STSE_ECC_KT_BP_P_256] = {/* BRAINPOOL P 256 */ - .curve_id_total_length = (STSE_BRAINPOOL_P_256_ID_VALUE_SIZE + STSE_ECC_CURVE_ID_LENGTH_SIZE), - .curve_id = {{UI16_B1(STSE_BRAINPOOL_P_256_ID_VALUE_SIZE), UI16_B0(STSE_BRAINPOOL_P_256_ID_VALUE_SIZE)}, - STSE_BRAINPOOL_P_256_ID_VALUE}, - .coordinate_or_key_size = (STSE_BRAINPOOL_P_256_X_COORDINATE_VALUE_SIZE), - .public_key_size = (STSE_BRAINPOOL_P_256_X_COORDINATE_VALUE_SIZE + STSE_BRAINPOOL_P_256_Y_COORDINATE_VALUE_SIZE), - .private_key_size = (STSE_BRAINPOOL_P_256_PRIVATE_KEY_SIZE), - .shared_secret_size = (STSE_BRAINPOOL_P_256_X_COORDINATE_VALUE_SIZE), - .signature_size = (STSE_BRAINPOOL_P_256_SIGNATURE_R_VALUE_SIZE + STSE_BRAINPOOL_P_256_SIGNATURE_S_VALUE_SIZE)}, + .curve_id_total_length = (STSE_BRAINPOOL_P_256_ID_VALUE_SIZE + STSE_ECC_CURVE_ID_LENGTH_SIZE), + .curve_id = {{UI16_B1(STSE_BRAINPOOL_P_256_ID_VALUE_SIZE), UI16_B0(STSE_BRAINPOOL_P_256_ID_VALUE_SIZE)}, STSE_BRAINPOOL_P_256_ID_VALUE}, + .coordinate_or_key_size = (STSE_BRAINPOOL_P_256_X_COORDINATE_VALUE_SIZE), + .public_key_size = (STSE_BRAINPOOL_P_256_X_COORDINATE_VALUE_SIZE + STSE_BRAINPOOL_P_256_Y_COORDINATE_VALUE_SIZE), + .private_key_size = (STSE_BRAINPOOL_P_256_PRIVATE_KEY_SIZE), + .shared_secret_size = (STSE_BRAINPOOL_P_256_X_COORDINATE_VALUE_SIZE), + .signature_size = (STSE_BRAINPOOL_P_256_SIGNATURE_R_VALUE_SIZE + STSE_BRAINPOOL_P_256_SIGNATURE_S_VALUE_SIZE)}, #endif #ifdef STSE_CONF_ECC_BRAINPOOL_P_384 [STSE_ECC_KT_BP_P_384] = {/* BRAINPOOL P 384 */ - .curve_id_total_length = (STSE_BRAINPOOL_P_384_ID_VALUE_SIZE + STSE_ECC_CURVE_ID_LENGTH_SIZE), - .curve_id = {{UI16_B1(STSE_BRAINPOOL_P_384_ID_VALUE_SIZE), UI16_B0(STSE_BRAINPOOL_P_384_ID_VALUE_SIZE)}, - STSE_BRAINPOOL_P_384_ID_VALUE}, - .coordinate_or_key_size = (STSE_BRAINPOOL_P_384_X_COORDINATE_VALUE_SIZE), - .public_key_size = (STSE_BRAINPOOL_P_384_X_COORDINATE_VALUE_SIZE + STSE_BRAINPOOL_P_384_Y_COORDINATE_VALUE_SIZE), - .private_key_size = (STSE_BRAINPOOL_P_384_PRIVATE_KEY_SIZE), - .shared_secret_size = (STSE_BRAINPOOL_P_384_X_COORDINATE_VALUE_SIZE), - .signature_size = (STSE_BRAINPOOL_P_384_SIGNATURE_R_VALUE_SIZE + STSE_BRAINPOOL_P_384_SIGNATURE_S_VALUE_SIZE)}, + .curve_id_total_length = (STSE_BRAINPOOL_P_384_ID_VALUE_SIZE + STSE_ECC_CURVE_ID_LENGTH_SIZE), + .curve_id = {{UI16_B1(STSE_BRAINPOOL_P_384_ID_VALUE_SIZE), UI16_B0(STSE_BRAINPOOL_P_384_ID_VALUE_SIZE)}, STSE_BRAINPOOL_P_384_ID_VALUE}, + .coordinate_or_key_size = (STSE_BRAINPOOL_P_384_X_COORDINATE_VALUE_SIZE), + .public_key_size = (STSE_BRAINPOOL_P_384_X_COORDINATE_VALUE_SIZE + STSE_BRAINPOOL_P_384_Y_COORDINATE_VALUE_SIZE), + .private_key_size = (STSE_BRAINPOOL_P_384_PRIVATE_KEY_SIZE), + .shared_secret_size = (STSE_BRAINPOOL_P_384_X_COORDINATE_VALUE_SIZE), + .signature_size = (STSE_BRAINPOOL_P_384_SIGNATURE_R_VALUE_SIZE + STSE_BRAINPOOL_P_384_SIGNATURE_S_VALUE_SIZE)}, #endif #ifdef STSE_CONF_ECC_BRAINPOOL_P_512 [STSE_ECC_KT_BP_P_512] = {/* BRAINPOOL P 512 */ - .curve_id_total_length = (STSE_BRAINPOOL_P_512_ID_VALUE_SIZE + STSE_ECC_CURVE_ID_LENGTH_SIZE), - .curve_id = {{UI16_B1(STSE_BRAINPOOL_P_512_ID_VALUE_SIZE), UI16_B0(STSE_BRAINPOOL_P_512_ID_VALUE_SIZE)}, - STSE_BRAINPOOL_P_512_ID_VALUE}, - .coordinate_or_key_size = (STSE_BRAINPOOL_P_512_X_COORDINATE_VALUE_SIZE), - .public_key_size = (STSE_BRAINPOOL_P_512_X_COORDINATE_VALUE_SIZE + STSE_BRAINPOOL_P_512_Y_COORDINATE_VALUE_SIZE), - .private_key_size = (STSE_BRAINPOOL_P_512_PRIVATE_KEY_SIZE), - .shared_secret_size = (STSE_BRAINPOOL_P_512_X_COORDINATE_VALUE_SIZE), - .signature_size = (STSE_BRAINPOOL_P_512_SIGNATURE_R_VALUE_SIZE + STSE_BRAINPOOL_P_512_SIGNATURE_S_VALUE_SIZE)}, + .curve_id_total_length = (STSE_BRAINPOOL_P_512_ID_VALUE_SIZE + STSE_ECC_CURVE_ID_LENGTH_SIZE), + .curve_id = {{UI16_B1(STSE_BRAINPOOL_P_512_ID_VALUE_SIZE), UI16_B0(STSE_BRAINPOOL_P_512_ID_VALUE_SIZE)}, STSE_BRAINPOOL_P_512_ID_VALUE}, + .coordinate_or_key_size = (STSE_BRAINPOOL_P_512_X_COORDINATE_VALUE_SIZE), + .public_key_size = (STSE_BRAINPOOL_P_512_X_COORDINATE_VALUE_SIZE + STSE_BRAINPOOL_P_512_Y_COORDINATE_VALUE_SIZE), + .private_key_size = (STSE_BRAINPOOL_P_512_PRIVATE_KEY_SIZE), + .shared_secret_size = (STSE_BRAINPOOL_P_512_X_COORDINATE_VALUE_SIZE), + .signature_size = (STSE_BRAINPOOL_P_512_SIGNATURE_R_VALUE_SIZE + STSE_BRAINPOOL_P_512_SIGNATURE_S_VALUE_SIZE)}, #endif #ifdef STSE_CONF_ECC_CURVE_25519 [STSE_ECC_KT_CURVE25519] = {/* X25519 */ - .curve_id_total_length = (STSE_X25519_ID_VALUE_SIZE + STSE_ECC_CURVE_ID_LENGTH_SIZE), - .curve_id = {{UI16_B1(STSE_X25519_ID_VALUE_SIZE), UI16_B0(STSE_X25519_ID_VALUE_SIZE)}, - STSE_X25519_ID_VALUE}, - .coordinate_or_key_size = STSE_X25519_PUBLIC_KEY_VALUE_SIZE, - .public_key_size = STSE_X25519_PUBLIC_KEY_VALUE_SIZE, - .private_key_size = STSE_X25519_PRIVATE_KEY_SIZE, - .shared_secret_size = STSE_X25519_SHARED_SECRET_VALUE_SIZE, - .signature_size = 0}, + .curve_id_total_length = (STSE_X25519_ID_VALUE_SIZE + STSE_ECC_CURVE_ID_LENGTH_SIZE), + .curve_id = {{UI16_B1(STSE_X25519_ID_VALUE_SIZE), UI16_B0(STSE_X25519_ID_VALUE_SIZE)}, STSE_X25519_ID_VALUE}, + .coordinate_or_key_size = STSE_X25519_PUBLIC_KEY_VALUE_SIZE, + .public_key_size = STSE_X25519_PUBLIC_KEY_VALUE_SIZE, + .private_key_size = STSE_X25519_PRIVATE_KEY_SIZE, + .shared_secret_size = STSE_X25519_SHARED_SECRET_VALUE_SIZE, + .signature_size = 0}, #endif #ifdef STSE_CONF_ECC_EDWARD_25519 [STSE_ECC_KT_ED25519] = {/* ED25519 */ - .curve_id_total_length = (STSE_ED25519_ID_VALUE_SIZE + STSE_ECC_CURVE_ID_LENGTH_SIZE), - .curve_id = {{UI16_B1(STSE_ED25519_ID_VALUE_SIZE), UI16_B0(STSE_ED25519_ID_VALUE_SIZE)}, - STSE_ED25519_ID_VALUE}, - .coordinate_or_key_size = STSE_ED25519_PUBLIC_KEY_VALUE_SIZE, - .public_key_size = STSE_ED25519_PUBLIC_KEY_VALUE_SIZE, - .private_key_size = STSE_ED25519_PRIVATE_KEY_SIZE, - .shared_secret_size = 0, - .signature_size = (STSE_ED25519_SIGNATURE_R_VALUE_SIZE + STSE_ED25519_SIGNATURE_S_VALUE_SIZE)}, + .curve_id_total_length = (STSE_ED25519_ID_VALUE_SIZE + STSE_ECC_CURVE_ID_LENGTH_SIZE), + .curve_id = {{UI16_B1(STSE_ED25519_ID_VALUE_SIZE), UI16_B0(STSE_ED25519_ID_VALUE_SIZE)}, STSE_ED25519_ID_VALUE}, + .coordinate_or_key_size = STSE_ED25519_PUBLIC_KEY_VALUE_SIZE, + .public_key_size = STSE_ED25519_PUBLIC_KEY_VALUE_SIZE, + .private_key_size = STSE_ED25519_PRIVATE_KEY_SIZE, + .shared_secret_size = 0, + .signature_size = (STSE_ED25519_SIGNATURE_R_VALUE_SIZE + STSE_ED25519_SIGNATURE_S_VALUE_SIZE)}, #endif }; #endif diff --git a/core/stse_generic_typedef.h b/core/stse_generic_typedef.h index e3f5dfb5..f5b37acf 100644 --- a/core/stse_generic_typedef.h +++ b/core/stse_generic_typedef.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stse_generic_typedef.h - * \brief STSE Generic typedefs (header) + * \brief STSELib generic typedefs header) * \author STMicroelectronics - CS application team * ****************************************************************************** diff --git a/core/stse_platform.c b/core/stse_platform.c index a56734f0..c46ce2d2 100644 --- a/core/stse_platform.c +++ b/core/stse_platform.c @@ -1,6 +1,6 @@ /****************************************************************************** - * \file stselib_crypto_platform.h - * \brief STSecureElement cryptographic platform file + * \file stse_platform.h + * \brief STSELib core functions for platform Abstraction layer (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -15,6 +15,9 @@ ****************************************************************************** */ +/* Includes ------------------------------------------------------------------*/ +#include + #include "core/stse_platform.h" #include "services/stsafea/stsafea_hash.h" diff --git a/core/stse_platform.h b/core/stse_platform.h index d147eabb..3dc775b0 100644 --- a/core/stse_platform.h +++ b/core/stse_platform.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stse_platform.h - * \brief STSAFE-Axxx Middleware Platform Abstraction layer (header) + * \brief STSELib callback functions declaration for platform Abstraction layer (header) * \author STMicroelectronics - CS application team * ****************************************************************************** diff --git a/core/stse_return_codes.h b/core/stse_return_codes.h index c4ac06a4..07490d96 100644 --- a/core/stse_return_codes.h +++ b/core/stse_return_codes.h @@ -1,7 +1,7 @@ /*! * ****************************************************************************** * \file stse_return_codes.h - * \brief STSE return code type definition + * \brief STSELib return code type definition * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -121,6 +121,8 @@ enum stse_ReturnCode_t { STSE_CERT_INVALID_CERTIFICATE, STSE_CERT_CA_NOT_MATCHING, STSE_CERT_UNSUPPORTED_FEATURE, + + __STSE_SIGNED = -1 // Used to make the type of this enum a signed integer, don't use. }; typedef enum stse_ReturnCode_t stse_ReturnCode_t; diff --git a/core/stse_session.c b/core/stse_session.c index b3ab029a..e89a0873 100644 --- a/core/stse_session.c +++ b/core/stse_session.c @@ -1,14 +1,29 @@ +/****************************************************************************** + * \file stse_session.c + * \brief STSELib api for session manager (source) + * \author STMicroelectronics - CS application team + * + ****************************************************************************** + * \attention + * + *

© COPYRIGHT 2022 STMicroelectronics

+ * + * This software is licensed under terms that can be found in the LICENSE file in + * the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include +#include + #include "core/stse_device.h" #include "core/stse_platform.h" #include "core/stse_return_codes.h" -/* Private variables ---------------------------------------------------------*/ - -//static uint8_t evaluation_host_mac_key[ ] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF }; /*!< STSAFE-A's Host cipher key */ -//static uint8_t evaluation_host_cipher_key[ ] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF }; /*!< STSAFE-A's Host Mac key */ - /* Public functions ----------------------------------------------------------*/ - void stse_session_erase_context(stse_session_t *pSession) { /* - Check stsafe handler initialization */ if (pSession == NULL) { diff --git a/core/stse_session.h b/core/stse_session.h index 869bd750..01ee6d4b 100644 --- a/core/stse_session.h +++ b/core/stse_session.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stse_session.h - * \brief STSE session manager (header) + * \brief STSELib api for session manager (header) * \author STMicroelectronics - SMD application team * ****************************************************************************** @@ -16,8 +16,8 @@ ****************************************************************************** */ -#ifndef STSE_SESSION_MANAGER_H -#define STSE_SESSION_MANAGER_H +#ifndef STSE_SESSION_H +#define STSE_SESSION_H #include "core/stse_device.h" #include "core/stse_frame.h" @@ -32,4 +32,4 @@ */ void stse_session_erase_context(stse_session_t *pSession); -#endif /* STSE_SESSION_MANAGER_H */ +#endif /* STSE_SESSION_H */ diff --git a/core/stse_util.h b/core/stse_util.h index 67b8a308..97490779 100644 --- a/core/stse_util.h +++ b/core/stse_util.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stse_util.h - * \brief Util Macros for STSAFE Middleware + * \brief STSELib api for util macros (header) * \author STMicroelectronics - CS application team * ****************************************************************************** diff --git a/doc/resources/Markdown/04_PORTING_GUIDE/PAL_files/stse_platform_generic.h.md b/doc/resources/Markdown/04_PORTING_GUIDE/PAL_files/stse_platform_generic.h.md index 40d2925c..1f19f6e2 100644 --- a/doc/resources/Markdown/04_PORTING_GUIDE/PAL_files/stse_platform_generic.h.md +++ b/doc/resources/Markdown/04_PORTING_GUIDE/PAL_files/stse_platform_generic.h.md @@ -21,9 +21,6 @@ The `stse_platform_generic.h` file provides generic platform definitions and inc ## Includes: - **stm32l4xx.h**: Includes the STM32L4xx header file. -- **stddef.h**: Includes the standard definitions header file. -- **string.h**: Includes the string manipulation functions header file. -- **stdio.h**: Includes the standard input/output functions header file. ## Implementation Example: diff --git a/doc/resources/dox_files/APIs/data_storage/stse_data_storage_get_partitioning_table.dox b/doc/resources/dox_files/APIs/data_storage/stse_data_storage_get_partitioning_table.dox index bcbe60b0..5aa0c91a 100644 --- a/doc/resources/dox_files/APIs/data_storage/stse_data_storage_get_partitioning_table.dox +++ b/doc/resources/dox_files/APIs/data_storage/stse_data_storage_get_partitioning_table.dox @@ -46,7 +46,8 @@ Following diagram illustrates the interactions performed between the Host and th stse_ret = stse_data_storage_get_partitioning_table( &stse_handler, total_zone_count, - data_partition_record_table + data_partition_record_table, + sizeof(data_partition_record_table) ); if(stse_ret != STSE_OK ) { diff --git a/doc/resources/dox_files/APIs/data_storage/stse_data_storage_get_total_partition_count.dox b/doc/resources/dox_files/APIs/data_storage/stse_data_storage_get_total_partition_count.dox index 749b555b..314b852e 100644 --- a/doc/resources/dox_files/APIs/data_storage/stse_data_storage_get_total_partition_count.dox +++ b/doc/resources/dox_files/APIs/data_storage/stse_data_storage_get_total_partition_count.dox @@ -48,7 +48,8 @@ Following diagram illustrates the interactions performed between the Host and th stse_ret = stse_data_storage_get_partitioning_table( &stse_handler, total_zone_count, - data_partition_record_table + data_partition_record_table, + sizeof(data_partition_record_table) ); if(stse_ret != STSE_OK ) { diff --git a/doc/resources/plantuml/plantuml.jar b/doc/resources/plantuml/plantuml.jar new file mode 100644 index 00000000..9b948830 Binary files /dev/null and b/doc/resources/plantuml/plantuml.jar differ diff --git a/services/stsafea/stsafea_aes.c b/services/stsafea/stsafea_aes.c index 8e1cb83d..6cb88a44 100644 --- a/services/stsafea/stsafea_aes.c +++ b/services/stsafea/stsafea_aes.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_aes.c - * \brief STSAFE Middleware services for symmetric key cryptography (source) + * \brief STSAFE-A services for symmetric key cryptography (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -15,6 +15,10 @@ * *****************************************************************************/ +/* Includes ------------------------------------------------------------------*/ +#include +#include + #include "services/stsafea/stsafea_aes.h" #include "services/stsafea/stsafea_frame_transfer.h" diff --git a/services/stsafea/stsafea_aes.h b/services/stsafea/stsafea_aes.h index 77a866c1..1ca94fe3 100644 --- a/services/stsafea/stsafea_aes.h +++ b/services/stsafea/stsafea_aes.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_aes.h - * \brief STSAFE Middleware services for symmetric key cryptography (header) + * \brief STSAFE-A services for symmetric key cryptography (header) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -43,7 +43,10 @@ * \details This service format and send encrypt command in AES ECB mode * \param[in] pSTSE Pointer to STSE Handler * \param[in] slot_number Key slot in symmetric key table to be used - * \param[in] message_length Length of the message + * \param[in] message_length Length of the message
+ * message_length maximum value (in bytes): + * - STSAFE-A110 : STSAFEA_MAX_FRAME_LENGTH_A110 - 5 + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 5 * \param[in] pPlaintext_message Plaintext message to encrypt * \param[out] pEncrypted_message Encrypted message * \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise @@ -60,7 +63,10 @@ stse_ReturnCode_t stsafea_aes_ecb_encrypt( * \details This service format and send decrypt command in AES ECB mode * \param[in] pSTSE Pointer to STSE Handler * \param[in] slot_number Key slot in symmetric key table to be used - * \param[in] message_length Length of the message + * \param[in] message_length Length of the message
+ * message_length maximum value (in bytes): + * - STSAFE-A110 : STSAFEA_MAX_FRAME_LENGTH_A110 - 5 + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 5 * \param[in] pEncrypted_message Encrypted message to decrypt * \param[out] pPlaintext_message Plaintext message * \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise @@ -81,7 +87,10 @@ stse_ReturnCode_t stsafea_aes_ecb_decrypt( * \param[in] pNonce Buffer containing the nonce * \param[in] associated_data_length Length of the associated data * \param[in] pAssociated_data Buffer containing associated data - * \param[in] message_length Length of the message to encrypt + * \param[in] message_length Length of the message to encrypt
+ * message_length maximum value (in bytes): + * - STSAFE-A110 : STSAFEA_MAX_FRAME_LENGTH_A110 - 22 - associated_data_length + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 22 - associated_data_length * \param[in] pPlaintext_message Buffer containing the message to encrypt * \param[out] pEncrypted_message Buffer to store the encrypted message * \param[out] pEncrypted_authentication_tag Buffer to store the authentication tag @@ -114,7 +123,9 @@ stse_ReturnCode_t stsafea_aes_ccm_encrypt( * \param[in] total_message_length Length of the complete message to be encrypted by chunks * \param[in] associated_data_chunk_length Length of the associated data chunk * \param[in] pAssociated_data_chunk Buffer containing associated data chunk - * \param[in] message_chunk_length Length of the message chunk to encrypt + * \param[in] message_chunk_length Length of the message chunk to encrypt
+ * message_chunk_length maximum value (in bytes): + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 17 - Nonce_length - associated_data_chunk_length * \param[in] pPlaintext_message_chunk Buffer containing 1st piece of plaintext message chunk to encrypt * \param[out] pEncrypted_message_chunk Buffer to store the encrypted message chunk * \param[out] pCounter_presence Counter presence flag @@ -142,7 +153,9 @@ stse_ReturnCode_t stsafea_aes_ccm_encrypt_start( * \param[in] pSTSE Pointer to STSE Handler * \param[in] associated_data_chunk_length Length of the associated data chunk * \param[in] pAssociated_data_chunk Buffer containing associated data chunk - * \param[in] message_chunk_length Length of the message chunk to encrypt + * \param[in] message_chunk_length Length of the message chunk to encrypt
+ * message_chunk_length maximum value (in bytes): + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 8 - associated_data_chunk_length * \param[in] pPlaintext_message_chunk Buffer containing the message chunk to encrypt * \param[out] pEncrypted_message_chunk Buffer to store the encrypted message chunk * \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise @@ -162,7 +175,9 @@ stse_ReturnCode_t stsafea_aes_ccm_encrypt_process( * \param[in] authentication_tag_length Length of the output authentication tag * \param[in] associated_data_chunk_length Length of the associated data chunk * \param[in] pAssociated_data_chunk Buffer containing associated data chunk - * \param[in] message_chunk_length Length of the message chunk to encrypt + * \param[in] message_chunk_length Length of the message chunk to encrypt
+ * message_chunk_length maximum value (in bytes): + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 8 - associated_data_chunk_length * \param[in] pPlaintext_message_chunk Buffer containing the message chunk to encrypt * \param[out] pEncrypted_message_chunk Buffer to store the encrypted message chunk * \param[out] pEncrypted_authentication_tag Encrypted authentication tag @@ -187,7 +202,10 @@ stse_ReturnCode_t stsafea_aes_ccm_encrypt_finish( * \param[in] pNonce Buffer containing the nonce * \param[in] associated_data_length Length of the associated data * \param[in] pAssociated_data Buffer containing associated data - * \param[in] message_length Length of the message to encrypt + * \param[in] message_length Length of the message to encrypt
+ * message_length maximum value (in bytes): + * - STSAFE-A110 : STSAFEA_MAX_FRAME_LENGTH_A110 - 22 - authentication_tag_length - associated_data_length + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 22 - authentication_tag_length - associated_data_length * \param[in] pEncrypted_message Buffer containing the message to decrypt * \param[in] pAuthentication_tag Buffer containing the authentication tag * \param[out] pVerification_result Verification result flag @@ -218,7 +236,9 @@ stse_ReturnCode_t stsafea_aes_ccm_decrypt( * \param[in] total_ciphertext_length Length of the complete ciphertext * \param[in] associated_data_chunk_length Length of the associated data chunk * \param[in] pAssociated_data_chunk Buffer containing associated data chunk - * \param[in] message_chunk_length Length of the message chunk to decrypt + * \param[in] message_chunk_length Length of the message chunk to decrypt
+ * message_chunk_length maximum value (in bytes): + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 17 - Nonce_length - associated_data_chunk_length * \param[in] pEncrypted_message_chunk Buffer containing the message chunk to decrypt * \param[out] pPlaintext_message_chunk Buffer to store the decrypted message chunk * \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise @@ -242,7 +262,9 @@ stse_ReturnCode_t stsafea_aes_ccm_decrypt_start( * \param[in] pSTSE Pointer to STSE Handler * \param[in] associated_data_chunk_length Length of the associated data chunk * \param[in] pAssociated_data_chunk Buffer containing associated data chunk - * \param[in] message_chunk_length Length of the message chunk to decrypt + * \param[in] message_chunk_length Length of the message chunk to decrypt
+ * message_chunk_length maximum value (in bytes): + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 8 - associated_data_chunk_length * \param[in] pEncrypted_message_chunk Buffer containing the message chunk to decrypt * \param[out] pPlaintext_message_chunk Buffer to store the decrypted message chunk * \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise @@ -262,7 +284,9 @@ stse_ReturnCode_t stsafea_aes_ccm_decrypt_process( * \param[in] authentication_tag_length Length of the output authentication tag * \param[in] associated_data_chunk_length Length of the associated data chunk * \param[in] pAssociated_data_chunk Buffer containing associated data chunk - * \param[in] message_chunk_length Length of the message chunk to decrypt + * \param[in] message_chunk_length Length of the message chunk to decrypt
+ * message_chunk_length maximum value (in bytes): + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 8 - authentication_tag_length - associated_data_chunk_length * \param[in] pEncrypted_message_chunk Buffer containing the message chunk to decrypt * \param[in] pAuthentication_tag Authentication tag * \param[out] pVerification_result Verification result flag @@ -290,7 +314,9 @@ stse_ReturnCode_t stsafea_aes_ccm_decrypt_finish( * \param[in] pIV IV buffer * \param[in] associated_data_length Length of the associated data * \param[in] pAssociated_data Buffer containing associated data - * \param[in] message_length Length of the message to encrypt + * \param[in] message_length Length of the message to encrypt
+ * message_length maximum value (in bytes): + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 11 - IV_length - associated_data_length * \param[in] pPlaintext_message Buffer containing the message to encrypt * \param[out] pEncrypted_message Buffer to store the encrypted message * \param[out] pAuthentication_tag Buffer to store the authentication tag @@ -318,7 +344,9 @@ stse_ReturnCode_t stsafea_aes_gcm_encrypt( * \param[in] pIV IV buffer * \param[in] associated_data_chunk_length Length of the associated data chunk * \param[in] pAssociated_data_chunk Buffer containing associated data chunk - * \param[in] message_chunk_length Length of the message chunk to encrypt + * \param[in] message_chunk_length Length of the message chunk to encrypt
+ * message_chunk_length maximum value (in bytes): + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 11 - IV_length - associated_data_chunk_length * \param[in] pPlaintext_message_chunk Buffer containing the message chunk to encrypt * \param[out] pEncrypted_message_chunk Buffer to store the encrypted message * \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise @@ -340,7 +368,9 @@ stse_ReturnCode_t stsafea_aes_gcm_encrypt_start( * \param[in] pSTSE Pointer to STSE Handler * \param[in] associated_data_chunk_length Length of the associated data chunk * \param[in] pAssociated_data_chunk Buffer containing associated data chunk - * \param[in] message_chunk_length Length of the message chunk to encrypt + * \param[in] message_chunk_length Length of the message chunk to encrypt
+ * message_chunk_length maximum value (in bytes): + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 8 - associated_data_chunk_length * \param[in] pPlaintext_message_chunk Buffer containing the message chunk to encrypt * \param[out] pEncrypted_message_chunk Buffer to store the encrypted message chunk * \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise @@ -360,7 +390,9 @@ stse_ReturnCode_t stsafea_aes_gcm_encrypt_process( * \param[in] authentication_tag_length Length of the output authentication tag * \param[in] associated_data_chunk_length Length of the associated data chunk * \param[in] pAssociated_data_chunk Buffer containing associated data chunk - * \param[in] message_chunk_length Length of the message chunk + * \param[in] message_chunk_length Length of the message chunk
+ * message_chunk_length maximum value (in bytes): + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 8 - associated_data_chunk_length * \param[in] pPlaintext_message_chunk Buffer containing the message chunk to encrypt * \param[out] pEncrypted_message_chunk Buffer to store the encrypted message chunk * \param[out] pAuthentication_tag Authentication tag @@ -386,7 +418,9 @@ stse_ReturnCode_t stsafea_aes_gcm_encrypt_finish( * \param[in] pIV IV buffer * \param[in] associated_data_length Length of the associated data * \param[in] pAssociated_data Buffer containing associated data - * \param[in] message_length Length of the message to decrypt + * \param[in] message_length Length of the message to decrypt
+ * message_length maximum value (in bytes): + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 11 - authentication_tag_length - IV_length - associated_data_length * \param[in] pEncrypted_message Buffer containing the message to decrypt * \param[in] pAuthentication_tag Buffer containing the authentication tag * \param[out] pVerification_result Verification result flag @@ -416,7 +450,9 @@ stse_ReturnCode_t stsafea_aes_gcm_decrypt( * \param[in] pIV IV buffer * \param[in] associated_data_chunk_length Length of the associated data chunk * \param[in] pAssociated_data_chunk Buffer containing associated data chunk - * \param[in] message_chunk_length Length of the message chunk to decrypt + * \param[in] message_chunk_length Length of the message chunk to decrypt
+ * message_chunk_length maximum value (in bytes): + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 11 - IV_length - associated_data_chunk_length * \param[in] pEncrypted_message_chunk Buffer containing the message chunk to decrypt * \param[out] pPlaintext_message_chunk Buffer to store the decrypted message chunk * \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise @@ -438,7 +474,9 @@ stse_ReturnCode_t stsafea_aes_gcm_decrypt_start( * \param[in] pSTSE Pointer to STSE Handler * \param[in] associated_data_chunk_length Length of the associated data chunk * \param[in] pAssociated_data_chunk Buffer containing associated data chunk - * \param[in] message_chunk_length Length of the message chunk to decrypt + * \param[in] message_chunk_length Length of the message chunk to decrypt
+ * message_chunk_length maximum value (in bytes): + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 8 - associated_data_chunk_length * \param[in] pEncrypted_message_chunk Buffer containing the message chunk to decrypt * \param[out] pPlaintext_message_chunk Buffer to store the decrypted message chunk * \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise @@ -458,7 +496,9 @@ stse_ReturnCode_t stsafea_aes_gcm_decrypt_process( * \param[in] authentication_tag_length Length of the output authentication tag * \param[in] associated_data_chunk_length Length of the associated data chunk * \param[in] pAssociated_data_chunk Buffer containing associated data chunk - * \param[in] message_chunk_length Length of the message chunk to decrypt + * \param[in] message_chunk_length Length of the message chunk to decrypt
+ * message_chunk_length maximum value (in bytes): + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 11 - authentication_tag_length - associated_data_chunk_length * \param[in] pEncrypted_message_chunk Buffer containing the message chunk to decrypt * \param[in] pAuthentication_tag Authentication tag * \param[out] pVerification_result Verification result flag diff --git a/services/stsafea/stsafea_asymmetric_key_slots.c b/services/stsafea/stsafea_asymmetric_key_slots.c index de98cfb8..b4540e1c 100644 --- a/services/stsafea/stsafea_asymmetric_key_slots.c +++ b/services/stsafea/stsafea_asymmetric_key_slots.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_asymmetric_key_slots.c - * \brief STSAFEA services for symmetric key slots management (source) + * \brief STSAFE-A services for asymmetric key slots management (source) * \author STMicroelectronics - SMD application team * ****************************************************************************** @@ -16,6 +16,8 @@ *****************************************************************************/ /* Includes ------------------------------------------------------------------*/ +#include +#include #include "services/stsafea/stsafea_asymmetric_key_slots.h" #include "services/stsafea/stsafea_frame_transfer.h" diff --git a/services/stsafea/stsafea_asymmetric_key_slots.h b/services/stsafea/stsafea_asymmetric_key_slots.h index f6a72d09..118c9723 100644 --- a/services/stsafea/stsafea_asymmetric_key_slots.h +++ b/services/stsafea/stsafea_asymmetric_key_slots.h @@ -1,6 +1,7 @@ -/****************************************************************************** - * \file stsafe_asymmetric_key_crypto_services.h - * \brief STSAFE-Axxx Middleware Asymmetric key cryptography services (header) +/* + ****************************************************************************** + * \file stsafea_asymmetric_key_slots.h + * \brief STSAFE-A services for asymmetric key slots management (header) * \author STMicroelectronics - SMD application team * ****************************************************************************** diff --git a/services/stsafea/stsafea_commands.c b/services/stsafea/stsafea_commands.c index f544af31..169b4521 100644 --- a/services/stsafea/stsafea_commands.c +++ b/services/stsafea/stsafea_commands.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_commands.c - * \brief Commands services for STSAFE-A + * \brief STSAFE-A command services (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -16,6 +16,9 @@ ****************************************************************************** */ +/* Includes ------------------------------------------------------------------*/ +#include + #include "services/stsafea/stsafea_commands.h" #include "services/stsafea/stsafea_frame_transfer.h" #include "services/stsafea/stsafea_put_query.h" diff --git a/services/stsafea/stsafea_commands.h b/services/stsafea/stsafea_commands.h index ecf29a6e..159ece32 100644 --- a/services/stsafea/stsafea_commands.h +++ b/services/stsafea/stsafea_commands.h @@ -1,7 +1,7 @@ /*! * ****************************************************************************** * \file stsafea_commands.h - * \brief STSAFE-A command typedefs and services + * \brief STSAFE-A command typedefs and services (header) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -57,7 +57,6 @@ #define STSAFEA_PROT_CMD_Msk 0x80U /*!< STSAFE Protected command mask */ #define STSAFEA_PROT_RSP_Msk 0x40U /*!< STSAFE Protected rsp mask */ -#define STSAFEA_PRODUCT_COUNT 4U #define STSAFEA_MAX_CMD_COUNT 29U #define STSAFEA_MAX_EXT_CMD_COUNT 29U diff --git a/services/stsafea/stsafea_data_partition.c b/services/stsafea/stsafea_data_partition.c index 90391b3f..c3ef91b7 100644 --- a/services/stsafea/stsafea_data_partition.c +++ b/services/stsafea/stsafea_data_partition.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_data_partition.c - * \brief Data partition services for STSAFE-A + * \brief STSAFE-A services for data partition (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -16,6 +16,9 @@ ****************************************************************************** */ +/* Includes ------------------------------------------------------------------*/ +#include + #include "services/stsafea/stsafea_data_partition.h" #include "services/stsafea/stsafea_frame_transfer.h" @@ -75,13 +78,13 @@ stse_ReturnCode_t stsafea_get_total_partition_count(stse_Handler_t *pSTSE, stse_ReturnCode_t stsafea_get_data_partitions_configuration(stse_Handler_t *pSTSE, PLAT_UI8 total_partitions_count, stsafea_data_partition_record_t *pRecord_table, - PLAT_UI16 record_table_length) { + PLAT_UI16 record_table_size) { stse_ReturnCode_t ret; volatile PLAT_UI8 partition_idx; PLAT_UI8 cmd_header = STSAFEA_CMD_QUERY; PLAT_UI8 tag = STSAFEA_SUBJECT_TAG_DATA_PARTITION_CONFIGURATION; PLAT_UI8 rsp_header; - PLAT_UI8 raw_data[record_table_length]; + PLAT_UI8 raw_data[record_table_size]; if (pSTSE == NULL) { return STSE_SERVICE_HANDLER_NOT_INITIALISED; @@ -95,7 +98,7 @@ stse_ReturnCode_t stsafea_get_data_partitions_configuration(stse_Handler_t *pSTS /*- Create Rsp frame and populate elements*/ stse_frame_allocate(RspFrame); stse_frame_element_allocate_push(&RspFrame, eRsp_header, 1, &rsp_header); - stse_frame_element_allocate_push(&RspFrame, eRaw, record_table_length, raw_data); + stse_frame_element_allocate_push(&RspFrame, eRaw, record_table_size, raw_data); /*- Perform Transfer*/ ret = stsafea_frame_raw_transfer(pSTSE, diff --git a/services/stsafea/stsafea_data_partition.h b/services/stsafea/stsafea_data_partition.h index e8d22271..9def4068 100644 --- a/services/stsafea/stsafea_data_partition.h +++ b/services/stsafea/stsafea_data_partition.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_data_partition.h - * \brief Data partition services for STSAFE-A + * \brief STSAFE-A services for data partition (header) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -113,13 +113,13 @@ stse_ReturnCode_t stsafea_get_total_partition_count(stse_Handler_t *pSTSE, * \param[in] pSTSE Pointer to target SE handler * \param[in] total_partitions_count Total partition count in bytes * \param[in,out] pRecord_table Pointer to applicative partition record table - * \param[in] record_table_length Applicative record table length + * \param[in] record_table_size Applicative record table (@p pRecord_table) size (in bytes) * \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise */ stse_ReturnCode_t stsafea_get_data_partitions_configuration(stse_Handler_t *pSTSE, PLAT_UI8 total_partitions_count, stsafea_data_partition_record_t *pRecord_table, - PLAT_UI16 record_table_length); + PLAT_UI16 record_table_size); /** * \brief Decrement counter zone @@ -130,7 +130,11 @@ stse_ReturnCode_t stsafea_get_data_partitions_configuration(stse_Handler_t *pSTS * \param[in] amount Amount to decrement * \param[in] offset Associated data offset * \param[in] data Pointer to associated data - * \param[in] data_length Length of associated data + * \param[in] data_length Length of associated data
+ * data_length maximum value (in bytes): + * - STSAFE-A100 : STSAFEA_MAX_FRAME_LENGTH_A100 - 11 + * - STSAFE-A110 : STSAFEA_MAX_FRAME_LENGTH_A110 - 11 + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 11 * \param[out] new_counter_value Pointer to store new counter value * \param[in] protection Command protection type * \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise @@ -195,7 +199,11 @@ stse_ReturnCode_t stsafea_read_data_zone(stse_Handler_t *pSTSE, * \param[in] option Update option * \param[in] offset Update offset * \param[in] data Pointer to data to write - * \param[in] data_length Length of data to write + * \param[in] data_length Length of data to write
+ * data_length maximum value (in bytes): + * - STSAFE-A100 : STSAFEA_MAX_FRAME_LENGTH_A100 - 7 + * - STSAFE-A110 : STSAFEA_MAX_FRAME_LENGTH_A110 - 7 + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 7 * \param[in] protection Command protection type * \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise */ diff --git a/services/stsafea/stsafea_derive_keys.c b/services/stsafea/stsafea_derive_keys.c index 2a6c42c4..246fd292 100644 --- a/services/stsafea/stsafea_derive_keys.c +++ b/services/stsafea/stsafea_derive_keys.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_derive_keys.c - * \brief STSAFE Middleware services for derive keys command (source) + * \brief STSAFE-A services for derive keys command (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -15,6 +15,9 @@ * *****************************************************************************/ +/* Includes ------------------------------------------------------------------*/ +#include + #include "services/stsafea/stsafea_derive_keys.h" #include "services/stsafea/stsafea_frame_transfer.h" diff --git a/services/stsafea/stsafea_derive_keys.h b/services/stsafea/stsafea_derive_keys.h index 516a9c3a..72b8ff61 100644 --- a/services/stsafea/stsafea_derive_keys.h +++ b/services/stsafea/stsafea_derive_keys.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_derive_keys.h - * \brief STSAFE Middleware services for derive keys command (header) + * \brief STSAFE-A services for derive keys command (header) * \author STMicroelectronics - CS application team * ****************************************************************************** diff --git a/services/stsafea/stsafea_ecc.c b/services/stsafea/stsafea_ecc.c index b961dbe8..b9e5fd13 100644 --- a/services/stsafea/stsafea_ecc.c +++ b/services/stsafea/stsafea_ecc.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_ecc.c - * \brief ECC services for STSAFE-A + * \brief STSAFE-A services for ECC (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -16,6 +16,9 @@ ****************************************************************************** */ +/* Includes ------------------------------------------------------------------*/ +#include + #include "services/stsafea/stsafea_ecc.h" #include "services/stsafea/stsafea_frame_transfer.h" @@ -229,9 +232,9 @@ stse_ReturnCode_t stsafea_stop_volatile_KEK_session( stse_ReturnCode_t stsafea_ecc_verify_signature( stse_Handler_t *pSTSE, stse_ecc_key_type_t key_type, - PLAT_UI8 *pPublic_key, - PLAT_UI8 *pSignature, - PLAT_UI8 *pMessage, + const PLAT_UI8 *pPublic_key, + const PLAT_UI8 *pSignature, + const PLAT_UI8 *pMessage, PLAT_UI16 message_length, PLAT_UI8 eddsa_variant, PLAT_UI8 *pSignature_validity) { @@ -288,7 +291,7 @@ stse_ReturnCode_t stsafea_ecc_verify_signature( if (key_type == STSE_ECC_KT_ED25519) { stse_frame_push_element(&CmdFrame, &ePublic_key_length_first_element); ePublic_key_first_element.length = stse_ecc_info_table[key_type].coordinate_or_key_size; - ePublic_key_first_element.pData = pPublic_key; + ePublic_key_first_element.pData = (PLAT_UI8 *)pPublic_key; stse_frame_push_element(&CmdFrame, &ePublic_key_first_element); } else #endif @@ -298,20 +301,20 @@ stse_ReturnCode_t stsafea_ecc_verify_signature( stse_frame_push_element(&CmdFrame, &ePublic_key_length_first_element); ePublic_key_first_element.length = stse_ecc_info_table[key_type].coordinate_or_key_size; - ePublic_key_first_element.pData = pPublic_key; + ePublic_key_first_element.pData = (PLAT_UI8 *)pPublic_key; stse_frame_push_element(&CmdFrame, &ePublic_key_first_element); stse_frame_push_element(&CmdFrame, &ePublic_key_length_second_element); ePublic_key_second_element.length = stse_ecc_info_table[key_type].coordinate_or_key_size; - ePublic_key_second_element.pData = pPublic_key + ePublic_key_first_element.length; + ePublic_key_second_element.pData = (PLAT_UI8 *)pPublic_key + ePublic_key_first_element.length; stse_frame_push_element(&CmdFrame, &ePublic_key_second_element); } stse_frame_element_allocate_push(&CmdFrame, eSignature_R_length, STSE_ECC_GENERIC_LENGTH_SIZE, pSignature_length_element); - stse_frame_element_allocate_push(&CmdFrame, eSignature_R, (stse_ecc_info_table[key_type].signature_size >> 1), pSignature); + stse_frame_element_allocate_push(&CmdFrame, eSignature_R, (stse_ecc_info_table[key_type].signature_size >> 1), (PLAT_UI8 *)pSignature); stse_frame_element_allocate_push(&CmdFrame, eSignature_S_length, STSE_ECC_GENERIC_LENGTH_SIZE, pSignature_length_element); - stse_frame_element_allocate_push(&CmdFrame, eSignature_S, (stse_ecc_info_table[key_type].signature_size >> 1), pSignature + (stse_ecc_info_table[key_type].signature_size >> 1)); + stse_frame_element_allocate_push(&CmdFrame, eSignature_S, (stse_ecc_info_table[key_type].signature_size >> 1), (PLAT_UI8 *)pSignature + (stse_ecc_info_table[key_type].signature_size >> 1)); #ifdef STSE_CONF_ECC_EDWARD_25519 if (key_type == STSE_ECC_KT_ED25519) { @@ -320,7 +323,7 @@ stse_ReturnCode_t stsafea_ecc_verify_signature( #endif stse_frame_element_allocate_push(&CmdFrame, eMessage_length, STSAFEA_GENERIC_LENGTH_SIZE, (PLAT_UI8 *)&message_length); - stse_frame_element_allocate_push(&CmdFrame, eMessage, message_length, pMessage); + stse_frame_element_allocate_push(&CmdFrame, eMessage, message_length, (PLAT_UI8 *)pMessage); stse_frame_element_swap_byte_order(&eMessage_length); stse_frame_allocate(RspFrame); diff --git a/services/stsafea/stsafea_ecc.h b/services/stsafea/stsafea_ecc.h index 12d88817..26471961 100644 --- a/services/stsafea/stsafea_ecc.h +++ b/services/stsafea/stsafea_ecc.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** - * \file stsafea_data_partition.h - * \brief Data partition services for STSAFE-A + * \file stsafea_ecc.h + * \brief STSAFE-A services for ECC (header) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -101,9 +101,9 @@ stse_ReturnCode_t stsafea_stop_volatile_KEK_session( stse_ReturnCode_t stsafea_ecc_verify_signature( stse_Handler_t *pSTSE, stse_ecc_key_type_t key_type, - PLAT_UI8 *pPublic_key, - PLAT_UI8 *pSignature, - PLAT_UI8 *pMessage, + const PLAT_UI8 *pPublic_key, + const PLAT_UI8 *pSignature, + const PLAT_UI8 *pMessage, PLAT_UI16 message_length, PLAT_UI8 eddsa_variant, PLAT_UI8 *pSignature_validity); diff --git a/services/stsafea/stsafea_echo.c b/services/stsafea/stsafea_echo.c index 9ccf114b..856dcd94 100644 --- a/services/stsafea/stsafea_echo.c +++ b/services/stsafea/stsafea_echo.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_echo.c - * \brief Echo services for STSAFE-A + * \brief STSAFE-A services for echo (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -16,6 +16,9 @@ ****************************************************************************** */ +/* Includes ------------------------------------------------------------------*/ +#include + #include "services/stsafea/stsafea_echo.h" #include "services/stsafea/stsafea_frame_transfer.h" diff --git a/services/stsafea/stsafea_echo.h b/services/stsafea/stsafea_echo.h index e65a0fec..a68efc88 100644 --- a/services/stsafea/stsafea_echo.h +++ b/services/stsafea/stsafea_echo.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_echo.h - * \brief Echo services for STSAFE-A + * \brief STSAFE-A services for echo (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -38,7 +38,11 @@ * \param[in] pSTSE Pointer to STSE Handler * \param[in] message Message buffer to send the echo command * \param[in] echoed_message Message buffer to receive the echo response - * \param[in] message_size Size of the echo message + * \param[in] message_size Size of the echo message
+ * message_size maximum value (in bytes): + * - STSAFE-A100 : STSAFEA_MAX_FRAME_LENGTH_A100 - 2 + * - STSAFE-A110 : STSAFEA_MAX_FRAME_LENGTH_A110 - 2 + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 2 * \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise */ stse_ReturnCode_t stsafea_echo( diff --git a/services/stsafea/stsafea_entity_auth.c b/services/stsafea/stsafea_entity_auth.c index b292adda..c6df1cbf 100644 --- a/services/stsafea/stsafea_entity_auth.c +++ b/services/stsafea/stsafea_entity_auth.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_entity_auth.c - * \brief Entity authentication services for STSAFE-A (source) + * \brief STSAFE-A services for entity authentication (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -16,6 +16,9 @@ ****************************************************************************** */ +/* Includes ------------------------------------------------------------------*/ +#include + #include "services/stsafea/stsafea_entity_auth.h" #include "services/stsafea/stsafea_frame_transfer.h" diff --git a/services/stsafea/stsafea_entity_auth.h b/services/stsafea/stsafea_entity_auth.h index af531b9d..21dfea66 100644 --- a/services/stsafea/stsafea_entity_auth.h +++ b/services/stsafea/stsafea_entity_auth.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_entity_auth.c - * \brief Entity authentication services for STSAFE-A (header) + * \brief STSAFE-A services for entity authentication (header) * \author STMicroelectronics - CS application team * ****************************************************************************** diff --git a/services/stsafea/stsafea_frame_transfer.c b/services/stsafea/stsafea_frame_transfer.c index 61135901..1e1ff856 100644 --- a/services/stsafea/stsafea_frame_transfer.c +++ b/services/stsafea/stsafea_frame_transfer.c @@ -1,7 +1,7 @@ /*! * ****************************************************************************** * \file stsafea_frame_transfer.c - * \brief STSAFE-A Frame transfer service (sources) + * \brief STSAFE-A services for frame transfer (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -16,8 +16,12 @@ ****************************************************************************** */ -#include "services/stsafea/stsafea_frame_transfer.h" +/* Includes ------------------------------------------------------------------*/ +#include +#include + #include "services/stsafea/stsafea_commands.h" +#include "services/stsafea/stsafea_frame_transfer.h" #include "services/stsafea/stsafea_sessions.h" #include "services/stsafea/stsafea_timings.h" @@ -26,9 +30,7 @@ const PLAT_UI16 stsafea_maximum_frame_length[STSAFEA_PRODUCT_COUNT] = { STSAFEA_MAX_FRAME_LENGTH_A100, STSAFEA_MAX_FRAME_LENGTH_A110, - STSAFEA_MAX_FRAME_LENGTH_A120, - STSAFEA_MAX_FRAME_LENGTH_A200, -}; + STSAFEA_MAX_FRAME_LENGTH_A120}; stse_ReturnCode_t stsafea_frame_transmit(stse_Handler_t *pSTSE, stse_frame_t *pFrame) { stse_ReturnCode_t ret = STSE_PLATFORM_BUS_ACK_ERROR; @@ -130,15 +132,15 @@ stse_ReturnCode_t stsafea_frame_receive(stse_Handler_t *pSTSE, stse_frame_t *pFr return (STSE_SERVICE_INVALID_PARAMETER); } - /* ======================================================= */ - /* ============== Get the total frame length ============= */ + /* ================================================================================= */ + /* ============== Get the total frame length + 2 bytes (potential CRC) ============= */ while ((retry_count != 0) && (ret == STSE_PLATFORM_BUS_ACK_ERROR)) { /* - Receive frame length from target STSAFE */ ret = pSTSE->io.BusRecvStart( pSTSE->io.busID, pSTSE->io.Devaddr, pSTSE->io.BusSpeed, - STSE_FRAME_LENGTH_SIZE + STSE_RSP_FRAME_HEADER_SIZE); + STSE_FRAME_LENGTH_SIZE + STSE_RSP_FRAME_HEADER_SIZE + STSE_FRAME_CRC_SIZE); if (ret != STSE_OK) { retry_count--; @@ -160,7 +162,7 @@ stse_ReturnCode_t stsafea_frame_receive(stse_Handler_t *pSTSE, stse_frame_t *pFr STSE_RSP_FRAME_HEADER_SIZE); /* - Get STSAFE Response Length */ - ret = pSTSE->io.BusRecvStop( + ret = pSTSE->io.BusRecvContinue( pSTSE->io.busID, pSTSE->io.Devaddr, pSTSE->io.BusSpeed, @@ -170,6 +172,17 @@ stse_ReturnCode_t stsafea_frame_receive(stse_Handler_t *pSTSE, stse_frame_t *pFr return ret; } + /* - Get STSAFE Response Potential CRC */ + ret = pSTSE->io.BusRecvStop( + pSTSE->io.busID, + pSTSE->io.Devaddr, + pSTSE->io.BusSpeed, + received_crc, + STSE_FRAME_CRC_SIZE); + if (ret != STSE_OK) { + return ret; + } + /* - Store response Length */ received_length = ((length_value[0] << 8) + length_value[1]) - STSE_FRAME_CRC_SIZE + STSE_RSP_FRAME_HEADER_SIZE; @@ -184,101 +197,136 @@ stse_ReturnCode_t stsafea_frame_receive(stse_Handler_t *pSTSE, stse_frame_t *pFr } } - /* ======================================================= */ - /* ====== Format the frame to handle CRC and filler ====== */ + if (received_length == 1) { + /* ====================================================== */ + /* ====== compute CRC for response without payload ====== */ - /* - Compare STSAFE Received frame length with local RSP Frame length */ - if (received_length > pFrame->length) { - /* Calculate needed filler to match both length */ - filler_size = received_length - pFrame->length; - } - if (received_length < pFrame->length) { - pFrame->length = received_length; - } + computed_crc = stse_platform_Crc16_Calculate(&received_header, STSE_RSP_FRAME_HEADER_SIZE); - /* Append filler frame element even if its length equal 0 */ - PLAT_UI8 filler[filler_size]; - stse_frame_element_allocate(eFiller, - filler_size, - filler); - if (filler_size > 0) { - stse_frame_push_element(pFrame, - &eFiller); - } +#ifdef STSE_FRAME_DEBUG_LOG + printf("\n\r STSAFE Frame < (%d-byte) : { 0x%02X } { 0x%02X 0x%02X }\n\r", + received_length + STSE_FRAME_CRC_SIZE, + received_header, + received_crc[0], + received_crc[1]); +#endif /* STSE_FRAME_DEBUG_LOG */ - /* ======================================================= */ - /* ========= Receive the frame in frame elements ========= */ + /* - Verify CRC */ + if (computed_crc != ((received_crc[0] << 8) + received_crc[1])) { + return (STSE_SERVICE_FRAME_CRC_ERROR); + } - ret = STSE_PLATFORM_BUS_ACK_ERROR; - while ((retry_count != 0) && (ret == STSE_PLATFORM_BUS_ACK_ERROR)) { - /* - Receive frame length from target STSAFE */ - ret = pSTSE->io.BusRecvStart( - pSTSE->io.busID, - pSTSE->io.Devaddr, - pSTSE->io.BusSpeed, - STSE_FRAME_LENGTH_SIZE + received_length + STSE_FRAME_CRC_SIZE); + ret = (stse_ReturnCode_t)(received_header & STSE_STSAFEA_RSP_STATUS_MASK); + } else { + /* ======================================================= */ + /* ====== Format the frame to handle CRC and filler ====== */ - if (ret != STSE_OK) { - retry_count--; - stse_platform_Delay_ms(STSE_POLLING_RETRY_INTERVAL); + /* - Compare STSAFE Received frame length with local RSP Frame length */ + if (received_length > pFrame->length) { + /* Calculate needed filler to match both length */ + filler_size = received_length - pFrame->length; + } + if (received_length < pFrame->length) { + pFrame->length = received_length; } - } - /* - Verify correct reception*/ - if (ret != STSE_OK) { - return ret; - } + /* Append filler frame element even if its length equal 0 */ + PLAT_UI8 filler[filler_size]; + stse_frame_element_allocate(eFiller, + filler_size, + filler); + if (filler_size > 0) { + stse_frame_push_element(pFrame, + &eFiller); + } - /* Receive response header */ - ret = pSTSE->io.BusRecvContinue( - pSTSE->io.busID, - pSTSE->io.Devaddr, - pSTSE->io.BusSpeed, - pFrame->first_element->pData, - STSE_RSP_FRAME_HEADER_SIZE); + /* ======================================================= */ + /* ========= Receive the frame in frame elements ========= */ + + ret = STSE_PLATFORM_BUS_ACK_ERROR; + while ((retry_count != 0) && (ret == STSE_PLATFORM_BUS_ACK_ERROR)) { + /* - Receive frame length from target STSAFE */ + ret = pSTSE->io.BusRecvStart( + pSTSE->io.busID, + pSTSE->io.Devaddr, + pSTSE->io.BusSpeed, + STSE_FRAME_LENGTH_SIZE + received_length + STSE_FRAME_CRC_SIZE); + + if (ret != STSE_OK) { + retry_count--; + stse_platform_Delay_ms(STSE_POLLING_RETRY_INTERVAL); + } + } - if (ret != STSE_OK) { - return ret; - } + /* - Verify correct reception*/ + if (ret != STSE_OK) { + return ret; + } - /* Substract response header already read in STSAFE-A */ - received_length -= STSE_RSP_FRAME_HEADER_SIZE; + /* Receive response header */ + ret = pSTSE->io.BusRecvContinue( + pSTSE->io.busID, + pSTSE->io.Devaddr, + pSTSE->io.BusSpeed, + pFrame->first_element->pData, + STSE_RSP_FRAME_HEADER_SIZE); - /* Receive and discard length (already stored) */ - ret = pSTSE->io.BusRecvContinue( - pSTSE->io.busID, - pSTSE->io.Devaddr, - pSTSE->io.BusSpeed, - NULL, - STSE_FRAME_LENGTH_SIZE); - if (ret != STSE_OK) { - return ret; - } + if (ret != STSE_OK) { + return ret; + } - /* - Append CRC element to the RSP Frame (valid only in Receive Scope) */ - stse_frame_element_allocate_push(pFrame, eCRC, STSE_FRAME_CRC_SIZE, received_crc); + /* Substract response header already read in STSAFE-A */ + received_length -= STSE_RSP_FRAME_HEADER_SIZE; - /* If first element is longer than just the header */ - if (pFrame->first_element->length > STSE_RSP_FRAME_HEADER_SIZE) { - /* Receive missing bytes after discarding the 2 bytes length */ + /* Receive and discard length (already stored) */ ret = pSTSE->io.BusRecvContinue( pSTSE->io.busID, pSTSE->io.Devaddr, pSTSE->io.BusSpeed, - pFrame->first_element->pData + STSE_RSP_FRAME_HEADER_SIZE, - pFrame->first_element->length - STSE_RSP_FRAME_HEADER_SIZE); + NULL, + STSE_FRAME_LENGTH_SIZE); if (ret != STSE_OK) { return ret; } - } - /* - Perform frame element reception and populate local RSP Frame */ - pCurrent_element = pFrame->first_element->next; - while (pCurrent_element != pFrame->last_element) { - if (received_length < pCurrent_element->length) { - pCurrent_element->length = received_length; + /* - Append CRC element to the RSP Frame (valid only in Receive Scope) */ + stse_frame_element_allocate_push(pFrame, eCRC, STSE_FRAME_CRC_SIZE, received_crc); + + /* If first element is longer than just the header */ + if (pFrame->first_element->length > STSE_RSP_FRAME_HEADER_SIZE) { + /* Receive missing bytes after discarding the 2 bytes length */ + ret = pSTSE->io.BusRecvContinue( + pSTSE->io.busID, + pSTSE->io.Devaddr, + pSTSE->io.BusSpeed, + pFrame->first_element->pData + STSE_RSP_FRAME_HEADER_SIZE, + pFrame->first_element->length - STSE_RSP_FRAME_HEADER_SIZE); + if (ret != STSE_OK) { + return ret; + } } - ret = pSTSE->io.BusRecvContinue( + + /* - Perform frame element reception and populate local RSP Frame */ + pCurrent_element = pFrame->first_element->next; + while (pCurrent_element != pFrame->last_element) { + if (received_length < pCurrent_element->length) { + pCurrent_element->length = received_length; + } + ret = pSTSE->io.BusRecvContinue( + pSTSE->io.busID, + pSTSE->io.Devaddr, + pSTSE->io.BusSpeed, + pCurrent_element->pData, + pCurrent_element->length); + if (ret != STSE_OK) { + return ret; + } + + received_length -= pCurrent_element->length; + pCurrent_element = pCurrent_element->next; + } + + ret = pSTSE->io.BusRecvStop( pSTSE->io.busID, pSTSE->io.Devaddr, pSTSE->io.BusSpeed, @@ -288,48 +336,36 @@ stse_ReturnCode_t stsafea_frame_receive(stse_Handler_t *pSTSE, stse_frame_t *pFr return ret; } - received_length -= pCurrent_element->length; - pCurrent_element = pCurrent_element->next; - } - ret = pSTSE->io.BusRecvStop( - pSTSE->io.busID, - pSTSE->io.Devaddr, - pSTSE->io.BusSpeed, - pCurrent_element->pData, - pCurrent_element->length); - if (ret != STSE_OK) { - return ret; - } - #ifdef STSE_FRAME_DEBUG_LOG - printf("\n\r STSAFE Frame < "); - stse_frame_debug_print(pFrame); - printf("\n\r"); + printf("\n\r STSAFE Frame < "); + stse_frame_debug_print(pFrame); + printf("\n\r"); #endif /* STSE_FRAME_DEBUG_LOG */ - /* - Swap CRC */ - stse_frame_element_swap_byte_order(&eCRC); + /* - Swap CRC */ + stse_frame_element_swap_byte_order(&eCRC); - /* - Pop CRC element from Frame*/ - stse_frame_pop_element(pFrame); + /* - Pop CRC element from Frame*/ + stse_frame_pop_element(pFrame); - /* - Compute CRC */ - ret = stse_frame_crc16_compute(pFrame, &computed_crc); - if (ret != STSE_OK) { - return ret; - } + /* - Compute CRC */ + ret = stse_frame_crc16_compute(pFrame, &computed_crc); + if (ret != STSE_OK) { + return ret; + } - /* - Pop Filler element from Frame*/ - if (filler_size > 0) { - stse_frame_pop_element(pFrame); - } + /* - Pop Filler element from Frame*/ + if (filler_size > 0) { + stse_frame_pop_element(pFrame); + } - /* - Verify CRC */ - if (computed_crc != *(PLAT_UI16 *)received_crc) { - return (STSE_SERVICE_FRAME_CRC_ERROR); - } + /* - Verify CRC */ + if (computed_crc != *(PLAT_UI16 *)received_crc) { + return (STSE_SERVICE_FRAME_CRC_ERROR); + } - ret = (stse_ReturnCode_t)(pFrame->first_element->pData[0] & STSE_STSAFEA_RSP_STATUS_MASK); + ret = (stse_ReturnCode_t)(pFrame->first_element->pData[0] & STSE_STSAFEA_RSP_STATUS_MASK); + } return ret; } diff --git a/services/stsafea/stsafea_frame_transfer.h b/services/stsafea/stsafea_frame_transfer.h index 732f8dbf..bbf3d886 100644 --- a/services/stsafea/stsafea_frame_transfer.h +++ b/services/stsafea/stsafea_frame_transfer.h @@ -1,7 +1,7 @@ /*! * ****************************************************************************** * \file stsafea_frame_transfer.h - * \brief STSAFE-A Frame transfer service (header) + * \brief STSAFE-A services for frame transfer (header) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -29,7 +29,7 @@ #include "core/stse_return_codes.h" #include "core/stse_util.h" -#define STSAFEA_PRODUCT_COUNT 4U +#define STSAFEA_PRODUCT_COUNT 3U extern const PLAT_UI16 stsafea_maximum_frame_length[STSAFEA_PRODUCT_COUNT]; diff --git a/services/stsafea/stsafea_hash.c b/services/stsafea/stsafea_hash.c index d445d2de..b61c4b6b 100644 --- a/services/stsafea/stsafea_hash.c +++ b/services/stsafea/stsafea_hash.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_hash.c - * \brief Hash services for STSAFE-A + * \brief STSAFE-A services for hash (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -16,8 +16,11 @@ ****************************************************************************** */ -#include "services/stsafea/stsafea_hash.h" +/* Includes ------------------------------------------------------------------*/ +#include + #include "services/stsafea/stsafea_frame_transfer.h" +#include "services/stsafea/stsafea_hash.h" #ifdef STSE_CONF_STSAFE_A_SUPPORT @@ -88,7 +91,6 @@ stse_ReturnCode_t stsafea_start_hash( PLAT_UI16 message_size) { PLAT_UI8 cmd_header[STSAFEA_EXT_HEADER_SIZE] = {STSAFEA_EXTENDED_COMMAND_PREFIX, STSAFEA_EXTENDED_CMD_START_HASH}; PLAT_UI8 rsp_header; - PLAT_UI16 hash_algo_id_length = STSAFEA_HASH_ALGO_ID_SIZE; if (pSTSE == NULL) { return (STSE_SERVICE_HANDLER_NOT_INITIALISED); @@ -101,7 +103,7 @@ stse_ReturnCode_t stsafea_start_hash( /*- Create CMD frame and populate elements */ stse_frame_allocate(CmdFrame); stse_frame_element_allocate_push(&CmdFrame, eCmd_header, STSAFEA_EXT_HEADER_SIZE, cmd_header); - stse_frame_element_allocate_push(&CmdFrame, eHashAlgo, hash_algo_id_length, (PLAT_UI8 *)&stsafea_hash_info_table[sha_algorithm].id); + stse_frame_element_allocate_push(&CmdFrame, eHashAlgo, STSAFEA_HASH_ALGO_ID_SIZE, (PLAT_UI8 *)&stsafea_hash_info_table[sha_algorithm].id); stse_frame_element_allocate_push(&CmdFrame, eMessage, message_size, pMessage); /*- Create Rsp frame and populate elements*/ diff --git a/services/stsafea/stsafea_hash.h b/services/stsafea/stsafea_hash.h index 586920cd..bff5f09e 100644 --- a/services/stsafea/stsafea_hash.h +++ b/services/stsafea/stsafea_hash.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_hash.h - * \brief Hash services for STSAFE-A + * \brief STSAFE-A services for hash (header) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -111,7 +111,9 @@ extern const stsafea_hash_info_t stsafea_hash_info_table[]; * \param[in] pSTSE Pointer to target SE handler * \param[in] sha_algorithm \ref stse_hash_algorithm_t SHA algorithm * \param[in] pMessage Pointer to message buffer - * \param[in] message_size Input message length in bytes + * \param[in] message_size Input message length in bytes
+ * message_size maximum value (in bytes): + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 15 * \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise */ stse_ReturnCode_t stsafea_start_hash(stse_Handler_t *pSTSE, @@ -124,7 +126,9 @@ stse_ReturnCode_t stsafea_start_hash(stse_Handler_t *pSTSE, * \details This service format and send/receive STSAFE-Axxx process hash command/response * \param[in] pSTSE Pointer to target SE handler * \param[in] pMessage Pointer to message buffer - * \param[in] message_size Input message length in bytes + * \param[in] message_size Input message length in bytes
+ * message_size maximum value (in bytes): + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 4 * \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise */ stse_ReturnCode_t stsafea_process_hash( @@ -138,7 +142,9 @@ stse_ReturnCode_t stsafea_process_hash( * \param[in] pSTSE Pointer to target SE handler * \param[in] sha_algorithm \ref stse_hash_algorithm_t SHA algorithm * \param[in] pMessage Pointer to message buffer - * \param[in] message_size Input message length in bytes + * \param[in] message_size Input message length in bytes
+ * message_size maximum value (in bytes): + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 4 * \param[out] pDigest Pointer to digest buffer * \param[out] pDigest_size Digest buffer length in bytes * \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise diff --git a/services/stsafea/stsafea_host_key_slot.c b/services/stsafea/stsafea_host_key_slot.c index 0c4e3ea4..3ca0f766 100644 --- a/services/stsafea/stsafea_host_key_slot.c +++ b/services/stsafea/stsafea_host_key_slot.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_host_key_slot.c - * \brief STSAFEA host key slot management services (source) + * \brief STSAFE-A services for host key slot management (source) * \author STMicroelectronics - SMD application team * ****************************************************************************** @@ -16,10 +16,11 @@ *****************************************************************************/ /* Includes ------------------------------------------------------------------*/ +#include -#include "services/stsafea/stsafea_host_key_slot.h" #include "services/stsafea/stsafea_frame_transfer.h" #include "services/stsafea/stsafea_hash.h" +#include "services/stsafea/stsafea_host_key_slot.h" #ifdef STSE_CONF_STSAFE_A_SUPPORT diff --git a/services/stsafea/stsafea_host_key_slot.h b/services/stsafea/stsafea_host_key_slot.h index e2dab020..6a05a2a1 100644 --- a/services/stsafea/stsafea_host_key_slot.h +++ b/services/stsafea/stsafea_host_key_slot.h @@ -1,6 +1,6 @@ /****************************************************************************** * \file stsafe_symmetric_key_crypto_services.h - * \brief STSAFE Middleware services for symmetric key cryptography (header) + * \brief STSAFE-A services for host key slot management (header) * \author STMicroelectronics - SMD application team * ****************************************************************************** diff --git a/services/stsafea/stsafea_low_power.c b/services/stsafea/stsafea_low_power.c index f31f7975..9832cdf5 100644 --- a/services/stsafea/stsafea_low_power.c +++ b/services/stsafea/stsafea_low_power.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_low_power.c - * \brief low-power modes services for STSAFE-A + * \brief STSAFE-A services for low-power modes services (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -16,8 +16,11 @@ ****************************************************************************** */ -#include "services/stsafea/stsafea_low_power.h" +/* Includes ------------------------------------------------------------------*/ +#include + #include "services/stsafea/stsafea_frame_transfer.h" +#include "services/stsafea/stsafea_low_power.h" #ifdef STSE_CONF_STSAFE_A_SUPPORT @@ -25,7 +28,6 @@ stse_ReturnCode_t stsafea_hibernate(stse_Handler_t *pSTSE, stse_hibernate_wake_up_mode_t wake_up_mode) { - (void)wake_up_mode; PLAT_UI8 cmd_header = STSAFEA_CMD_HIBERNATE; PLAT_UI8 rsp_header; @@ -36,6 +38,7 @@ stse_ReturnCode_t stsafea_hibernate(stse_Handler_t *pSTSE, /*- Create CMD frame and populate elements */ stse_frame_allocate(CmdFrame); stse_frame_element_allocate_push(&CmdFrame, eCmd_header, 1, &cmd_header); + stse_frame_element_allocate_push(&CmdFrame, e_wake_up_mode, 1, &wake_up_mode); /*- Create Rsp frame and populate elements*/ stse_frame_allocate(RspFrame); diff --git a/services/stsafea/stsafea_low_power.h b/services/stsafea/stsafea_low_power.h index 30951f0c..302405c8 100644 --- a/services/stsafea/stsafea_low_power.h +++ b/services/stsafea/stsafea_low_power.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_low_power.h - * \brief low-power modes services for STSAFE-A + * \brief STSAFE-A services for low-power modes services (header) * \author STMicroelectronics - CS application team * ****************************************************************************** diff --git a/services/stsafea/stsafea_mac.c b/services/stsafea/stsafea_mac.c index 567e6996..b80d3417 100644 --- a/services/stsafea/stsafea_mac.c +++ b/services/stsafea/stsafea_mac.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_mac.c - * \brief STSAFE Middleware services for Message Authentication Code - MAC (source) + * \brief STSAFE-A services for message Authentication Code - MAC (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -15,8 +15,11 @@ * *****************************************************************************/ -#include "services/stsafea/stsafea_mac.h" +/* Includes ------------------------------------------------------------------*/ +#include + #include "services/stsafea/stsafea_frame_transfer.h" +#include "services/stsafea/stsafea_mac.h" #ifdef STSE_CONF_STSAFE_A_SUPPORT diff --git a/services/stsafea/stsafea_mac.h b/services/stsafea/stsafea_mac.h index 4c354c9a..9cd653e2 100644 --- a/services/stsafea/stsafea_mac.h +++ b/services/stsafea/stsafea_mac.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_mac.h - * \brief STSAFE Middleware services for Message Authentication Code - MAC (header) + * \brief STSAFE-A services for message Authentication Code - MAC (header) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -42,7 +42,10 @@ * \param[in] pSTSE Pointer to STSE Handler * \param[in] slot_number Key slot in symmetric key table to be used * \param[in] pMessage Plaintext message - * \param[in] message_length Plaintext message length + * \param[in] message_length Plaintext message length
+ * message_length maximum value (in bytes): + * - STSAFE-A110 : STSAFEA_MAX_FRAME_LENGTH_A110 - 6 + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 6 * \param[out] pMac Buffer to store the MAC * \param[out] mac_length MAC length (CMAC:2,4,8,16 / HMAC:16-32) * \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise @@ -63,7 +66,10 @@ stse_ReturnCode_t stsafea_cmac_hmac_compute( * \param[in] pMac Buffer containing the MAC * \param[in] mac_length MAC length (CMAC:2,4,8,16 / HMAC:16-32) * \param[in] pMessage Plaintext message - * \param[in] message_length Plaintext message length + * \param[in] message_length Plaintext message length
+ * message_length maximum value (in bytes): + * - STSAFE-A110 : STSAFEA_MAX_FRAME_LENGTH_A110 - 6 - mac_length + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 6 - mac_length * \param[out] verification_result Verification result flag * \return \ref STSE_OK on success ; \ref stse_ReturnCode_t error code otherwise */ @@ -83,7 +89,9 @@ stse_ReturnCode_t stsafea_cmac_hmac_verify( * \param[in] slot_number Key slot in symmetric key table to be used * \param[in] IV_length IV buffer length in bytes * \param[in] pIV IV buffer - * \param[in] associated_data_length Length of the associated data + * \param[in] associated_data_length Length of the associated data
+ * message_length maximum value (in bytes): + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 11 - IV_length * \param[in] pAssociated_data Buffer containing associated data * \param[in] authentication_tag_length Expected length for the authentication tag * \param[out] pAuthentication_tag Buffer to store the authentication tag @@ -106,7 +114,9 @@ stse_ReturnCode_t stsafea_aes_gmac_compute( * \param[in] slot_number Key slot in symmetric key table to be used * \param[in] IV_length IV buffer length in bytes * \param[in] pIV IV buffer - * \param[in] associated_data_length Length of the associated data + * \param[in] associated_data_length Length of the associated data
+ * message_length maximum value (in bytes): + * - STSAFE-A120 : STSAFEA_MAX_FRAME_LENGTH_A120 - 11 - IV_length - authentication_tag_length * \param[in] pAssociated_data Buffer containing associated data * \param[in] authentication_tag_length Expected length for the authentication tag * \param[in] pAuthentication_tag Buffer containing the authentication tag diff --git a/services/stsafea/stsafea_password.c b/services/stsafea/stsafea_password.c index 05d82fda..67db1621 100644 --- a/services/stsafea/stsafea_password.c +++ b/services/stsafea/stsafea_password.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_password.c - * \brief password services for STSAFE-A + * \brief STSAFE-A services for password (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -16,8 +16,11 @@ ****************************************************************************** */ -#include "services/stsafea/stsafea_password.h" +/* Includes ------------------------------------------------------------------*/ +#include + #include "services/stsafea/stsafea_frame_transfer.h" +#include "services/stsafea/stsafea_password.h" #ifdef STSE_CONF_STSAFE_A_SUPPORT diff --git a/services/stsafea/stsafea_password.h b/services/stsafea/stsafea_password.h index b1763ec1..a4be3dc2 100644 --- a/services/stsafea/stsafea_password.h +++ b/services/stsafea/stsafea_password.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_password.h - * \brief password services for STSAFE-A + * \brief STSAFE-A services for password (header) * \author STMicroelectronics - CS application team * ****************************************************************************** diff --git a/services/stsafea/stsafea_patch.c b/services/stsafea/stsafea_patch.c index e06ff808..bffdf454 100644 --- a/services/stsafea/stsafea_patch.c +++ b/services/stsafea/stsafea_patch.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_patch.c - * \brief Patch services for STSAFE-A + * \brief STSAFE-A services for patch (source) * \author STMicroelectronics - CS application team * ****************************************************************************** diff --git a/services/stsafea/stsafea_patch.h b/services/stsafea/stsafea_patch.h index 19f643b1..303941e2 100644 --- a/services/stsafea/stsafea_patch.h +++ b/services/stsafea/stsafea_patch.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_patch.c - * \brief Patch services for STSAFE-A + * \brief STSAFE-A services for patch (header) * \author STMicroelectronics - CS application team * ****************************************************************************** diff --git a/services/stsafea/stsafea_public_key_slots.c b/services/stsafea/stsafea_public_key_slots.c index 71d9ce5e..14a12a0b 100644 --- a/services/stsafea/stsafea_public_key_slots.c +++ b/services/stsafea/stsafea_public_key_slots.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_public_key_slots.c - * \brief STSAFE Middleware services for genric public slots (source) + * \brief STSAFE-A services for for generic public slots (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -15,8 +15,12 @@ * *****************************************************************************/ -#include "services/stsafea/stsafea_public_key_slots.h" +/* Includes ------------------------------------------------------------------*/ +#include +#include + #include "services/stsafea/stsafea_frame_transfer.h" +#include "services/stsafea/stsafea_public_key_slots.h" #ifdef STSE_CONF_STSAFE_A_SUPPORT diff --git a/services/stsafea/stsafea_public_key_slots.h b/services/stsafea/stsafea_public_key_slots.h index 0bc88d84..6b63bf85 100644 --- a/services/stsafea/stsafea_public_key_slots.h +++ b/services/stsafea/stsafea_public_key_slots.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_public_key_slots.h - * \brief STSAFE Middleware services for genric public slots (header) + * \brief STSAFE-A services for for generic public slots (header) * \author STMicroelectronics - CS application team * ****************************************************************************** diff --git a/services/stsafea/stsafea_put_query.c b/services/stsafea/stsafea_put_query.c index 16809138..4325194e 100644 --- a/services/stsafea/stsafea_put_query.c +++ b/services/stsafea/stsafea_put_query.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_put_query.c - * \brief Put and query services for STSAFE-A + * \brief STSAFE-A services for put and query (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -16,8 +16,11 @@ ****************************************************************************** */ -#include "services/stsafea/stsafea_put_query.h" +/* Includes ------------------------------------------------------------------*/ +#include + #include "services/stsafea/stsafea_frame_transfer.h" +#include "services/stsafea/stsafea_put_query.h" #ifdef STSE_CONF_STSAFE_A_SUPPORT @@ -95,8 +98,7 @@ stse_ReturnCode_t stsafea_put_i2c_parameters( #endif if (pSTSE->device_type == STSAFE_A100 || - pSTSE->device_type == STSAFE_A110 || - pSTSE->device_type == STSAFE_A200) { + pSTSE->device_type == STSAFE_A110) { pI2c_parameters->idle_bus_time_to_standby = 0; } diff --git a/services/stsafea/stsafea_put_query.h b/services/stsafea/stsafea_put_query.h index 544abfde..a3e9a915 100644 --- a/services/stsafea/stsafea_put_query.h +++ b/services/stsafea/stsafea_put_query.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_patch.c - * \brief Patch services for STSAFE-A + * \brief STSAFE-A services for put and query (header) * \author STMicroelectronics - CS application team * ****************************************************************************** diff --git a/services/stsafea/stsafea_random.c b/services/stsafea/stsafea_random.c index 3bbf25ca..89ad0f2d 100644 --- a/services/stsafea/stsafea_random.c +++ b/services/stsafea/stsafea_random.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_random.c - * \brief Random services for STSAFE + * \brief STSAFE-A services for random (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -16,8 +16,12 @@ ****************************************************************************** */ -#include "services/stsafea/stsafea_random.h" +/* Includes ------------------------------------------------------------------*/ +#include +//#include + #include "services/stsafea/stsafea_frame_transfer.h" +#include "services/stsafea/stsafea_random.h" #ifdef STSE_CONF_STSAFE_A_SUPPORT @@ -40,7 +44,7 @@ stse_ReturnCode_t stsafea_generate_random( /*- Create CMD frame and populate elements */ stse_frame_allocate(CmdFrame); - stse_frame_element_allocate_push(&CmdFrame, eCmd_header, 1, &cmd_header); + stse_frame_element_allocate_push(&CmdFrame, eCmd_header, STSAFEA_HEADER_SIZE, &cmd_header); stse_frame_element_allocate_push(&CmdFrame, eSubject, 1, &subject); stse_frame_element_allocate_push(&CmdFrame, eSize, 1, &random_size); diff --git a/services/stsafea/stsafea_random.h b/services/stsafea/stsafea_random.h index e0d933d5..ee3793d1 100644 --- a/services/stsafea/stsafea_random.h +++ b/services/stsafea/stsafea_random.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_random.h - * \brief Random services for STSAFE + * \brief STSAFE-A services for random (header) * \author STMicroelectronics - CS application team * ****************************************************************************** diff --git a/services/stsafea/stsafea_reset.c b/services/stsafea/stsafea_reset.c index aa4d0130..ded816c6 100644 --- a/services/stsafea/stsafea_reset.c +++ b/services/stsafea/stsafea_reset.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_reset.c - * \brief Reset services for STSAFE + * \brief STSAFE-A services for reset (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -16,8 +16,11 @@ ****************************************************************************** */ -#include "services/stsafea/stsafea_reset.h" +/* Includes ------------------------------------------------------------------*/ +#include + #include "services/stsafea/stsafea_frame_transfer.h" +#include "services/stsafea/stsafea_reset.h" #ifdef STSE_CONF_STSAFE_A_SUPPORT @@ -31,7 +34,7 @@ stse_ReturnCode_t stsafea_reset(stse_Handler_t *pSTSE) { /*- Create CMD frame and populate elements */ stse_frame_allocate(CmdFrame); - stse_frame_element_allocate_push(&CmdFrame, eCmd_header, 1, &cmd_header); + stse_frame_element_allocate_push(&CmdFrame, eCmd_header, STSAFEA_HEADER_SIZE, &cmd_header); /*- Create Rsp frame and populate elements*/ stse_frame_allocate(RspFrame); diff --git a/services/stsafea/stsafea_reset.h b/services/stsafea/stsafea_reset.h index 53a0b367..a2512706 100644 --- a/services/stsafea/stsafea_reset.h +++ b/services/stsafea/stsafea_reset.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_reset.h - * \brief Reset services for STSAFE + * \brief STSAFE-A services for reset (header) * \author STMicroelectronics - CS application team * ****************************************************************************** diff --git a/services/stsafea/stsafea_sessions.c b/services/stsafea/stsafea_sessions.c index fe8977c3..dcb6d212 100644 --- a/services/stsafea/stsafea_sessions.c +++ b/services/stsafea/stsafea_sessions.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_sessions.c - * \brief STSAFE-A sessions (header) + * \brief STSAFE-A services for sessions (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -16,11 +16,16 @@ ****************************************************************************** */ -#include "services/stsafea/stsafea_sessions.h" +/* Includes ------------------------------------------------------------------*/ +#include +#include +#include + #include "services/stsafea/stsafea_aes.h" #include "services/stsafea/stsafea_commands.h" #include "services/stsafea/stsafea_frame_transfer.h" #include "services/stsafea/stsafea_host_key_slot.h" +#include "services/stsafea/stsafea_sessions.h" #ifdef STSE_CONF_STSAFE_A_SUPPORT diff --git a/services/stsafea/stsafea_sessions.h b/services/stsafea/stsafea_sessions.h index 7f09618e..fd36b9e8 100644 --- a/services/stsafea/stsafea_sessions.h +++ b/services/stsafea/stsafea_sessions.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stse_session.h - * \brief STSE session manager (header) + * \brief STSAFE-A services for sessions (header) * \author STMicroelectronics - SMD application team * ****************************************************************************** diff --git a/services/stsafea/stsafea_symmetric_key_slots.c b/services/stsafea/stsafea_symmetric_key_slots.c index bddfeaff..33f9d958 100644 --- a/services/stsafea/stsafea_symmetric_key_slots.c +++ b/services/stsafea/stsafea_symmetric_key_slots.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_symmetric_key_slots.c - * \brief STSAFEA symmetric key slots management services (source) + * \brief STSAFE-A services for symmetric key slots management (source) * \author STMicroelectronics - SMD application team * ****************************************************************************** @@ -16,10 +16,12 @@ *****************************************************************************/ /* Includes ------------------------------------------------------------------*/ +#include +#include -#include "services/stsafea/stsafea_symmetric_key_slots.h" #include "services/stsafea/stsafea_frame_transfer.h" #include "services/stsafea/stsafea_sessions.h" +#include "services/stsafea/stsafea_symmetric_key_slots.h" #ifdef STSE_CONF_STSAFE_A_SUPPORT diff --git a/services/stsafea/stsafea_symmetric_key_slots.h b/services/stsafea/stsafea_symmetric_key_slots.h index 71d1090e..61f3734c 100644 --- a/services/stsafea/stsafea_symmetric_key_slots.h +++ b/services/stsafea/stsafea_symmetric_key_slots.h @@ -1,6 +1,6 @@ /****************************************************************************** * \file stsafe_symmetric_key_crypto_services.h - * \brief STSAFE Middleware services for symmetric key cryptography (header) + * \brief STSAFE-A services for symmetric key slots management (header) * \author STMicroelectronics - SMD application team * ****************************************************************************** diff --git a/services/stsafea/stsafea_timings.c b/services/stsafea/stsafea_timings.c index c5dfa3f4..40155ebc 100644 --- a/services/stsafea/stsafea_timings.c +++ b/services/stsafea/stsafea_timings.c @@ -1,6 +1,6 @@ /****************************************************************************** * \file stsafe_timings.c - * \brief Util Macros for STSAFE Middleware + * \brief STSAFE-A timings definition (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -89,9 +89,9 @@ const PLAT_UI16 stsafea_cmd_timings[STSAFEA_PRODUCT_COUNT][STSAFEA_MAX_CMD_COUNT }, /* STSAFE_A120 */ { - 50, /* Echo */ - 22, /* Reset */ - 26, /* Generate Random */ + 2, /* Echo */ + 2, /* Reset */ + 4, /* Generate Random */ 22, /* Start Session */ 23, /* Decrement zone counter */ 23, /* Read zone */ @@ -103,53 +103,21 @@ const PLAT_UI16 stsafea_cmd_timings[STSAFEA_PRODUCT_COUNT][STSAFEA_MAX_CMD_COUNT STSAFEA_EXEC_TIME_DEFAULT, /* Unwrap issuer envelope (Not applicable)*/ STSAFEA_EXEC_TIME_DEFAULT, /* Delete MAC (Not applicable)*/ STSAFEA_EXEC_TIME_DEFAULT, /* Hibernate, (Not applicable)*/ - 25, /* Wrap Local Envelope */ - 24, /* Unwrap Local Envelope */ + 3, /* Wrap Local Envelope */ + 3, /* Unwrap Local Envelope */ STSAFEA_EXEC_TIME_DEFAULT, /* Put attribute(Not applicable) */ - 80, /* Generate key */ + 32, /* Generate key */ STSAFEA_EXEC_TIME_DEFAULT, /* Put key (Not applicable)*/ STSAFEA_EXEC_TIME_DEFAULT, /* Configure */ - 10, /* Query */ + 5, /* Query */ STSAFEA_EXEC_TIME_DEFAULT, /* Get Signature */ - 96, /* Generate Signature */ - 156, /* Verify Signature */ - 34, /* Establish Key */ + 37, /* Generate Signature */ + 62, /* Verify Signature */ + 83, /* Establish Key */ STSAFEA_EXEC_TIME_DEFAULT, /* Standby (Not applicable)*/ STSAFEA_EXEC_TIME_DEFAULT, /* Verify Password (Not applicable)*/ - 25, /* Encrypt */ - 26 /* Decrypt */ - }, - /* STSAFE_A200 */ - { - STSAFEA_EXEC_TIME_DEFAULT, /* Echo */ - STSAFEA_EXEC_TIME_DEFAULT, /* Reset */ - STSAFEA_EXEC_TIME_DEFAULT, /* Generate Random */ - STSAFEA_EXEC_TIME_DEFAULT, /* Start Session */ - STSAFEA_EXEC_TIME_DEFAULT, /* Decrement zone counter */ - STSAFEA_EXEC_TIME_DEFAULT, /* Read zone */ - STSAFEA_EXEC_TIME_DEFAULT, /* Update zone */ - STSAFEA_EXEC_TIME_DEFAULT, /* Increment zone counter */ - STSAFEA_EXEC_TIME_DEFAULT, /* Derive LORA key */ - STSAFEA_EXEC_TIME_DEFAULT, /* Generate MAC */ - STSAFEA_EXEC_TIME_DEFAULT, /* Verify MAC */ - STSAFEA_EXEC_TIME_DEFAULT, /* Unwrap issuer envelope */ - STSAFEA_EXEC_TIME_DEFAULT, /* Delete MAC */ - STSAFEA_EXEC_TIME_DEFAULT, /* Hibernate */ - STSAFEA_EXEC_TIME_DEFAULT, /* Wrap Local Envelope */ - STSAFEA_EXEC_TIME_DEFAULT, /* Unwrap Local Envelope */ - STSAFEA_EXEC_TIME_DEFAULT, /* Put attribute */ - STSAFEA_EXEC_TIME_DEFAULT, /* Generate key */ - STSAFEA_EXEC_TIME_DEFAULT, /* Put key */ - STSAFEA_EXEC_TIME_DEFAULT, /* Configure */ - STSAFEA_EXEC_TIME_DEFAULT, /* Query */ - STSAFEA_EXEC_TIME_DEFAULT, /* Get Signature */ - STSAFEA_EXEC_TIME_DEFAULT, /* Generate Signature */ - STSAFEA_EXEC_TIME_DEFAULT, /* Verify Signature */ - STSAFEA_EXEC_TIME_DEFAULT, /* Establish Key */ - STSAFEA_EXEC_TIME_DEFAULT, /* Standby */ - STSAFEA_EXEC_TIME_DEFAULT, /* Verify Password */ - STSAFEA_EXEC_TIME_DEFAULT, /* Encrypt */ - STSAFEA_EXEC_TIME_DEFAULT /* Decrypt */ + 5, /* Encrypt */ + 6 /* Decrypt */ }}; const PLAT_UI16 stsafea_extended_cmd_timings[STSAFEA_PRODUCT_COUNT][STSAFEA_MAX_EXT_CMD_COUNT] = { @@ -216,37 +184,6 @@ const PLAT_UI16 stsafea_extended_cmd_timings[STSAFEA_PRODUCT_COUNT][STSAFEA_MAX_ STSAFEA_EXEC_TIME_DEFAULT, STSAFEA_EXEC_TIME_DEFAULT}, /* STSAFE_A120 */ - { - STSAFEA_EXEC_TIME_DEFAULT, /* start hash */ - STSAFEA_EXEC_TIME_DEFAULT, /* process hash */ - STSAFEA_EXEC_TIME_DEFAULT, /* finish hash */ - STSAFEA_EXEC_TIME_DEFAULT, /* start volatile KEK session*/ - STSAFEA_EXEC_TIME_DEFAULT, /* establish symmetric keys */ - STSAFEA_EXEC_TIME_DEFAULT, /* confirm symmetric keys */ - STSAFEA_EXEC_TIME_DEFAULT, /* stop volatile KEK session */ - STSAFEA_EXEC_TIME_DEFAULT, /* WRITE_HOST_KEY_V2_PLAINTEXT */ - STSAFEA_EXEC_TIME_DEFAULT, /* WRITE_HOST_KEY_V2_WRAPPED */ - STSAFEA_EXEC_TIME_DEFAULT, /* WRITE_SYMMETRIC_KEY */ - STSAFEA_EXEC_TIME_DEFAULT, /* WRITE_PUBLIC_KEY */ - STSAFEA_EXEC_TIME_DEFAULT, /* GENERATE_ECDHE */ - STSAFEA_EXEC_TIME_DEFAULT, - STSAFEA_EXEC_TIME_DEFAULT, - STSAFEA_EXEC_TIME_DEFAULT, - STSAFEA_EXEC_TIME_DEFAULT, - STSAFEA_EXEC_TIME_DEFAULT, - STSAFEA_EXEC_TIME_DEFAULT, - STSAFEA_EXEC_TIME_DEFAULT, - STSAFEA_EXEC_TIME_DEFAULT, - STSAFEA_EXEC_TIME_DEFAULT, - STSAFEA_EXEC_TIME_DEFAULT, - STSAFEA_EXEC_TIME_DEFAULT, - STSAFEA_EXEC_TIME_DEFAULT, - STSAFEA_EXEC_TIME_DEFAULT, - STSAFEA_EXEC_TIME_DEFAULT, - STSAFEA_EXEC_TIME_DEFAULT, - STSAFEA_EXEC_TIME_DEFAULT, - STSAFEA_EXEC_TIME_DEFAULT}, - /* STSAFE_A200 */ { STSAFEA_EXEC_TIME_DEFAULT, /* start hash */ STSAFEA_EXEC_TIME_DEFAULT, /* process hash */ @@ -282,14 +219,12 @@ const PLAT_UI16 stsafea_boot_time[STSAFEA_PRODUCT_COUNT] = { STSAFEA_BOOT_TIME_DEFAULT, /* STSAFE_A100 */ STSAFEA_BOOT_TIME_DEFAULT, /* STSAFE_A110 */ STSAFEA_BOOT_TIME_DEFAULT, /* STSAFE_A120 */ - STSAFEA_BOOT_TIME_DEFAULT /* STSAFE_A200 */ }; const PLAT_UI16 stsafea_wakeup_time[STSAFEA_PRODUCT_COUNT] = { STSAFEA_WAKEUP_TIME_DEFAULT, /* STSAFE_A100 */ STSAFEA_WAKEUP_TIME_DEFAULT, /* STSAFE_A110 */ STSAFEA_WAKEUP_TIME_DEFAULT, /* STSAFE_A120 */ - STSAFEA_WAKEUP_TIME_DEFAULT /* STSAFE_A200 */ }; #endif /* STSE_CONF_STSAFE_A_SUPPORT */ diff --git a/services/stsafea/stsafea_timings.h b/services/stsafea/stsafea_timings.h index 75288c55..c45cd3e4 100644 --- a/services/stsafea/stsafea_timings.h +++ b/services/stsafea/stsafea_timings.h @@ -1,6 +1,6 @@ /****************************************************************************** * \file stsafea_timings.h - * \brief STSAFE-A timings definitions + * \brief STSAFE-A timings definition (header) * \author STMicroelectronics - CS application team * ****************************************************************************** diff --git a/services/stsafea/stsafea_wrap_unwrap.c b/services/stsafea/stsafea_wrap_unwrap.c index 5a591e93..5cf2dbd8 100644 --- a/services/stsafea/stsafea_wrap_unwrap.c +++ b/services/stsafea/stsafea_wrap_unwrap.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_wrap_unwrap.c - * \brief Wrap & unwrap services for STSAFE-A + * \brief STSAFE-A services for wrap & unwrap (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -16,8 +16,11 @@ ****************************************************************************** */ -#include "services/stsafea/stsafea_wrap_unwrap.h" +/* Includes ------------------------------------------------------------------*/ +#include + #include "services/stsafea/stsafea_frame_transfer.h" +#include "services/stsafea/stsafea_wrap_unwrap.h" #ifdef STSE_CONF_STSAFE_A_SUPPORT diff --git a/services/stsafea/stsafea_wrap_unwrap.h b/services/stsafea/stsafea_wrap_unwrap.h index 90deebba..d7a22c63 100644 --- a/services/stsafea/stsafea_wrap_unwrap.h +++ b/services/stsafea/stsafea_wrap_unwrap.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafea_hash.h - * \brief Hash services for STSAFE-A + * \brief STSAFE-A services for wrap & unwrap (header) * \author STMicroelectronics - CS application team * ****************************************************************************** diff --git a/services/stsafel/stsafel_commands.c b/services/stsafel/stsafel_commands.c index 2e70622d..cd6e8a41 100644 --- a/services/stsafel/stsafel_commands.c +++ b/services/stsafel/stsafel_commands.c @@ -1,6 +1,6 @@ /****************************************************************************** * \file stsafel_timings.c - * \brief STSAFE-L Timings definitions + * \brief STSAFE-L command services (source) * \author STMicroelectronics - CS application team * ****************************************************************************** diff --git a/services/stsafel/stsafel_commands.h b/services/stsafel/stsafel_commands.h index 697c99d4..c79f75be 100644 --- a/services/stsafel/stsafel_commands.h +++ b/services/stsafel/stsafel_commands.h @@ -1,7 +1,7 @@ /*! * ****************************************************************************** * \file stsafel_commands.h - * \brief STSAFE-L command typedefs and services + * \brief STSAFE-A command services (header) * \author STMicroelectronics - CS application team * ****************************************************************************** diff --git a/services/stsafel/stsafel_data_partition.c b/services/stsafel/stsafel_data_partition.c index 980f1882..4386f3bd 100644 --- a/services/stsafel/stsafel_data_partition.c +++ b/services/stsafel/stsafel_data_partition.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafel_data_partition.c - * \brief Data partition services for STSAFE-L + * \brief STSAFE-A services for data partition (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -16,8 +16,11 @@ ****************************************************************************** */ -#include "services/stsafel/stsafel_data_partition.h" +/* Includes ------------------------------------------------------------------*/ +#include + #include "services/stsafel/stsafel_commands.h" +#include "services/stsafel/stsafel_data_partition.h" #include "services/stsafel/stsafel_frame_transfer.h" #ifdef STSE_CONF_STSAFE_L_SUPPORT diff --git a/services/stsafel/stsafel_data_partition.h b/services/stsafel/stsafel_data_partition.h index c9d77b2f..7f6c8437 100644 --- a/services/stsafel/stsafel_data_partition.h +++ b/services/stsafel/stsafel_data_partition.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafel_data_partition.h - * \brief Data partition services for STSAFE-L + * \brief STSAFE-A services for data partition (header) * \author STMicroelectronics - CS application team * ****************************************************************************** diff --git a/services/stsafel/stsafel_device_info.c b/services/stsafel/stsafel_device_info.c index 95b218ee..3268b2ee 100644 --- a/services/stsafel/stsafel_device_info.c +++ b/services/stsafel/stsafel_device_info.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafel_device_info.c - * \brief Device info services for STSAFE-L + * \brief STSAFE-L services for device info (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -16,8 +16,11 @@ ****************************************************************************** */ -#include "services/stsafel/stsafel_device_info.h" +/* Includes ------------------------------------------------------------------*/ +#include + #include "services/stsafel/stsafel_commands.h" +#include "services/stsafel/stsafel_device_info.h" #include "services/stsafel/stsafel_frame_transfer.h" #ifdef STSE_CONF_STSAFE_L_SUPPORT diff --git a/services/stsafel/stsafel_device_info.h b/services/stsafel/stsafel_device_info.h index 63f0d6c2..24fc0d04 100644 --- a/services/stsafel/stsafel_device_info.h +++ b/services/stsafel/stsafel_device_info.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafel_device_info.h - * \brief Device info services for STSAFE-L + * \brief STSAFE-L services for device info (header) * \author STMicroelectronics - CS application team * ****************************************************************************** diff --git a/services/stsafel/stsafel_ecc.c b/services/stsafel/stsafel_ecc.c index cd0f9692..5826400e 100644 --- a/services/stsafel/stsafel_ecc.c +++ b/services/stsafel/stsafel_ecc.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafel_ecc.h - * \brief Elliptic Curves Cryptography (ECC) services for STSAFE-L + * \brief STSAFE-L services for ECC (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -16,8 +16,11 @@ ****************************************************************************** */ -#include "services/stsafel/stsafel_ecc.h" +/* Includes ------------------------------------------------------------------*/ +#include + #include "services/stsafel/stsafel_commands.h" +#include "services/stsafel/stsafel_ecc.h" #include "services/stsafel/stsafel_frame_transfer.h" #ifdef STSE_CONF_STSAFE_L_SUPPORT diff --git a/services/stsafel/stsafel_ecc.h b/services/stsafel/stsafel_ecc.h index 7c5e8b60..4ffa9570 100644 --- a/services/stsafel/stsafel_ecc.h +++ b/services/stsafel/stsafel_ecc.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafel_ecc.h - * \brief Elliptic Curves Cryptography (ECC) services for STSAFE-L + * \brief STSAFE-A services for ECC (header) * \author STMicroelectronics - CS application team * ****************************************************************************** diff --git a/services/stsafel/stsafel_echo.c b/services/stsafel/stsafel_echo.c index a736371d..1c6b9fba 100644 --- a/services/stsafel/stsafel_echo.c +++ b/services/stsafel/stsafel_echo.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafel_echo.c - * \brief Echo services for STSAFE-L + * \brief STSAFE-L services for echo (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -16,8 +16,11 @@ ****************************************************************************** */ -#include "services/stsafel/stsafel_echo.h" +/* Includes ------------------------------------------------------------------*/ +#include + #include "services/stsafel/stsafel_commands.h" +#include "services/stsafel/stsafel_echo.h" #include "services/stsafel/stsafel_frame_transfer.h" #ifdef STSE_CONF_STSAFE_L_SUPPORT diff --git a/services/stsafel/stsafel_echo.h b/services/stsafel/stsafel_echo.h index 20ec81e0..bd33dc66 100644 --- a/services/stsafel/stsafel_echo.h +++ b/services/stsafel/stsafel_echo.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafel_echo.h - * \brief Echo services for STSAFE-L + * \brief STSAFE-L services for echo (source) * \author STMicroelectronics - CS application team * ****************************************************************************** diff --git a/services/stsafel/stsafel_frame_transfer.c b/services/stsafel/stsafel_frame_transfer.c index 49154bc7..d561283d 100644 --- a/services/stsafel/stsafel_frame_transfer.c +++ b/services/stsafel/stsafel_frame_transfer.c @@ -1,7 +1,7 @@ /*! * ****************************************************************************** * \file stsafel_frame_transfer.c - * \brief STSAFE-L Frame transfer service (sources) + * \brief STSAFE-L services for frame transfer (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -16,6 +16,10 @@ ****************************************************************************** */ +/* Includes ------------------------------------------------------------------*/ +#include +#include + #include "services/stsafel/stsafel_frame_transfer.h" #include "services/stsafel/stsafel_timings.h" diff --git a/services/stsafel/stsafel_frame_transfer.h b/services/stsafel/stsafel_frame_transfer.h index abb216b2..5b6555cb 100644 --- a/services/stsafel/stsafel_frame_transfer.h +++ b/services/stsafel/stsafel_frame_transfer.h @@ -1,7 +1,7 @@ /*! * ****************************************************************************** * \file stsafel_frame_transfer.h - * \brief STSAFE-L Frame transfer service (header) + * \brief STSAFE-L services for frame transfer (header) * \author STMicroelectronics - CS application team * ****************************************************************************** diff --git a/services/stsafel/stsafel_low_power.c b/services/stsafel/stsafel_low_power.c index ea8712ab..65c8090f 100644 --- a/services/stsafel/stsafel_low_power.c +++ b/services/stsafel/stsafel_low_power.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafel_low_power.c - * \brief Low power services for STSAFE-L + * \brief STSAFE-L services for low-power modes services (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -16,10 +16,13 @@ ****************************************************************************** */ -#include "services/stsafel/stsafel_low_power.h" +/* Includes ------------------------------------------------------------------*/ +#include + #include "services/stsafel/stsafel_commands.h" #include "services/stsafel/stsafel_echo.h" #include "services/stsafel/stsafel_frame_transfer.h" +#include "services/stsafel/stsafel_low_power.h" #ifdef STSE_CONF_STSAFE_L_SUPPORT diff --git a/services/stsafel/stsafel_low_power.h b/services/stsafel/stsafel_low_power.h index b06acd46..2828e389 100644 --- a/services/stsafel/stsafel_low_power.h +++ b/services/stsafel/stsafel_low_power.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafel_low_power.h - * \brief Low power service for STSAFE-L + * \brief STSAFE-L services for low-power modes services (header) * \author STMicroelectronics - CS application team * ****************************************************************************** diff --git a/services/stsafel/stsafel_reset.c b/services/stsafel/stsafel_reset.c index eaaa9dbe..c453d00d 100644 --- a/services/stsafel/stsafel_reset.c +++ b/services/stsafel/stsafel_reset.c @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafel_reset.c - * \brief Reset services for STSAFE-L + * \brief STSAFE-L services for reset (source) * \author STMicroelectronics - CS application team * ****************************************************************************** @@ -16,9 +16,12 @@ ****************************************************************************** */ -#include "services/stsafel/stsafel_reset.h" +/* Includes ------------------------------------------------------------------*/ +#include + #include "services/stsafel/stsafel_commands.h" #include "services/stsafel/stsafel_frame_transfer.h" +#include "services/stsafel/stsafel_reset.h" #ifdef STSE_CONF_STSAFE_L_SUPPORT diff --git a/services/stsafel/stsafel_reset.h b/services/stsafel/stsafel_reset.h index 275ced41..e788d0e9 100644 --- a/services/stsafel/stsafel_reset.h +++ b/services/stsafel/stsafel_reset.h @@ -1,7 +1,7 @@ /*! ****************************************************************************** * \file stsafel_reset.h - * \brief Reset service for STSAFE-L + * \brief STSAFE-L services for reset (header) * \author STMicroelectronics - CS application team * ****************************************************************************** diff --git a/services/stsafel/stsafel_timings.c b/services/stsafel/stsafel_timings.c index 6bb4e07d..6063cf96 100644 --- a/services/stsafel/stsafel_timings.c +++ b/services/stsafel/stsafel_timings.c @@ -1,6 +1,6 @@ /****************************************************************************** * \file stsafel_timings.c - * \brief STSAFE-L Timings definitions + * \brief STSAFE-L timings definition (source) * \author STMicroelectronics - CS application team * ****************************************************************************** diff --git a/services/stsafel/stsafel_timings.h b/services/stsafel/stsafel_timings.h index 9b958163..a76cc23a 100644 --- a/services/stsafel/stsafel_timings.h +++ b/services/stsafel/stsafel_timings.h @@ -1,6 +1,6 @@ /****************************************************************************** * \file stsafel_timings.h - * \brief STSAFE-L Timings definitions + * \brief STSAFE-L timings definition (header) * \author STMicroelectronics - CS application team * ******************************************************************************