blob: e9a133590c8e98d7eed3d5a332fc830798d1af9b [file] [log] [blame]
Manuel Pégourié-Gonnard55086732022-07-07 12:17:55 +02001/**
2 * Internal macros for parts of the code governed by MBEDTLS_USE_PSA_CRYPTO.
Manuel Pégourié-Gonnard043c8c52022-07-08 10:33:44 +02003 * Some 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 * Other macros provide max sizes or similar information in a USE_PSA-aware
7 * way; they're name after a similar constant from the legacy API or PSA.
Manuel Pégourié-Gonnard55086732022-07-07 12:17:55 +02008 *
9 * Copyright The Mbed TLS Contributors
10 * SPDX-License-Identifier: Apache-2.0
11 *
12 * Licensed under the Apache License, Version 2.0 (the "License"); you may
13 * not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
20 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 */
24
25#ifndef MBEDTLS_USE_PSA_HELPERS_H
26#define MBEDTLS_USE_PSA_HELPERS_H
27
28#include "common.h"
29
30/* Hash algorithms */
31#if ( !defined(MBEDTLS_USE_PSA_CRYPTO) && defined(MBEDTLS_MD5_C) ) || \
32 ( defined(MBEDTLS_USE_PSA_CRYPTO) && defined(PSA_WANT_ALG_MD5) )
33#define MBEDTLS_USE_PSA_WANT_ALG_MD5
34#endif
35#if ( !defined(MBEDTLS_USE_PSA_CRYPTO) && defined(MBEDTLS_RIPEMD160_C) ) || \
36 ( defined(MBEDTLS_USE_PSA_CRYPTO) && defined(PSA_WANT_ALG_RIPEMD160) )
37#define MBEDTLS_USE_PSA_WANT_ALG_RIPEMD160
38#endif
39#if ( !defined(MBEDTLS_USE_PSA_CRYPTO) && defined(MBEDTLS_SHA1_C) ) || \
40 ( defined(MBEDTLS_USE_PSA_CRYPTO) && defined(PSA_WANT_ALG_SHA_1) )
41#define MBEDTLS_USE_PSA_WANT_ALG_SHA_1
42#endif
43#if ( !defined(MBEDTLS_USE_PSA_CRYPTO) && defined(MBEDTLS_SHA224_C) ) || \
44 ( defined(MBEDTLS_USE_PSA_CRYPTO) && defined(PSA_WANT_ALG_SHA_224) )
45#define MBEDTLS_USE_PSA_WANT_ALG_SHA_224
46#endif
47#if ( !defined(MBEDTLS_USE_PSA_CRYPTO) && defined(MBEDTLS_SHA256_C) ) || \
48 ( defined(MBEDTLS_USE_PSA_CRYPTO) && defined(PSA_WANT_ALG_SHA_256) )
49#define MBEDTLS_USE_PSA_WANT_ALG_SHA_256
50#endif
51#if ( !defined(MBEDTLS_USE_PSA_CRYPTO) && defined(MBEDTLS_SHA384_C) ) || \
52 ( defined(MBEDTLS_USE_PSA_CRYPTO) && defined(PSA_WANT_ALG_SHA_384) )
53#define MBEDTLS_USE_PSA_WANT_ALG_SHA_384
54#endif
55#if ( !defined(MBEDTLS_USE_PSA_CRYPTO) && defined(MBEDTLS_SHA512_C) ) || \
56 ( defined(MBEDTLS_USE_PSA_CRYPTO) && defined(PSA_WANT_ALG_SHA_512) )
57#define MBEDTLS_USE_PSA_WANT_ALG_SHA_512
58#endif
59
Manuel Pégourié-Gonnard043c8c52022-07-08 10:33:44 +020060/* Hash information */
61#if defined(MBEDTLS_USE_PSA_CRYPTO)
62#define MBEDTLS_USE_PSA_MD_MAX_SIZE PSA_HASH_MAX_SIZE
63#else
64#define MBEDTLS_USE_PSA_MD_MAX_SIZE MBEDTLS_MD_MAX_SIZE
65#endif
66
Manuel Pégourié-Gonnard55086732022-07-07 12:17:55 +020067#endif /* MBEDTLS_USE_PSA_HELPERS_H */