Skip to content

Commit 10b92ad

Browse files
authored
Merge pull request #406 from ahmadstm/stm32wba6_psa_api
ST : Add STM32WBA platform to psa-arch-tests.
2 parents a206b70 + 874b8c2 commit 10b92ad

File tree

10 files changed

+1047
-2
lines changed

10 files changed

+1047
-2
lines changed

api-tests/platform/drivers/watchdog/stm/pal_wd_stm.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/** @file
2-
* Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved.
2+
* Copyright (c) 2018 - 2025, Arm Limited or its affiliates. All rights reserved.
3+
* SPDX-License-Identifier : Apache-2.0
4+
*
5+
* Copyright (c) 2018 - 2025, STMicroelectronics.
36
* SPDX-License-Identifier : Apache-2.0
47
*
58
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -54,6 +57,37 @@ int pal_wd_stm_init(addr_t base_addr, uint32_t time_us, uint32_t timer_tick_us)
5457
return 0;
5558
}
5659

60+
/**
61+
@brief - Initializes an hardware watchdog timer
62+
@param - base_addr : Base address of the watchdog module for STM32WBA
63+
- time_us : Time in micro seconds
64+
- timer_tick_us : Number of ticks per micro second
65+
@return - SUCCESS/FAILURE
66+
**/
67+
int pal_wd_stm_wba_init(addr_t base_addr, uint32_t time_us, uint32_t timer_tick_us)
68+
{
69+
volatile uint32_t ti = time_us;
70+
volatile uint32_t titi = timer_tick_us;
71+
ti;
72+
titi;
73+
/* enable watchog clock */
74+
#define RCC_APB1ENR1_WWDGEN_Pos (11U)
75+
#define RCC_APB1ENR1_WWDGEN_Msk (0x1UL << RCC_APB1ENR1_WWDGEN_Pos)/*!< 0x00000800 */
76+
#define RCC_APB1ENR1_WWDGEN RCC_APB1ENR1_WWDGEN_Msk
77+
/* RCC_APB1ENR1 */
78+
volatile uint32_t *reg = (uint32_t *)0x40002C00;
79+
*reg |= RCC_APB1ENR1_WWDGEN;
80+
*reg |= RCC_APB1ENR1_WWDGEN;
81+
/* prescaler */
82+
MODIFY_REG(((WWDG_TypeDef *)base_addr)->CFR, WWDG_CFR_WDGTB, LL_WWDG_PRESCALER_128);
83+
/* Counter 0..0x7F (7 bit counter value)*/
84+
MODIFY_REG(((WWDG_TypeDef *)base_addr)->CR, WWDG_CR_T, 0x7F);
85+
/* Window 0x00..0x7F*/
86+
MODIFY_REG(((WWDG_TypeDef *)base_addr)->CFR, WWDG_CFR_W, 0x7F);
87+
88+
return 0;
89+
}
90+
5791
/**
5892
@brief - Enables a hardware watchdog timer
5993
@param - base_addr : Base address of the watchdog module

api-tests/platform/drivers/watchdog/stm/pal_wd_stm.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/** @file
2-
* Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved.
2+
* Copyright (c) 2018 - 2025, Arm Limited or its affiliates. All rights reserved.
3+
* SPDX-License-Identifier : Apache-2.0
4+
*
5+
* Copyright (c) 2018 - 2025, STMicroelectronics.
36
* SPDX-License-Identifier : Apache-2.0
47
*
58
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -101,6 +104,7 @@ typedef struct {
101104

102105

103106
int pal_wd_stm_init(addr_t base_addr, uint32_t time_us, uint32_t timer_tick_us);
107+
int pal_wd_stm_wba_init(addr_t base_addr, uint32_t time_us, uint32_t timer_tick_us);
104108
int pal_wd_stm_enable(addr_t base_addr);
105109
int pal_wd_stm_disable(addr_t base_addr);
106110
int pal_wd_stm_is_enabled(addr_t base_addr);
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/** @file
2+
* Copyright (c) 2025, Arm Limited or its affiliates. All rights reserved.
3+
* SPDX-License-Identifier : Apache-2.0
4+
*
5+
* Copyright (c) 2025, STMicroelectronics.
6+
* SPDX-License-Identifier : Apache-2.0
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
**/
20+
21+
#ifndef _PAL_ATTESTATION_CONFIG_H_
22+
#define _PAL_ATTESTATION_CONFIG_H_
23+
24+
#define COSE_ALGORITHM_ES256 -7
25+
#define COSE_ALG_SHA256_PROPRIETARY -72000
26+
27+
#define USEFUL_BUF_MAKE_STACK_UB UsefulBuf_MAKE_STACK_UB
28+
29+
#define COSE_SIG_CONTEXT_STRING_SIGNATURE1 "Signature1"
30+
31+
/* Private value. Intentionally not documented for Doxygen.
32+
* This is the size allocated for the encoded protected headers. It
33+
* needs to be big enough for make_protected_header() to succeed. It
34+
* currently sized for one header with an algorithm ID up to 32 bits
35+
* long -- one byte for the wrapping map, one byte for the label, 5
36+
* bytes for the ID. If this is made accidentially too small, QCBOR will
37+
* only return an error, and not overrun any buffers.
38+
*
39+
* 9 extra bytes are added, rounding it up to 16 total, in case some
40+
* other protected header is to be added.
41+
*/
42+
#define T_COSE_SIGN1_MAX_PROT_HEADER (1+1+5+9)
43+
44+
/**
45+
* This is the size of the first part of the CBOR encoded TBS
46+
* bytes. It is around 20 bytes. See create_tbs_hash().
47+
*/
48+
#define T_COSE_SIZE_OF_TBS \
49+
1 + /* For opening the array */ \
50+
sizeof(COSE_SIG_CONTEXT_STRING_SIGNATURE1) + /* "Signature1" */ \
51+
2 + /* Overhead for encoding string */ \
52+
T_COSE_SIGN1_MAX_PROT_HEADER + /* entire protected headers */ \
53+
3 * (/* 3 NULL bstrs for fields not used */ \
54+
1 /* size of a NULL bstr */ \
55+
)
56+
#define NULL_USEFUL_BUF_C NULLUsefulBufC
57+
58+
#define ATTEST_PUBLIC_KEY_SLOT 4
59+
#define ECC_CURVE_SECP256R1_PULBIC_KEY_LENGTH (1 + 2 * PSA_BITS_TO_BYTES(256))
60+
61+
typedef struct {
62+
uint8_t *pubx_key;
63+
size_t pubx_key_size;
64+
uint8_t *puby_key;
65+
size_t puby_key_size;
66+
} ecc_key_t;
67+
68+
struct ecc_public_key_t {
69+
const uint8_t a;
70+
uint8_t public_key[]; /* X-coordinate || Y-coordinate */
71+
};
72+
73+
static const struct ecc_public_key_t attest_public_key = {
74+
/* Constant byte */
75+
0x04,
76+
/* X-coordinate */
77+
{0x79, 0xEB, 0xA9, 0x0E, 0x8B, 0xF4, 0x50, 0xA6,
78+
0x75, 0x15, 0x76, 0xAD, 0x45, 0x99, 0xB0, 0x7A,
79+
0xDF, 0x93, 0x8D, 0xA3, 0xBB, 0x0B, 0xD1, 0x7D,
80+
0x00, 0x36, 0xED, 0x49, 0xA2, 0xD0, 0xFC, 0x3F,
81+
/* Y-coordinate */
82+
0xBF, 0xCD, 0xFA, 0x89, 0x56, 0xB5, 0x68, 0xBF,
83+
0xDB, 0x86, 0x73, 0xE6, 0x48, 0xD8, 0xB5, 0x8D,
84+
0x92, 0x99, 0x55, 0xB1, 0x4A, 0x26, 0xC3, 0x08,
85+
0x0F, 0x34, 0x11, 0x7D, 0x97, 0x1D, 0x68, 0x64},
86+
};
87+
88+
static const uint8_t initial_attestation_public_x_key[] = {
89+
0x79, 0xEB, 0xA9, 0x0E, 0x8B, 0xF4, 0x50, 0xA6,
90+
0x75, 0x15, 0x76, 0xAD, 0x45, 0x99, 0xB0, 0x7A,
91+
0xDF, 0x93, 0x8D, 0xA3, 0xBB, 0x0B, 0xD1, 0x7D,
92+
0x00, 0x36, 0xED, 0x49, 0xA2, 0xD0, 0xFC, 0x3F
93+
};
94+
95+
static const uint8_t initial_attestation_public_y_key[] = {
96+
0xBF, 0xCD, 0xFA, 0x89, 0x56, 0xB5, 0x68, 0xBF,
97+
0xDB, 0x86, 0x73, 0xE6, 0x48, 0xD8, 0xB5, 0x8D,
98+
0x92, 0x99, 0x55, 0xB1, 0x4A, 0x26, 0xC3, 0x08,
99+
0x0F, 0x34, 0x11, 0x7D, 0x97, 0x1D, 0x68, 0x64
100+
};
101+
102+
/* Initialize the structure with given public key */
103+
static const ecc_key_t attest_key = {
104+
(uint8_t *)initial_attestation_public_x_key,
105+
sizeof(initial_attestation_public_x_key),
106+
(uint8_t *)initial_attestation_public_y_key,
107+
sizeof(initial_attestation_public_y_key)
108+
};
109+
110+
#endif /* _PAL_ATTESTATION_CONFIG_H_ */
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/** @file
2+
* Copyright (c) 2025, Arm Limited or its affiliates. All rights reserved.
3+
* SPDX-License-Identifier : Apache-2.0
4+
*
5+
* Copyright (c) 2025, STMicroelectronics.
6+
* SPDX-License-Identifier : Apache-2.0
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
**/
20+
21+
#ifndef _PAL_CONFIG_H_
22+
#define _PAL_CONFIG_H_
23+
24+
#include "pal_crypto_config.h"
25+
#include "pal_attestation_config.h"
26+
#include "pal_storage_config.h"
27+
28+
/* Define PSA test suite dependent macros for non-cmake build */
29+
#if !defined(PSA_CMAKE_BUILD)
30+
31+
/* Print verbosity = TEST */
32+
#define VERBOSE 3
33+
34+
/* NSPE or SPE VAL build? */
35+
#define VAL_NSPE_BUILD
36+
37+
/* NSPE or SPE TEST build? */
38+
#define NONSECURE_TEST_BUILD
39+
40+
/* If not defined, skip watchdog programming */
41+
#define WATCHDOG_AVAILABLE
42+
43+
/* Are Dynamic memory APIs available to secure partition? */
44+
#define SP_HEAP_MEM_SUPP
45+
46+
/* PSA Isolation level supported by platform */
47+
#define PLATFORM_PSA_ISOLATION_LEVEL 3
48+
#endif /* PSA_CMAKE_BUILD */
49+
50+
/* Version of crypto spec used in attestation */
51+
#define CRYPTO_VERSION_BETA3
52+
53+
/* Use hardcoded public key */
54+
#define PLATFORM_OVERRIDE_ATTEST_PK
55+
56+
/*
57+
* Include of PSA defined Header files
58+
*/
59+
#ifdef IPC
60+
/* psa/client.h: Contains the PSA Client API elements */
61+
#include "psa/client.h"
62+
63+
/*
64+
* psa_manifest/sid.h: Macro definitions derived from manifest files that map from RoT Service
65+
* names to Service IDs (SIDs). Partition manifest parse build tool must provide the implementation
66+
* of this file.
67+
*/
68+
#include "psa_manifest/sid.h"
69+
70+
/*
71+
* psa_manifest/pid.h: Secure Partition IDs
72+
* Macro definitions that map from Secure Partition names to Secure Partition IDs.
73+
* Partition manifest parse build tool must provide the implementation of this file.
74+
*/
75+
#include "psa_manifest/pid.h"
76+
#endif
77+
78+
#ifdef CRYPTO
79+
/* psa/crypto.h: Contains the PSA Crypto API elements */
80+
#include "psa/crypto.h"
81+
#endif
82+
83+
#if defined(INTERNAL_TRUSTED_STORAGE) || defined(STORAGE)
84+
/* psa/internal_trusted_storage.h: Contains the PSA ITS API elements */
85+
#include "psa/internal_trusted_storage.h"
86+
#endif
87+
88+
#if defined(PROTECTED_STORAGE) || defined(STORAGE)
89+
/* psa/protected_storage.h: Contains the PSA PS API elements */
90+
#include "psa/protected_storage.h"
91+
#endif
92+
93+
#ifdef INITIAL_ATTESTATION
94+
/* psa/initial_attestation.h: Contains the PSA Initial Attestation API elements */
95+
#include "psa/initial_attestation.h"
96+
#endif
97+
98+
#endif /* _PAL_CONFIG_H_ */

0 commit comments

Comments
 (0)