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.
pull/14652/head
Lingkai Dong 2021-05-14 15:31:06 +01:00 committed by Jaeden Amero
parent f275a83593
commit fa5df141d6
2 changed files with 106 additions and 0 deletions

View File

@ -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 */

View File

@ -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 */