Commit 8cfa0f40 authored by Joakim Andersson's avatar Joakim Andersson Committed by Anas Nashif
Browse files

samples: tfm_secure_partition: Update sample for TF-M 1.7.0



Update TF-M secure partition sample for TF-M 1.7.0.
Removes the support for Library model in the sample.
Updates to using PSA framework 1.1.

Signed-off-by: default avatarJoakim Andersson <joakim.andersson@nordicsemi.no>
Signed-off-by: default avatarDavid Brown <david.brown@linaro.org>
parent d9b6e58e
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -25,24 +25,26 @@ target_sources(tfm_app_rot_partition_dp
# The generated sources
target_sources(tfm_app_rot_partition_dp
    PRIVATE
        $<$<BOOL:${TFM_PSA_API}>:
            ${CMAKE_BINARY_DIR}/dummy_partition/auto_generated/intermedia_tfm_dummy_partition.c>
        ${CMAKE_BINARY_DIR}/dummy_partition/auto_generated/intermedia_tfm_dummy_partition.c
)
target_sources(tfm_partitions
    INTERFACE
        $<$<BOOL:${TFM_PSA_API}>:
            ${CMAKE_BINARY_DIR}/dummy_partition/auto_generated/load_info_tfm_dummy_partition.c>
        ${CMAKE_BINARY_DIR}/dummy_partition/auto_generated/load_info_tfm_dummy_partition.c
)

target_link_libraries(tfm_app_rot_partition_dp
    PRIVATE
        tfm_secure_api
        psa_interface
        secure_fw
        platform_s
        tfm_psa_rot_partition_crypto
        tfm_sprt
)

target_link_libraries(tfm_spm
    PRIVATE
        tfm_app_rot_partition_dp
)

############################ Partition Defs ####################################

target_link_libraries(tfm_partitions
    INTERFACE
        tfm_app_rot_partition_dp
+3 −42
Original line number Diff line number Diff line
@@ -7,9 +7,11 @@
#include <psa/crypto.h>
#include <stdbool.h>
#include <stdint.h>
#include "tfm_secure_api.h"
#include "tfm_api.h"

#include "psa/service.h"
#include "psa_manifest/tfm_dummy_partition.h"

#define NUM_SECRETS 5

struct dp_secret {
@@ -60,41 +62,6 @@ static psa_status_t tfm_dp_secret_digest(uint32_t secret_index,
	return PSA_SUCCESS;
}

#ifndef TFM_PSA_API

#include "tfm_memory_utils.h"

void psa_write_digest(void *handle, uint8_t *digest, uint32_t digest_size)
{
	tfm_memcpy(handle, digest, digest_size);
}

psa_status_t tfm_dp_secret_digest_req(psa_invec *in_vec, size_t in_len,
				      psa_outvec *out_vec, size_t out_len)
{
	uint32_t secret_index;

	if ((in_len != 1) || (out_len != 1)) {
		/* The number of arguments are incorrect */
		return PSA_ERROR_PROGRAMMER_ERROR;
	}

	if (in_vec[0].len != sizeof(secret_index)) {
		/* The input argument size is incorrect */
		return PSA_ERROR_PROGRAMMER_ERROR;
	}

	secret_index = *((uint32_t *)in_vec[0].base);

	return tfm_dp_secret_digest(secret_index, out_vec[0].len,
				    &out_vec[0].len, psa_write_digest,
				    (void *)out_vec[0].base);
}

#else /* !defined(TFM_PSA_API) */
#include "psa/service.h"
#include "psa_manifest/tfm_dummy_partition.h"

typedef psa_status_t (*dp_func_t)(psa_msg_t *);

static void psa_write_digest(void *handle, uint8_t *digest,
@@ -123,7 +90,6 @@ static psa_status_t tfm_dp_secret_digest_ipc(psa_msg_t *msg)
				    (void *)msg->handle);
}


static void dp_signal_handle(psa_signal_t signal, dp_func_t pfn)
{
	psa_status_t status;
@@ -145,11 +111,9 @@ static void dp_signal_handle(psa_signal_t signal, dp_func_t pfn)
		psa_panic();
	}
}
#endif /* !defined(TFM_PSA_API) */

psa_status_t tfm_dp_req_mngr_init(void)
{
#ifdef TFM_PSA_API
	psa_signal_t signals = 0;

	while (1) {
@@ -163,7 +127,4 @@ psa_status_t tfm_dp_req_mngr_init(void)
	}

	return PSA_ERROR_SERVICE_FAILURE;
#else
	return PSA_SUCCESS;
#endif
}
+13 −20
Original line number Diff line number Diff line
@@ -7,36 +7,29 @@
# -------------------------------------------------------------------------------

{
  "psa_framework_version": 1.0,
  "psa_framework_version": 1.1,
  "name": "TFM_SP_DP",
  "type": "APPLICATION-ROT",
  "priority": "NORMAL",
  "model": "IPC",
  "entry_point": "tfm_dp_req_mngr_init",
  "stack_size": "0x800",

  # Service definitions for library mode.
  "secure_functions": [
  # Service definitions for IPC model.
  "services": [
    {
      "name": "TFM_DP_SECRET_DIGEST",
      "signal": "TFM_DP_SECRET_DIGEST_REQ",
      "non_secure_clients": true,
      "version": 1,
      "version_policy": "STRICT"
    }
  ],

  # Service definitions for IPC mode.
  "services": [{
    "name": "TFM_DP_SECRET_DIGEST",

      # Bits [31:12] denote the vendor (change this),
      # bits [11:0] are arbitrary at the discretion of the
      # vendor.
      "sid": "0xFFFFF001",

      "non_secure_clients": true,
      # Make the service connection based.
      # We now require TFM_CONNECTION_BASED_SERVICE_API to be enabled.
      "connection_based": true,
      "version": 1,
    "version_policy": "STRICT"
      "version_policy": "STRICT",
    }
  ],

+2 −2
Original line number Diff line number Diff line
@@ -6,14 +6,14 @@
#-------------------------------------------------------------------------------

{
  "name": "TF-M secure partition manifests",
  "description": "TF-M secure partition manifests",
  "type": "manifest_list",
  "version_major": 0,
  "version_minor": 1,
  "pid": 1000,
  "manifest_list": [
    {
      "name": "Dummy Partition",
      "description": "Dummy Partition",
      "short_name": "TFM_DP",
      "manifest": "${APPLICATION_SOURCE_DIR}/dummy_partition/tfm_dummy_partition.yaml",
      "output_path": "${TFM_BINARY_DIR}/dummy_partition",
+1 −0
Original line number Diff line number Diff line
@@ -6,3 +6,4 @@

CONFIG_BUILD_WITH_TFM=y
CONFIG_TFM_PROFILE_TYPE_NOT_SET=y
CONFIG_TFM_CONNECTION_BASED_SERVICE_API=y
Loading