Manuel Pégourié-Gonnard | 5508673 | 2022-07-07 12:17:55 +0200 | [diff] [blame] | 1 | /** |
| 2 | * Internal macros for parts of the code governed by MBEDTLS_USE_PSA_CRYPTO. |
| 3 | * These macros allow checking if an algorithm is available, either via the |
| 4 | * legacy API or the PSA Crypto API, depending on MBEDTLS_USE_PSA_CRYPTO. |
| 5 | * When possible, they're named after the corresponding PSA_WANT_ macro. |
| 6 | * |
| 7 | * Copyright The Mbed TLS Contributors |
| 8 | * SPDX-License-Identifier: Apache-2.0 |
| 9 | * |
| 10 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 11 | * not use this file except in compliance with the License. |
| 12 | * You may obtain a copy of the License at |
| 13 | * |
| 14 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 15 | * |
| 16 | * Unless required by applicable law or agreed to in writing, software |
| 17 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 18 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 19 | * See the License for the specific language governing permissions and |
| 20 | * limitations under the License. |
| 21 | */ |
| 22 | |
| 23 | #ifndef MBEDTLS_USE_PSA_HELPERS_H |
| 24 | #define MBEDTLS_USE_PSA_HELPERS_H |
| 25 | |
| 26 | #include "common.h" |
| 27 | |
| 28 | /* Hash algorithms */ |
| 29 | #if ( !defined(MBEDTLS_USE_PSA_CRYPTO) && defined(MBEDTLS_MD5_C) ) || \ |
| 30 | ( defined(MBEDTLS_USE_PSA_CRYPTO) && defined(PSA_WANT_ALG_MD5) ) |
| 31 | #define MBEDTLS_USE_PSA_WANT_ALG_MD5 |
| 32 | #endif |
| 33 | #if ( !defined(MBEDTLS_USE_PSA_CRYPTO) && defined(MBEDTLS_RIPEMD160_C) ) || \ |
| 34 | ( defined(MBEDTLS_USE_PSA_CRYPTO) && defined(PSA_WANT_ALG_RIPEMD160) ) |
| 35 | #define MBEDTLS_USE_PSA_WANT_ALG_RIPEMD160 |
| 36 | #endif |
| 37 | #if ( !defined(MBEDTLS_USE_PSA_CRYPTO) && defined(MBEDTLS_SHA1_C) ) || \ |
| 38 | ( defined(MBEDTLS_USE_PSA_CRYPTO) && defined(PSA_WANT_ALG_SHA_1) ) |
| 39 | #define MBEDTLS_USE_PSA_WANT_ALG_SHA_1 |
| 40 | #endif |
| 41 | #if ( !defined(MBEDTLS_USE_PSA_CRYPTO) && defined(MBEDTLS_SHA224_C) ) || \ |
| 42 | ( defined(MBEDTLS_USE_PSA_CRYPTO) && defined(PSA_WANT_ALG_SHA_224) ) |
| 43 | #define MBEDTLS_USE_PSA_WANT_ALG_SHA_224 |
| 44 | #endif |
| 45 | #if ( !defined(MBEDTLS_USE_PSA_CRYPTO) && defined(MBEDTLS_SHA256_C) ) || \ |
| 46 | ( defined(MBEDTLS_USE_PSA_CRYPTO) && defined(PSA_WANT_ALG_SHA_256) ) |
| 47 | #define MBEDTLS_USE_PSA_WANT_ALG_SHA_256 |
| 48 | #endif |
| 49 | #if ( !defined(MBEDTLS_USE_PSA_CRYPTO) && defined(MBEDTLS_SHA384_C) ) || \ |
| 50 | ( defined(MBEDTLS_USE_PSA_CRYPTO) && defined(PSA_WANT_ALG_SHA_384) ) |
| 51 | #define MBEDTLS_USE_PSA_WANT_ALG_SHA_384 |
| 52 | #endif |
| 53 | #if ( !defined(MBEDTLS_USE_PSA_CRYPTO) && defined(MBEDTLS_SHA512_C) ) || \ |
| 54 | ( defined(MBEDTLS_USE_PSA_CRYPTO) && defined(PSA_WANT_ALG_SHA_512) ) |
| 55 | #define MBEDTLS_USE_PSA_WANT_ALG_SHA_512 |
| 56 | #endif |
| 57 | |
| 58 | #endif /* MBEDTLS_USE_PSA_HELPERS_H */ |