1a8e1175bSopenharmony_ci/** 2a8e1175bSopenharmony_ci * \file check_crypto_config.h 3a8e1175bSopenharmony_ci * 4a8e1175bSopenharmony_ci * \brief Consistency checks for PSA configuration options 5a8e1175bSopenharmony_ci */ 6a8e1175bSopenharmony_ci/* 7a8e1175bSopenharmony_ci * Copyright The Mbed TLS Contributors 8a8e1175bSopenharmony_ci * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 9a8e1175bSopenharmony_ci */ 10a8e1175bSopenharmony_ci 11a8e1175bSopenharmony_ci/* 12a8e1175bSopenharmony_ci * It is recommended to include this file from your crypto_config.h 13a8e1175bSopenharmony_ci * in order to catch dependency issues early. 14a8e1175bSopenharmony_ci */ 15a8e1175bSopenharmony_ci 16a8e1175bSopenharmony_ci#ifndef MBEDTLS_CHECK_CRYPTO_CONFIG_H 17a8e1175bSopenharmony_ci#define MBEDTLS_CHECK_CRYPTO_CONFIG_H 18a8e1175bSopenharmony_ci 19a8e1175bSopenharmony_ci#if defined(PSA_WANT_ALG_CCM) && \ 20a8e1175bSopenharmony_ci !(defined(PSA_WANT_KEY_TYPE_AES) || \ 21a8e1175bSopenharmony_ci defined(PSA_WANT_KEY_TYPE_CAMELLIA)) 22a8e1175bSopenharmony_ci#error "PSA_WANT_ALG_CCM defined, but not all prerequisites" 23a8e1175bSopenharmony_ci#endif 24a8e1175bSopenharmony_ci 25a8e1175bSopenharmony_ci#if defined(PSA_WANT_ALG_CMAC) && \ 26a8e1175bSopenharmony_ci !(defined(PSA_WANT_KEY_TYPE_AES) || \ 27a8e1175bSopenharmony_ci defined(PSA_WANT_KEY_TYPE_CAMELLIA) || \ 28a8e1175bSopenharmony_ci defined(PSA_WANT_KEY_TYPE_DES)) 29a8e1175bSopenharmony_ci#error "PSA_WANT_ALG_CMAC defined, but not all prerequisites" 30a8e1175bSopenharmony_ci#endif 31a8e1175bSopenharmony_ci 32a8e1175bSopenharmony_ci#if defined(PSA_WANT_ALG_DETERMINISTIC_ECDSA) && \ 33a8e1175bSopenharmony_ci !(defined(PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC) || \ 34a8e1175bSopenharmony_ci defined(PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY)) 35a8e1175bSopenharmony_ci#error "PSA_WANT_ALG_DETERMINISTIC_ECDSA defined, but not all prerequisites" 36a8e1175bSopenharmony_ci#endif 37a8e1175bSopenharmony_ci 38a8e1175bSopenharmony_ci#if defined(PSA_WANT_ALG_ECDSA) && \ 39a8e1175bSopenharmony_ci !(defined(PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC) || \ 40a8e1175bSopenharmony_ci defined(PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY)) 41a8e1175bSopenharmony_ci#error "PSA_WANT_ALG_ECDSA defined, but not all prerequisites" 42a8e1175bSopenharmony_ci#endif 43a8e1175bSopenharmony_ci 44a8e1175bSopenharmony_ci#if defined(PSA_WANT_ALG_GCM) && \ 45a8e1175bSopenharmony_ci !(defined(PSA_WANT_KEY_TYPE_AES) || \ 46a8e1175bSopenharmony_ci defined(PSA_WANT_KEY_TYPE_CAMELLIA)) 47a8e1175bSopenharmony_ci#error "PSA_WANT_ALG_GCM defined, but not all prerequisites" 48a8e1175bSopenharmony_ci#endif 49a8e1175bSopenharmony_ci 50a8e1175bSopenharmony_ci#if defined(PSA_WANT_ALG_RSA_PKCS1V15_CRYPT) && \ 51a8e1175bSopenharmony_ci !(defined(PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC) || \ 52a8e1175bSopenharmony_ci defined(PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY)) 53a8e1175bSopenharmony_ci#error "PSA_WANT_ALG_RSA_PKCS1V15_CRYPT defined, but not all prerequisites" 54a8e1175bSopenharmony_ci#endif 55a8e1175bSopenharmony_ci 56a8e1175bSopenharmony_ci#if defined(PSA_WANT_ALG_RSA_PKCS1V15_SIGN) && \ 57a8e1175bSopenharmony_ci !(defined(PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC) || \ 58a8e1175bSopenharmony_ci defined(PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY)) 59a8e1175bSopenharmony_ci#error "PSA_WANT_ALG_RSA_PKCS1V15_SIGN defined, but not all prerequisites" 60a8e1175bSopenharmony_ci#endif 61a8e1175bSopenharmony_ci 62a8e1175bSopenharmony_ci#if defined(PSA_WANT_ALG_RSA_OAEP) && \ 63a8e1175bSopenharmony_ci !(defined(PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC) || \ 64a8e1175bSopenharmony_ci defined(PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY)) 65a8e1175bSopenharmony_ci#error "PSA_WANT_ALG_RSA_OAEP defined, but not all prerequisites" 66a8e1175bSopenharmony_ci#endif 67a8e1175bSopenharmony_ci 68a8e1175bSopenharmony_ci#if defined(PSA_WANT_ALG_RSA_PSS) && \ 69a8e1175bSopenharmony_ci !(defined(PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC) || \ 70a8e1175bSopenharmony_ci defined(PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY)) 71a8e1175bSopenharmony_ci#error "PSA_WANT_ALG_RSA_PSS defined, but not all prerequisites" 72a8e1175bSopenharmony_ci#endif 73a8e1175bSopenharmony_ci 74a8e1175bSopenharmony_ci#if (defined(PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC) || \ 75a8e1175bSopenharmony_ci defined(PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT) || \ 76a8e1175bSopenharmony_ci defined(PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT) || \ 77a8e1175bSopenharmony_ci defined(PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_GENERATE) || \ 78a8e1175bSopenharmony_ci defined(PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE)) && \ 79a8e1175bSopenharmony_ci !defined(PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY) 80a8e1175bSopenharmony_ci#error "PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_xxx defined, but not all prerequisites" 81a8e1175bSopenharmony_ci#endif 82a8e1175bSopenharmony_ci 83a8e1175bSopenharmony_ci#if (defined(PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC) || \ 84a8e1175bSopenharmony_ci defined(PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT) || \ 85a8e1175bSopenharmony_ci defined(PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT) || \ 86a8e1175bSopenharmony_ci defined(PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_GENERATE)) && \ 87a8e1175bSopenharmony_ci !defined(PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY) 88a8e1175bSopenharmony_ci#error "PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_xxx defined, but not all prerequisites" 89a8e1175bSopenharmony_ci#endif 90a8e1175bSopenharmony_ci 91a8e1175bSopenharmony_ci#if (defined(PSA_WANT_KEY_TYPE_DH_KEY_PAIR_BASIC) || \ 92a8e1175bSopenharmony_ci defined(PSA_WANT_KEY_TYPE_DH_KEY_PAIR_IMPORT) || \ 93a8e1175bSopenharmony_ci defined(PSA_WANT_KEY_TYPE_DH_KEY_PAIR_EXPORT) || \ 94a8e1175bSopenharmony_ci defined(PSA_WANT_KEY_TYPE_DH_KEY_PAIR_GENERATE)) && \ 95a8e1175bSopenharmony_ci !defined(PSA_WANT_KEY_TYPE_DH_PUBLIC_KEY) 96a8e1175bSopenharmony_ci#error "PSA_WANT_KEY_TYPE_DH_KEY_PAIR_xxx defined, but not all prerequisites" 97a8e1175bSopenharmony_ci#endif 98a8e1175bSopenharmony_ci 99a8e1175bSopenharmony_ci#if defined(PSA_WANT_KEY_TYPE_ECC_KEY_PAIR) 100a8e1175bSopenharmony_ci#if defined(MBEDTLS_DEPRECATED_REMOVED) 101a8e1175bSopenharmony_ci#error "PSA_WANT_KEY_TYPE_ECC_KEY_PAIR is deprecated and will be removed in a \ 102a8e1175bSopenharmony_ci future version of Mbed TLS. Please switch to new PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_xxx \ 103a8e1175bSopenharmony_ci symbols, where xxx can be: USE, IMPORT, EXPORT, GENERATE, DERIVE" 104a8e1175bSopenharmony_ci#elif defined(MBEDTLS_DEPRECATED_WARNING) 105a8e1175bSopenharmony_ci#warning "PSA_WANT_KEY_TYPE_ECC_KEY_PAIR is deprecated and will be removed in a \ 106a8e1175bSopenharmony_ci future version of Mbed TLS. Please switch to new PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_xxx \ 107a8e1175bSopenharmony_ci symbols, where xxx can be: USE, IMPORT, EXPORT, GENERATE, DERIVE" 108a8e1175bSopenharmony_ci#endif /* MBEDTLS_DEPRECATED_WARNING */ 109a8e1175bSopenharmony_ci#endif /* PSA_WANT_KEY_TYPE_ECC_KEY_PAIR */ 110a8e1175bSopenharmony_ci 111a8e1175bSopenharmony_ci#if defined(PSA_WANT_KEY_TYPE_RSA_KEY_PAIR) 112a8e1175bSopenharmony_ci#if defined(MBEDTLS_DEPRECATED_REMOVED) 113a8e1175bSopenharmony_ci#error "PSA_WANT_KEY_TYPE_RSA_KEY_PAIR is deprecated and will be removed in a \ 114a8e1175bSopenharmony_ci future version of Mbed TLS. Please switch to new PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_xxx \ 115a8e1175bSopenharmony_ci symbols, where xxx can be: USE, IMPORT, EXPORT, GENERATE, DERIVE" 116a8e1175bSopenharmony_ci#elif defined(MBEDTLS_DEPRECATED_WARNING) 117a8e1175bSopenharmony_ci#warning "PSA_WANT_KEY_TYPE_RSA_KEY_PAIR is deprecated and will be removed in a \ 118a8e1175bSopenharmony_ci future version of Mbed TLS. Please switch to new PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_xxx \ 119a8e1175bSopenharmony_ci symbols, where xxx can be: USE, IMPORT, EXPORT, GENERATE, DERIVE" 120a8e1175bSopenharmony_ci#endif /* MBEDTLS_DEPRECATED_WARNING */ 121a8e1175bSopenharmony_ci#endif /* PSA_WANT_KEY_TYPE_RSA_KEY_PAIR */ 122a8e1175bSopenharmony_ci 123a8e1175bSopenharmony_ci#if defined(PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_DERIVE) 124a8e1175bSopenharmony_ci#error "PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_DERIVE defined, but feature is not supported" 125a8e1175bSopenharmony_ci#endif 126a8e1175bSopenharmony_ci 127a8e1175bSopenharmony_ci#if defined(PSA_WANT_KEY_TYPE_DH_KEY_PAIR_DERIVE) 128a8e1175bSopenharmony_ci#error "PSA_WANT_KEY_TYPE_DH_KEY_PAIR_DERIVE defined, but feature is not supported" 129a8e1175bSopenharmony_ci#endif 130a8e1175bSopenharmony_ci 131a8e1175bSopenharmony_ci#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && defined(MBEDTLS_USE_PSA_CRYPTO) && \ 132a8e1175bSopenharmony_ci !(defined(PSA_WANT_ALG_SHA_1) || defined(PSA_WANT_ALG_SHA_256) || defined(PSA_WANT_ALG_SHA_512)) 133a8e1175bSopenharmony_ci#error "MBEDTLS_SSL_PROTO_TLS1_2 defined, but not all prerequisites" 134a8e1175bSopenharmony_ci#endif 135a8e1175bSopenharmony_ci 136a8e1175bSopenharmony_ci#if defined(PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS) && \ 137a8e1175bSopenharmony_ci !defined(PSA_WANT_ALG_SHA_256) 138a8e1175bSopenharmony_ci#error "PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS defined, but not all prerequisites" 139a8e1175bSopenharmony_ci#endif 140a8e1175bSopenharmony_ci 141a8e1175bSopenharmony_ci#endif /* MBEDTLS_CHECK_CRYPTO_CONFIG_H */ 142