Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions api/stse_aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
*
*****************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include <stddef.h>

#include "api/stse_aes.h"

stse_ReturnCode_t stse_aes_ecb_encrypt(
Expand Down
2 changes: 2 additions & 0 deletions api/stse_asymmetric_keys_management.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*****************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include <stddef.h>
#include <string.h>

#include "api/stse_asymmetric_keys_management.h"

Expand Down
8 changes: 2 additions & 6 deletions api/stse_data_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ 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;

#ifdef STSE_CONF_STSAFE_A_SUPPORT
#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 */
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions api/stse_data_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ 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
*/
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
Expand Down
4 changes: 4 additions & 0 deletions api/stse_derive_keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
*
*****************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include <stddef.h>
#include <string.h>

#include "api/stse_derive_keys.h"

stse_ReturnCode_t stse_derive_key(
Expand Down
1 change: 1 addition & 0 deletions api/stse_device_authentication.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*****************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include <stddef.h>

#include "api/stse_device_authentication.h"
#include "api/stse_ecc.h"
Expand Down
6 changes: 2 additions & 4 deletions api/stse_device_management.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*****************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include <stddef.h>

#include "api/stse_device_management.h"

/* Exported variables --------------------------------------------------------*/
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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 */
Expand Down
10 changes: 6 additions & 4 deletions api/stse_ecc.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@
*
*****************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include <stddef.h>

#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) {
Expand Down Expand Up @@ -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 */
Expand Down
6 changes: 3 additions & 3 deletions api/stse_ecc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions api/stse_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
*
*****************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include <stddef.h>

#include "api/stse_hash.h"
#include "services/stsafea/stsafea_frame_transfer.h"
#include "services/stsafea/stsafea_hash.h"
Expand Down
3 changes: 3 additions & 0 deletions api/stse_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
*
*****************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include <stddef.h>

#include "api/stse_mac.h"

stse_ReturnCode_t stse_cmac_hmac_compute(
Expand Down
3 changes: 3 additions & 0 deletions api/stse_random.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
*
*****************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include <stddef.h>

#include "api/stse_random.h"

stse_ReturnCode_t stse_generate_random(
Expand Down
28 changes: 15 additions & 13 deletions api/stse_symmetric_keys_management.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
*****************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include <stddef.h>
#include <string.h>

#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
Expand Down Expand Up @@ -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;
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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(
Expand Down
6 changes: 5 additions & 1 deletion certificate/stse_certificate_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@
******************************************************************************
*/

#include "certificate/stse_certificate_crypto.h"
/* Includes ------------------------------------------------------------------*/
#include <stddef.h>
#include <string.h>

#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;
Expand Down
7 changes: 5 additions & 2 deletions core/stse_device.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* ******************************************************************************
* \file stse_device.c
* \brief STSAFE Frame layer (sources)
* \brief STSELib api for device (sources)
* \author STMicroelectronics - CS application team
*
******************************************************************************
Expand Down Expand Up @@ -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;
Expand Down
Loading