From fa5df141d6bb47ce261610b3e0ae86ec5924a771 Mon Sep 17 00:00:00 2001 From: Lingkai Dong Date: Fri, 14 May 2021 15:31:06 +0100 Subject: [PATCH] psa: Add mbedtls_svc_key_id.h In order for Mbed TLS to use the PSA Crypto API, definitions of `MBEDTLS_SVC_KEY_ID_INIT`, `mbedtls_svc_key_id_t` and `mbedtls_svc_key_id_is_null()` need to be present but are not provided by the PSA headers from TF-M. To solve this issue, this commit copies those definitions from Mbed TLS's original `psa/crypto_types.h` and `psa/crypto_values.h` into a separate `mbedtls_svc_key_id.h` for TF-M PSA. --- .../include/mbedtls_svc_key_id.h | 53 +++++++++++++++++++ .../include/mbedtls_svc_key_id.h | 53 +++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/include/mbedtls_svc_key_id.h create mode 100644 platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_V1_0/include/mbedtls_svc_key_id.h diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/include/mbedtls_svc_key_id.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/include/mbedtls_svc_key_id.h new file mode 100644 index 0000000000..9679b914bb --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/include/mbedtls_svc_key_id.h @@ -0,0 +1,53 @@ +/** + * \file mbedtls_svc_key_id.h + * + * Excerpted from Mbed TLS for internal use by Mbed TLS's PSK key exchange to + * interface with generic PSA Crypto implementations. + * + */ +/* + * Copyright The Mbed TLS Contributors + * 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 MBEDTLS_SVC_KEY_ID_H +#define MBEDTLS_SVC_KEY_ID_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef psa_key_id_t mbedtls_svc_key_id_t; + +#define MBEDTLS_SVC_KEY_ID_INIT ( (psa_key_id_t)0 ) + +/** Check whether a key identifier is null. + * + * \param key Key identifier. + * + * \return Non-zero if the key identifier is null, zero otherwise. + */ +static inline int mbedtls_svc_key_id_is_null( mbedtls_svc_key_id_t key ) +{ + return( key == 0 ); +} + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif /* MBEDTLS_SVC_KEY_ID_H */ diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_V1_0/include/mbedtls_svc_key_id.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_V1_0/include/mbedtls_svc_key_id.h new file mode 100644 index 0000000000..9679b914bb --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_V1_0/include/mbedtls_svc_key_id.h @@ -0,0 +1,53 @@ +/** + * \file mbedtls_svc_key_id.h + * + * Excerpted from Mbed TLS for internal use by Mbed TLS's PSK key exchange to + * interface with generic PSA Crypto implementations. + * + */ +/* + * Copyright The Mbed TLS Contributors + * 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 MBEDTLS_SVC_KEY_ID_H +#define MBEDTLS_SVC_KEY_ID_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef psa_key_id_t mbedtls_svc_key_id_t; + +#define MBEDTLS_SVC_KEY_ID_INIT ( (psa_key_id_t)0 ) + +/** Check whether a key identifier is null. + * + * \param key Key identifier. + * + * \return Non-zero if the key identifier is null, zero otherwise. + */ +static inline int mbedtls_svc_key_id_is_null( mbedtls_svc_key_id_t key ) +{ + return( key == 0 ); +} + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif /* MBEDTLS_SVC_KEY_ID_H */