Gilles Peskine | e59236f | 2018-01-27 23:32:46 +0100 | [diff] [blame] | 1 | /** |
| 2 | * \file psa/crypto_platform.h |
| 3 | * |
Jaeden Amero | 95d8438 | 2019-05-30 13:14:00 +0100 | [diff] [blame] | 4 | * \brief PSA cryptography module: Mbed TLS platform definitions |
Gilles Peskine | 07c91f5 | 2018-06-28 18:02:53 +0200 | [diff] [blame] | 5 | * |
| 6 | * \note This file may not be included directly. Applications must |
| 7 | * include psa/crypto.h. |
| 8 | * |
| 9 | * This file contains platform-dependent type definitions. |
| 10 | * |
| 11 | * In implementations with isolation between the application and the |
| 12 | * cryptography module, implementers should take care to ensure that |
| 13 | * the definitions that are exposed to applications match what the |
| 14 | * module implements. |
Gilles Peskine | e59236f | 2018-01-27 23:32:46 +0100 | [diff] [blame] | 15 | */ |
| 16 | /* |
Bence Szépkúti | 1e14827 | 2020-08-07 13:07:28 +0200 | [diff] [blame] | 17 | * Copyright The Mbed TLS Contributors |
Gilles Peskine | e59236f | 2018-01-27 23:32:46 +0100 | [diff] [blame] | 18 | * SPDX-License-Identifier: Apache-2.0 |
| 19 | * |
| 20 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 21 | * not use this file except in compliance with the License. |
| 22 | * You may obtain a copy of the License at |
| 23 | * |
| 24 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 25 | * |
| 26 | * Unless required by applicable law or agreed to in writing, software |
| 27 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 28 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 29 | * See the License for the specific language governing permissions and |
| 30 | * limitations under the License. |
Gilles Peskine | e59236f | 2018-01-27 23:32:46 +0100 | [diff] [blame] | 31 | */ |
| 32 | |
| 33 | #ifndef PSA_CRYPTO_PLATFORM_H |
| 34 | #define PSA_CRYPTO_PLATFORM_H |
| 35 | |
| 36 | /* Include the Mbed TLS configuration file, the way Mbed TLS does it |
| 37 | * in each of its header files. */ |
| 38 | #if !defined(MBEDTLS_CONFIG_FILE) |
Jaeden Amero | d58a00d | 2019-06-07 11:49:59 +0100 | [diff] [blame] | 39 | #include "mbedtls/config.h" |
Gilles Peskine | e59236f | 2018-01-27 23:32:46 +0100 | [diff] [blame] | 40 | #else |
| 41 | #include MBEDTLS_CONFIG_FILE |
| 42 | #endif |
| 43 | |
| 44 | /* PSA requires several types which C99 provides in stdint.h. */ |
| 45 | #include <stdint.h> |
| 46 | |
Ronald Cron | ecfb237 | 2020-07-23 17:13:42 +0200 | [diff] [blame^] | 47 | #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ |
| 48 | !defined(inline) && !defined(__cplusplus) |
| 49 | #define inline __inline |
| 50 | #endif |
| 51 | |
Gilles Peskine | f535eb2 | 2018-11-30 14:08:36 +0100 | [diff] [blame] | 52 | /* Integral type representing a key handle. */ |
| 53 | typedef uint16_t psa_key_handle_t; |
| 54 | |
Ronald Cron | 71016a9 | 2020-08-28 19:01:50 +0200 | [diff] [blame] | 55 | #if defined(MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER) |
Gilles Peskine | 69d7c8b | 2019-02-19 14:00:31 +0100 | [diff] [blame] | 56 | |
Gilles Peskine | 572f067 | 2019-02-19 14:16:17 +0100 | [diff] [blame] | 57 | /* Building for the PSA Crypto service on a PSA platform. */ |
| 58 | /* A key owner is a PSA partition identifier. */ |
Ronald Cron | 72f65fc | 2020-09-01 15:50:17 +0200 | [diff] [blame] | 59 | typedef int32_t mbedtls_key_owner_id_t; |
Ronald Cron | ecfb237 | 2020-07-23 17:13:42 +0200 | [diff] [blame^] | 60 | |
| 61 | /** Compare two key owner identifiers. |
| 62 | * |
| 63 | * \param id1 First key owner identifier. |
| 64 | * \param id2 Second key owner identifier. |
| 65 | * |
| 66 | * \return Non-zero if the two key owner identifiers are equal, zero otherwise. |
| 67 | */ |
| 68 | static inline int mbedtls_key_owner_id_equal( mbedtls_key_owner_id_t id1, |
| 69 | mbedtls_key_owner_id_t id2 ) |
| 70 | { |
| 71 | return( id1 == id2 ); |
| 72 | } |
Gilles Peskine | 572f067 | 2019-02-19 14:16:17 +0100 | [diff] [blame] | 73 | |
Ronald Cron | 71016a9 | 2020-08-28 19:01:50 +0200 | [diff] [blame] | 74 | #endif /* MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER */ |
Gilles Peskine | 69d7c8b | 2019-02-19 14:00:31 +0100 | [diff] [blame] | 75 | |
Gilles Peskine | e59236f | 2018-01-27 23:32:46 +0100 | [diff] [blame] | 76 | #endif /* PSA_CRYPTO_PLATFORM_H */ |