From 50b449776df11cac06347e8ef1af5dae701a0e3a Mon Sep 17 00:00:00 2001 From: laurenw-arm Date: Thu, 21 Apr 2022 16:53:37 -0500 Subject: [PATCH] feat(arm): retrieve the right ROTPK for cca The cca chain of trust involves 3 root-of-trust public keys: - The CCA components ROTPK. - The platform owner ROTPK (PROTPK). - The secure world ROTPK (SWD_ROTPK). Use the cookie argument as a key ID for plat_get_rotpk_info() to return the appropriate one. Signed-off-by: Lauren Wehrmeister Change-Id: Ieaae5b0bc4384dd12d0b616596596b031179044a --- .../arm/board/common/board_arm_trusted_boot.c | 50 ++++++++++++++++--- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/plat/arm/board/common/board_arm_trusted_boot.c b/plat/arm/board/common/board_arm_trusted_boot.c index 66cc3e949..714c444e7 100644 --- a/plat/arm/board/common/board_arm_trusted_boot.c +++ b/plat/arm/board/common/board_arm_trusted_boot.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2015-2022, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -13,18 +13,20 @@ #include #include #include -#include -#include #include #include -#include - -#if defined(ARM_COT_tbbr) -#include +#if defined(ARM_COT_cca) +#include #elif defined(ARM_COT_dualroot) #include +#elif defined(ARM_COT_tbbr) +#include #endif +#include +#include +#include + #if !ARM_CRYPTOCELL_INTEG #if !ARM_ROTPK_LOCATION_ID #error "ARM_ROTPK_LOCATION_ID not defined" @@ -181,6 +183,40 @@ int arm_get_rotpk_info(void *cookie, void **key_ptr, unsigned int *key_len, return 1; } } + +#elif defined(ARM_COT_cca) + +int arm_get_rotpk_info(void *cookie, void **key_ptr, unsigned int *key_len, + unsigned int *flags) +{ + /* + * Return the right root of trust key hash based on the cookie value: + * - NULL means the primary ROTPK. + * - Otherwise, interpret cookie as the OID of the certificate + * extension containing the key. + */ + if (cookie == NULL) { + return get_rotpk_info(key_ptr, key_len, flags); + } else if (strcmp(cookie, PROT_PK_OID) == 0) { + extern unsigned char arm_protpk_hash[]; + extern unsigned char arm_protpk_hash_end[]; + *key_ptr = arm_protpk_hash; + *key_len = arm_protpk_hash_end - arm_protpk_hash; + *flags = ROTPK_IS_HASH; + return 0; + } else if (strcmp(cookie, SWD_ROT_PK_OID) == 0) { + extern unsigned char arm_swd_rotpk_hash[]; + extern unsigned char arm_swd_rotpk_hash_end[]; + *key_ptr = arm_swd_rotpk_hash; + *key_len = arm_swd_rotpk_hash_end - arm_swd_rotpk_hash; + *flags = ROTPK_IS_HASH; + return 0; + } else { + /* Invalid key ID. */ + return 1; + } +} + #endif /* -- 2.39.5