blob: 8bc6f8a4906685a7982f7c6d3b6eb18a3e17bb59 [file] [log] [blame]
John Durkopb6f7afc2020-11-12 11:36:06 -08001/**
2 * \file check_crypto_config.h
3 *
4 * \brief Consistency checks for PSA configuration options
5 */
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/*
24 * It is recommended to include this file from your crypto_config.h
25 * in order to catch dependency issues early.
26 */
27
28#ifndef MBEDTLS_CHECK_CRYPTO_CONFIG_H
29#define MBEDTLS_CHECK_CRYPTO_CONFIG_H
30
Ronald Cron3d471812021-03-18 13:40:31 +010031#if defined(PSA_WANT_ALG_CCM) && \
Gilles Peskine449bd832023-01-11 14:50:10 +010032 !(defined(PSA_WANT_KEY_TYPE_AES) || \
33 defined(PSA_WANT_KEY_TYPE_CAMELLIA))
Ronald Cron3d471812021-03-18 13:40:31 +010034#error "PSA_WANT_ALG_CCM defined, but not all prerequisites"
35#endif
36
37#if defined(PSA_WANT_ALG_CMAC) && \
Gilles Peskine449bd832023-01-11 14:50:10 +010038 !(defined(PSA_WANT_KEY_TYPE_AES) || \
39 defined(PSA_WANT_KEY_TYPE_CAMELLIA) || \
40 defined(PSA_WANT_KEY_TYPE_DES))
Ronald Cron3d471812021-03-18 13:40:31 +010041#error "PSA_WANT_ALG_CMAC defined, but not all prerequisites"
42#endif
43
John Durkopb6f7afc2020-11-12 11:36:06 -080044#if defined(PSA_WANT_ALG_DETERMINISTIC_ECDSA) && \
Valerio Setti8bb57632023-05-26 13:48:07 +020045 !(defined(MBEDTLS_PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_LEGACY) || \
Gilles Peskine449bd832023-01-11 14:50:10 +010046 defined(PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY))
John Durkopb6f7afc2020-11-12 11:36:06 -080047#error "PSA_WANT_ALG_DETERMINISTIC_ECDSA defined, but not all prerequisites"
48#endif
49
50#if defined(PSA_WANT_ALG_ECDSA) && \
Valerio Setti8bb57632023-05-26 13:48:07 +020051 !(defined(MBEDTLS_PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_LEGACY) || \
Gilles Peskine449bd832023-01-11 14:50:10 +010052 defined(PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY))
John Durkopb6f7afc2020-11-12 11:36:06 -080053#error "PSA_WANT_ALG_ECDSA defined, but not all prerequisites"
54#endif
55
Ronald Cron3d471812021-03-18 13:40:31 +010056#if defined(PSA_WANT_ALG_GCM) && \
Gilles Peskine449bd832023-01-11 14:50:10 +010057 !(defined(PSA_WANT_KEY_TYPE_AES) || \
58 defined(PSA_WANT_KEY_TYPE_CAMELLIA))
Ronald Cron3d471812021-03-18 13:40:31 +010059#error "PSA_WANT_ALG_GCM defined, but not all prerequisites"
60#endif
61
John Durkopb6f7afc2020-11-12 11:36:06 -080062#if defined(PSA_WANT_ALG_RSA_PKCS1V15_CRYPT) && \
Valerio Setti8bb57632023-05-26 13:48:07 +020063 !(defined(MBEDTLS_PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_LEGACY) || \
Gilles Peskine449bd832023-01-11 14:50:10 +010064 defined(PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY))
John Durkopb6f7afc2020-11-12 11:36:06 -080065#error "PSA_WANT_ALG_RSA_PKCS1V15_CRYPT defined, but not all prerequisites"
66#endif
67
68#if defined(PSA_WANT_ALG_RSA_PKCS1V15_SIGN) && \
Valerio Setti8bb57632023-05-26 13:48:07 +020069 !(defined(MBEDTLS_PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_LEGACY) || \
Gilles Peskine449bd832023-01-11 14:50:10 +010070 defined(PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY))
John Durkopb6f7afc2020-11-12 11:36:06 -080071#error "PSA_WANT_ALG_RSA_PKCS1V15_SIGN defined, but not all prerequisites"
72#endif
73
74#if defined(PSA_WANT_ALG_RSA_OAEP) && \
Valerio Setti8bb57632023-05-26 13:48:07 +020075 !(defined(MBEDTLS_PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_LEGACY) || \
Gilles Peskine449bd832023-01-11 14:50:10 +010076 defined(PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY))
John Durkopb6f7afc2020-11-12 11:36:06 -080077#error "PSA_WANT_ALG_RSA_OAEP defined, but not all prerequisites"
78#endif
79
80#if defined(PSA_WANT_ALG_RSA_PSS) && \
Valerio Setti8bb57632023-05-26 13:48:07 +020081 !(defined(MBEDTLS_PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_LEGACY) || \
Gilles Peskine449bd832023-01-11 14:50:10 +010082 defined(PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY))
John Durkopb6f7afc2020-11-12 11:36:06 -080083#error "PSA_WANT_ALG_RSA_PSS defined, but not all prerequisites"
84#endif
85
Valerio Setti8bb57632023-05-26 13:48:07 +020086#if defined(MBEDTLS_PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_LEGACY) && \
John Durkop07cc04a2020-11-16 22:08:34 -080087 !defined(PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY)
Valerio Setti8bb57632023-05-26 13:48:07 +020088#error "MBEDTLS_PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_LEGACY defined, but not all prerequisites"
John Durkop07cc04a2020-11-16 22:08:34 -080089#endif
90
Andrzej Kurekcccb0442022-08-19 03:42:11 -040091#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && defined(MBEDTLS_USE_PSA_CRYPTO) && \
Gilles Peskine449bd832023-01-11 14:50:10 +010092 !(defined(PSA_WANT_ALG_SHA_1) || defined(PSA_WANT_ALG_SHA_256) || defined(PSA_WANT_ALG_SHA_512))
Andrzej Kurek7e16ce32022-08-17 16:19:39 -040093#error "MBEDTLS_SSL_PROTO_TLS1_2 defined, but not all prerequisites"
94#endif
95
Andrzej Kurekd60907b2022-09-14 10:02:30 -040096#if defined(PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS) && \
97 !defined(PSA_WANT_ALG_SHA_256)
98#error "PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS defined, but not all prerequisites"
99#endif
100
John Durkopb6f7afc2020-11-12 11:36:06 -0800101#endif /* MBEDTLS_CHECK_CRYPTO_CONFIG_H */