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
4 changes: 2 additions & 2 deletions Applications/Projects/00_Project_template/main.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
******************************************************************************
* \file main.c
* \brief STSELIB project template
* \brief STSAFE-L010 project template
* \author CS application team
******************************************************************************
* COPYRIGHT 2022 STMicroelectronics
Expand All @@ -21,7 +21,7 @@

/**
* @brief Main program entry point
* @note This is a template project for STSAFE-A120 examples
* @note This is a template project for STSAFE-L010 examples
* Add your application code here
* @retval Not applicable (infinite loop)
*/
Expand Down
17 changes: 4 additions & 13 deletions Applications/Projects/ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
# Project package example

This project folder contains examples illustrating typical use cases for the STSAFE-A120.
The index preceding the project folder name illustrates the execution hierarchy of the examples.
This means that the project with a higher index must be executed after the project with a lower index.
For example, index project 03 must be run after index project 02.
Indeed, some tests configure the STSAFE-A120 according to a typical configuration for field usage.

Dependency index between groups of examples:
- 0: Template ((No dependency)
- 1: Examples without dependency
- 2: Configuration examples without any dependency
- 3: Examples with group 2 dependency
- 4: Configuration examples without any dependency
- 5: Examples with dependency of groups 2 & 4
This project folder contains examples illustrating typical use cases for the STSAFE-L010.



Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>STSAFE-L010_secure_data_storage</name>
<name>SPL01_Device_authentication</name>
<comment></comment>
<projects>
</projects>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @author CS application team
* @brief STSAFE-L010 Device authentication example
******************************************************************************
* COPYRIGHT 2022 STMicroelectronics
* 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.
Expand All @@ -19,9 +19,9 @@

/* Defines -------------------------------------------------------------------*/

/* Root CA key used for STSE-L SPL01 */
/* Root CA key used for STSAFE-L010 SPL01 */
#define CA_SELF_SIGNED_CERTIFICATE_01 \
0x30, 0x82, 0x01, 0x67, 0x30, 0x82, 0x01, 0x19, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, \
0x30, 0x82, 0x01, 0x67, 0x30, 0x82, 0x01, 0x19, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, \
0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x70, 0x30, 0x4b, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, \
0x04, 0x06, 0x13, 0x02, 0x4e, 0x4c, 0x31, 0x1e, 0x30, 0x1c, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, \
0x15, 0x53, 0x54, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x72, 0x6f, 0x6e, \
Expand Down Expand Up @@ -64,52 +64,55 @@
*/
int main(void) {
stse_ReturnCode_t stse_ret = STSE_API_INVALID_PARAMETER;
stse_Handler_t stse_handler;
stse_Handler_t stse_handle;
static const uint8_t ca_selfsigned_cert[] = {CA_SELF_SIGNED_CERTIFICATE_01};

/* Initialize Terminal */
apps_terminal_init(115200);

/* - Print Example instruction on terminal */
/* ## Print Example instruction on terminal */
printf("----------------------------------------------------------------------------------------------------------------");
printf("\n\r- STSAFE-L010 Device Authentication Example -");
printf("\n\r- STSAFE-L010 SPL01 Device Authentication Example -");
printf("\n\r----------------------------------------------------------------------------------------------------------------");
printf("\n\r- This example illustrates STSAFE-L010 device authentication process using Multi-Step approach. -");
printf("\n\r- This example illustrates STSAFE-L010 device authentication process. -");
printf("\n\r- it can be taken as reference for building distant server authentication use cases. -");
printf("\n\r----------------------------------------------------------------------------------------------------------------");

/* ## Initialize STSAFE-A1xx device handler */
stse_ret = stse_set_default_handler_value(&stse_handler);
printf("\n\n\r ( Press key to continue )");
uart_getc();

/* ## Initialize STSAFE-L010 device handler */
stse_ret = stse_set_default_handler_value(&stse_handle);
if (stse_ret != STSE_OK) {
printf(PRINT_RED "\n\r ## stse_set_default_handler_value ERROR : 0x%04X\n\r", stse_ret);
printf("\n\n\r ## stse_set_default_handler_value : "PRINT_RED"ERROR 0x%04X"PRINT_RESET"\n\r", stse_ret);
apps_process_error(stse_ret);
}

stse_handler.device_type = STSAFE_L010;
stse_handler.io.busID = 1;
stse_handler.io.BusSpeed = 100;
stse_handler.io.Devaddr = 0x0C;
stse_handle.device_type = STSAFE_L010;
stse_handle.io.BusType = STSE_BUS_TYPE_I2C;
stse_handle.io.BusSpeed = 100;
stse_handle.io.Devaddr = 0x0C;

printf("\n\r - Initialize target STSAFE-L010");
stse_ret = stse_init(&stse_handler);
printf("\n\n\r ## Initialize target STSAFE-L010");
stse_ret = stse_init(&stse_handle);
if (stse_ret != STSE_OK) {
printf(PRINT_RED "\n\r ## stse_init ERROR : 0x%04X\n\r", stse_ret);
printf("\n\r ## stse_init : "PRINT_RED"ERROR 0x%04X"PRINT_RESET"\n\r", stse_ret);
apps_process_error(stse_ret);
}

/* ## Authenticate target STSAFE-A120 device */
/* ## Authenticate target STSAFE-L010 device */
stse_ret = stse_device_authenticate(
&stse_handler,
&stse_handle,
ca_selfsigned_cert,
STSAFE_CERTIFICATE_ZONE_0,
STSE_STATIC_PRIVATE_KEY_SLOT_0);

if (stse_ret != STSE_OK) {
printf(PRINT_RED "\n\n\r ## Device authentication over STSE-L SPL01 CA certificate : Failed \n\r");
printf("\n\r\t o stse_device_authenticate ERROR : 0x%04X", stse_ret);
printf("\n\n\r ## Device authentication over STSAFE-L010 SPL01 CA certificate :"PRINT_RED" FAIL "PRINT_RESET"\n\r");
printf("\n\r\t o stse_device_authenticate"PRINT_RED": ERROR 0x%04X"PRINT_RESET, stse_ret);
apps_process_error(stse_ret);
} else {
printf(PRINT_GREEN "\n\n\r ## Device authentication over STSE-L SPL01 CA certificate : Successful\n\r");
printf("\n\n\r ## Device authentication over STSAFE-L010 SPL01 CA certificate :"PRINT_GREEN" SUCCESS "PRINT_RESET"\n\r");
}

while (1) {
Expand Down
Loading