Skip to content
Merged
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
2 changes: 1 addition & 1 deletion api-tests/platform/drivers/watchdog/nrf/nrf_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define NRF_WDT31_NS ((struct NRF_WDT_Type *)0x40109000)
#define NRF_WDT0_NS ((struct NRF_WDT_Type *)0x40018000)

#ifdef NRF54L15_XXAA
#if defined(NRF54L15_XXAA) || defined(NRF7120_ENGA_XXAA)
#define PSA_TEST_WDT_INSTANCE NRF_WDT31_NS
#else
#define PSA_TEST_WDT_INSTANCE NRF_WDT0_NS
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/** @file
* Copyright (c) 2025, Arm Limited or its affiliates. All rights reserved.
* SPDX-License-Identifier : Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

#ifndef _PAL_ATTESTATION_CONFIG_H_
#define _PAL_ATTESTATION_CONFIG_H_

#define COSE_ALGORITHM_ES256 -7
#define COSE_ALG_SHA256_PROPRIETARY -72000

#define USEFUL_BUF_MAKE_STACK_UB UsefulBuf_MAKE_STACK_UB

#define COSE_SIG_CONTEXT_STRING_SIGNATURE1 "Signature1"

/* Private value. Intentionally not documented for Doxygen.
* This is the size allocated for the encoded protected headers. It
* needs to be big enough for make_protected_header() to succeed. It
* currently sized for one header with an algorithm ID up to 32 bits
* long -- one byte for the wrapping map, one byte for the label, 5
* bytes for the ID. If this is made accidentially too small, QCBOR will
* only return an error, and not overrun any buffers.
*
* 9 extra bytes are added, rounding it up to 16 total, in case some
* other protected header is to be added.
*/
#define T_COSE_SIGN1_MAX_PROT_HEADER (1+1+5+9)

/**
* This is the size of the first part of the CBOR encoded TBS
* bytes. It is around 20 bytes. See create_tbs_hash().
*/
#define T_COSE_SIZE_OF_TBS ( \
1 + /* For opening the array */ \
sizeof(COSE_SIG_CONTEXT_STRING_SIGNATURE1) + /* "Signature1" */ \
2 + /* Overhead for encoding string */ \
T_COSE_SIGN1_MAX_PROT_HEADER + /* entire protected headers */ \
3 * (/* 3 NULL bstrs for fields not used */ \
1 /* size of a NULL bstr */ \
) \
)

#define NULL_USEFUL_BUF_C NULLUsefulBufC

#define ATTEST_PUBLIC_KEY_SLOT 4
#define ECC_CURVE_SECP256R1_PULBIC_KEY_LENGTH (1 + 2 * PSA_BITS_TO_BYTES(256))

typedef struct {
uint8_t *pubx_key;
size_t pubx_key_size;
uint8_t *puby_key;
size_t puby_key_size;
} ecc_key_t;

struct ecc_public_key_t {
const uint8_t a;
uint8_t public_key[]; /* X-coordinate || Y-coordinate */
};

static const struct ecc_public_key_t attest_public_key = {
/* Constant byte */
0x04,
/* X-coordinate */
{0x79, 0xEB, 0xA9, 0x0E, 0x8B, 0xF4, 0x50, 0xA6,
0x75, 0x15, 0x76, 0xAD, 0x45, 0x99, 0xB0, 0x7A,
0xDF, 0x93, 0x8D, 0xA3, 0xBB, 0x0B, 0xD1, 0x7D,
0x00, 0x36, 0xED, 0x49, 0xA2, 0xD0, 0xFC, 0x3F,
/* Y-coordinate */
0xBF, 0xCD, 0xFA, 0x89, 0x56, 0xB5, 0x68, 0xBF,
0xDB, 0x86, 0x73, 0xE6, 0x48, 0xD8, 0xB5, 0x8D,
0x92, 0x99, 0x55, 0xB1, 0x4A, 0x26, 0xC3, 0x08,
0x0F, 0x34, 0x11, 0x7D, 0x97, 0x1D, 0x68, 0x64},
};

static const uint8_t initial_attestation_public_x_key[] = {
0x79, 0xEB, 0xA9, 0x0E, 0x8B, 0xF4, 0x50, 0xA6,
0x75, 0x15, 0x76, 0xAD, 0x45, 0x99, 0xB0, 0x7A,
0xDF, 0x93, 0x8D, 0xA3, 0xBB, 0x0B, 0xD1, 0x7D,
0x00, 0x36, 0xED, 0x49, 0xA2, 0xD0, 0xFC, 0x3F
};

static const uint8_t initial_attestation_public_y_key[] = {
0xBF, 0xCD, 0xFA, 0x89, 0x56, 0xB5, 0x68, 0xBF,
0xDB, 0x86, 0x73, 0xE6, 0x48, 0xD8, 0xB5, 0x8D,
0x92, 0x99, 0x55, 0xB1, 0x4A, 0x26, 0xC3, 0x08,
0x0F, 0x34, 0x11, 0x7D, 0x97, 0x1D, 0x68, 0x64
};

/* Initialize the structure with given public key */
static const ecc_key_t attest_key = {
(uint8_t *)initial_attestation_public_x_key,
sizeof(initial_attestation_public_x_key),
(uint8_t *)initial_attestation_public_y_key,
sizeof(initial_attestation_public_y_key)
};

#endif /* _PAL_ATTESTATION_CONFIG_H_ */

157 changes: 157 additions & 0 deletions api-tests/platform/targets/tgt_dev_apis_tfm_nrf7120/nspe/pal_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
/** @file
* Copyright (c) 2025, Arm Limited or its affiliates. All rights reserved.
* SPDX-License-Identifier : Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

#ifndef _PAL_CONFIG_H_
#define _PAL_CONFIG_H_

#include "pal_crypto_config.h"
#include "pal_attestation_config.h"
#include "pal_storage_config.h"

/*========================== PLATFORM CONFIGURATIONS START ==========================*/

// UART device info
#define UART_NUM 20
#define UART_20_BASE 0x0

/*
* The nRF instance that is appropriate to use on 71 non-secure is
* NRF_WDT31, but 31 breaks the test infrastructure so we pretend we are
* using the non-existent instance 4 instead.
*/

/* Watchdog device info */
#define WATCHDOG_NUM 4
#define WATCHDOG_4_BASE 0x40109000
#define WATCHDOG_4_NUM_OF_TICK_PER_MICRO_SEC 0x1

#define WATCHDOG_4_TIMEOUT_IN_MICRO_SEC_LOW 500000000
#define WATCHDOG_4_TIMEOUT_IN_MICRO_SEC_MEDIUM 500000000
#define WATCHDOG_4_TIMEOUT_IN_MICRO_SEC_HIGH 500000000
#define WATCHDOG_4_TIMEOUT_IN_MICRO_SEC_CRYPTO 500000000

/* Range of 1KB Non-volatile memory to preserve data over reset. Ex, NVRAM and FLASH */
#define NVMEM_NUM 1

#define NVMEM_0_START 0x0
#define NVMEM_0_END 0x3FF

/*========================== PLATFORM CONFIGURATIONS END ============================*/

/* Define PSA test suite dependent macros for non-cmake build */
#if !defined(PSA_CMAKE_BUILD)

/* Print verbosity = TEST */
#define VERBOSITY 3

/* NSPE or SPE VAL build? */
#define VAL_NSPE_BUILD

/* NSPE or SPE TEST build? */
#define NONSECURE_TEST_BUILD

/* If not defined, skip watchdog programming */
#define WATCHDOG_AVAILABLE

/* Are Dynamic memory APIs available to secure partition? */
#define SP_HEAP_MEM_SUPP

/* PSA Isolation level supported by platform */
#define PLATFORM_PSA_ISOLATION_LEVEL 3
#endif /* PSA_CMAKE_BUILD */

/* Version of crypto spec used in attestation */
#define CRYPTO_VERSION_BETA3

/* Use hardcoded public key */
#define PLATFORM_OVERRIDE_ATTEST_PK

/* Enable custom printing for Non-secure side */
#define BESPOKE_PRINT_NS

/* UART base address assigned */
#define PLATFORM_UART_BASE UART_20_BASE

/* Watchdog device configurations assigned */
#define PLATFORM_WD_BASE WATCHDOG_4_BASE
#define PLATFORM_WD_NUM_OF_TICK_PER_MICRO_SEC WATCHDOG_4_NUM_OF_TICK_PER_MICRO_SEC
#define PLATFORM_WD_TIMEOUT_IN_MICRO_SEC_LOW WATCHDOG_4_TIMEOUT_IN_MICRO_SEC_LOW
#define PLATFORM_WD_TIMEOUT_IN_MICRO_SEC_MEDIUM WATCHDOG_4_TIMEOUT_IN_MICRO_SEC_LOW
#define PLATFORM_WD_TIMEOUT_IN_MICRO_SEC_HIGH WATCHDOG_4_TIMEOUT_IN_MICRO_SEC_LOW
#define PLATFORM_WD_TIMEOUT_IN_MICRO_SEC_CRYPTO WATCHDOG_4_TIMEOUT_IN_MICRO_SEC_CRYPTO

/* Non-volatile memory base address assigned */
#define PLATFORM_NVM_BASE NVMEM_0_START

/*
* Include of PSA defined Header files
*/
#ifdef IPC
/* psa/client.h: Contains the PSA Client API elements */
#include "psa/client.h"

/*
* psa_manifest/sid.h: Macro definitions derived from manifest files that map from RoT Service
* names to Service IDs (SIDs). Partition manifest parse build tool must provide the implementation
* of this file.
*/
#include "psa_manifest/sid.h"

/*
* psa_manifest/pid.h: Secure Partition IDs
* Macro definitions that map from Secure Partition names to Secure Partition IDs.
* Partition manifest parse build tool must provide the implementation of this file.
*/
#include "psa_manifest/pid.h"
#endif

#ifdef CRYPTO
/* psa/crypto.h: Contains the PSA Crypto API elements */
#include "psa/crypto.h"
#endif

#if defined(INTERNAL_TRUSTED_STORAGE) || defined(STORAGE)
/* psa/internal_trusted_storage.h: Contains the PSA ITS API elements */
#include "psa/internal_trusted_storage.h"
#endif

#if defined(PROTECTED_STORAGE) || defined(STORAGE)
/* psa/protected_storage.h: Contains the PSA PS API elements */
#include "psa/protected_storage.h"
#endif

#ifdef INITIAL_ATTESTATION
/* psa/initial_attestation.h: Contains the PSA Initial Attestation API elements */
#include "psa/initial_attestation.h"
#endif

extern int tfm_log_printf(const char *, ...);
extern int32_t tfm_platform_system_reset(void);

/* Initialize the timer with the given number of ticks. */
extern void pal_timer_init_ns(uint32_t ticks);

/* Start the timer. */
extern void pal_timer_start_ns(void);

/* Stop and reset the timer. */
extern void pal_timer_stop_ns(void);

/* Get the address of a free, word-aligned, 1K memory area. */
extern uint32_t pal_nvmem_get_addr(void);

#endif /* _PAL_CONFIG_H_ */
Loading