Path: blob/master/thirdparty/mbedtls/include/psa/crypto_platform.h
9904 views
/**1* \file psa/crypto_platform.h2*3* \brief PSA cryptography module: Mbed TLS platform definitions4*5* \note This file may not be included directly. Applications must6* include psa/crypto.h.7*8* This file contains platform-dependent type definitions.9*10* In implementations with isolation between the application and the11* cryptography module, implementers should take care to ensure that12* the definitions that are exposed to applications match what the13* module implements.14*/15/*16* Copyright The Mbed TLS Contributors17* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later18*/1920#ifndef PSA_CRYPTO_PLATFORM_H21#define PSA_CRYPTO_PLATFORM_H22#include "mbedtls/private_access.h"2324/*25* Include the build-time configuration information header. Here, we do not26* include `"mbedtls/build_info.h"` directly but `"psa/build_info.h"`, which27* is basically just an alias to it. This is to ease the maintenance of the28* TF-PSA-Crypto repository which has a different build system and29* configuration.30*/31#include "psa/build_info.h"3233/* PSA requires several types which C99 provides in stdint.h. */34#include <stdint.h>3536#if defined(MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER)3738/* Building for the PSA Crypto service on a PSA platform, a key owner is a PSA39* partition identifier.40*41* The function psa_its_identifier_of_slot() in psa_crypto_storage.c that42* translates a key identifier to a key storage file name assumes that43* mbedtls_key_owner_id_t is a 32-bit integer. This function thus needs44* reworking if mbedtls_key_owner_id_t is not defined as a 32-bit integer45* here anymore.46*/47typedef int32_t mbedtls_key_owner_id_t;4849/** Compare two key owner identifiers.50*51* \param id1 First key owner identifier.52* \param id2 Second key owner identifier.53*54* \return Non-zero if the two key owner identifiers are equal, zero otherwise.55*/56static inline int mbedtls_key_owner_id_equal(mbedtls_key_owner_id_t id1,57mbedtls_key_owner_id_t id2)58{59return id1 == id2;60}6162#endif /* MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER */6364/*65* When MBEDTLS_PSA_CRYPTO_SPM is defined, the code is being built for SPM66* (Secure Partition Manager) integration which separates the code into two67* parts: NSPE (Non-Secure Processing Environment) and SPE (Secure Processing68* Environment). When building for the SPE, an additional header file should be69* included.70*/71#if defined(MBEDTLS_PSA_CRYPTO_SPM)72#define PSA_CRYPTO_SECURE 173#include "crypto_spe.h"74#endif // MBEDTLS_PSA_CRYPTO_SPM7576#if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)77/** The type of the context passed to mbedtls_psa_external_get_random().78*79* Mbed TLS initializes the context to all-bits-zero before calling80* mbedtls_psa_external_get_random() for the first time.81*82* The definition of this type in the Mbed TLS source code is for83* demonstration purposes. Implementers of mbedtls_psa_external_get_random()84* are expected to replace it with a custom definition.85*/86typedef struct {87uintptr_t MBEDTLS_PRIVATE(opaque)[2];88} mbedtls_psa_external_random_context_t;89#endif /* MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG */9091#if defined(MBEDTLS_PSA_CRYPTO_CLIENT) && !defined(MBEDTLS_PSA_CRYPTO_C)92/** The type of the client handle used in context structures93*94* When a client view of the multipart context structures is required,95* this handle is used to keep a mapping with the service side of the96* context which contains the actual data.97*/98typedef uint32_t mbedtls_psa_client_handle_t;99#endif100101#endif /* PSA_CRYPTO_PLATFORM_H */102103104