blob: c5d284cc95f735ea81ea8041601b99be712367bd [file] [log] [blame]
John Durkop6e33dbe2020-09-17 21:15:13 -07001/**
2 * \file mbedtls/config_psa.h
3 * \brief PSA crypto configuration options (set of defines)
4 *
John Durkop34818822020-10-12 21:36:22 -07005 * This set of compile-time options takes settings defined in
6 * include/mbedtls/config.h and include/psa/crypto_config.h and uses
7 * those definitions to define symbols used in the library code.
8 *
9 * Users and integrators should not edit this file, please edit
10 * include/mbedtls/config.h for MBETLS_XXX settings or
11 * include/psa/crypto_config.h for PSA_WANT_XXX settings.
John Durkop6e33dbe2020-09-17 21:15:13 -070012 */
13/*
14 * Copyright The Mbed TLS Contributors
15 * SPDX-License-Identifier: Apache-2.0
16 *
17 * Licensed under the Apache License, Version 2.0 (the "License"); you may
18 * not use this file except in compliance with the License.
19 * You may obtain a copy of the License at
20 *
21 * http://www.apache.org/licenses/LICENSE-2.0
22 *
23 * Unless required by applicable law or agreed to in writing, software
24 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
25 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26 * See the License for the specific language governing permissions and
27 * limitations under the License.
28 */
29
30#ifndef MBEDTLS_CONFIG_PSA_H
31#define MBEDTLS_CONFIG_PSA_H
32
John Durkop714e3a12020-09-29 22:07:04 -070033#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
John Durkop6e33dbe2020-09-17 21:15:13 -070034#include "psa/crypto_config.h"
John Durkop76228ac2020-09-29 22:33:49 -070035#endif /* defined(MBEDTLS_PSA_CRYPTO_CONFIG) */
John Durkop6e33dbe2020-09-17 21:15:13 -070036
37#ifdef __cplusplus
38extern "C" {
39#endif
40
John Durkop2dfaf9c2020-09-24 04:30:10 -070041#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
John Durkopd8959392020-09-20 23:09:17 -070042
John Durkop2dfaf9c2020-09-24 04:30:10 -070043#if defined(PSA_WANT_ALG_ECDSA)
44#if !defined(MBEDTLS_PSA_ACCEL_ALG_ECDSA)
John Durkop34818822020-10-12 21:36:22 -070045#define MBEDTLS_PSA_BUILTIN_ALG_ECDSA 1
John Durkopd8959392020-09-20 23:09:17 -070046#define MBEDTLS_ECDSA_C
John Durkop34818822020-10-12 21:36:22 -070047#endif /* !MBEDTLS_PSA_ACCEL_ALG_ECDSA */
48#endif /* PSA_WANT_ALG_ECDSA */
John Durkopd8959392020-09-20 23:09:17 -070049
John Durkop0ea39e02020-10-13 19:58:20 -070050#if defined(PSA_WANT_ALG_DETERMINISTIC_ECDSA)
51#if !defined(MBEDTLS_PSA_ACCEL_ALG_DETERMINISTIC_ECDSA)
52#define MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA 1
John Durkopd8959392020-09-20 23:09:17 -070053#define MBEDTLS_ECDSA_DETERMINISTIC
John Durkop36a82e52020-10-26 09:39:05 -070054#define MBEDTLS_ECDSA_C
John Durkop6dff93f2020-10-23 01:22:58 -070055#define MBEDTLS_HMAC_DRBG_C
56#define MBEDTLS_MD_C
John Durkopd0321952020-10-29 21:37:36 -070057#endif /* !MBEDTLS_PSA_ACCEL_ALG_DETERMINISTIC_ECDSA */
John Durkop34818822020-10-12 21:36:22 -070058#endif /* PSA_WANT_ALG_DETERMINISTIC_ECDSA */
John Durkop2dfaf9c2020-09-24 04:30:10 -070059
John Durkopd0321952020-10-29 21:37:36 -070060#if defined(PSA_WANT_ALG_ECDH)
61#if !defined(MBEDTLS_PSA_ACCEL_ALG_ECDH)
62#define MBEDTLS_PSA_BUILTIN_ALG_ECDH 1
63#define MBEDTLS_ECDH_C
64#define MBEDTLS_ECP_C
65#define MBEDTLS_BIGNUM_C
John Durkopf4c4cb02020-10-28 20:09:55 -070066#endif /* !MBEDTLS_PSA_ACCEL_ALG_ECDH */
67#endif /* PSA_WANT_ALG_ECDH */
68
69#if defined(PSA_WANT_ECC_KEY_PAIR)
70#if !defined(MBEDTLS_PSA_ACCEL_ECC_KEY_PAIR)
71#define MBEDTLS_PSA_BUILTIN_ECC_KEY_PAIR 1
72#endif /* !MBEDTLS_PSA_ACCEL_ECC_KEY_PAIR */
73#endif /* PSA_WANT_ECC_KEY_PAIR */
74
75#if defined(PSA_WANT_ECC_PUBLIC_KEY)
76#if !defined(MBEDTLS_PSA_ACCEL_ECC_PUBLIC_KEY)
77#define MBEDTLS_PSA_BUILTIN_ECC_PUBLIC_KEY 1
78#endif /* !MBEDTLS_PSA_ACCEL_ECC_PUBLIC_KEY */
79#endif /* PSA_WANT_ECC_PUBLIC_KEY */
John Durkopd0321952020-10-29 21:37:36 -070080
81#if defined(PSA_WANT_ALG_HMAC)
82#if !defined(MBEDTLS_PSA_ACCEL_ALG_HMAC)
83#define MBEDTLS_PSA_BUILTIN_ALG_HMAC 1
84#define MBEDTLS_MD_C
John Durkopf4c4cb02020-10-28 20:09:55 -070085#endif /* !MBEDTLS_PSA_ACCEL_ALG_HMAC */
86#endif /* PSA_WANT_ALG_HMAC */
John Durkopd0321952020-10-29 21:37:36 -070087
88#if defined(PSA_WANT_ALG_HKDF)
89#if !defined(MBEDTLS_PSA_ACCEL_ALG_HKDF)
90#define MBEDTLS_PSA_BUILTIN_ALG_HKDF 1
91#define MBEDTLS_HKDF_C
92#define MBEDTLS_MD_C
John Durkopf4c4cb02020-10-28 20:09:55 -070093#endif /* !MBEDTLS_PSA_ACCEL_ALG_HKDF */
94#endif /* PSA_WANT_ALG_HKDF */
John Durkopd0321952020-10-29 21:37:36 -070095
96#if defined(PSA_WANT_ALG_RSA)
97#if !defined(MBEDTLS_PSA_ACCEL_ALG_RSA)
98#define MBEDTLS_PSA_BUILTIN_ALG_RSA
99#define MBEDTLS_RSA_C
100#define MBEDTLS_BIGNUM_C
101#define MBEDTLS_OID_C
John Durkopf4c4cb02020-10-28 20:09:55 -0700102#endif /* !MBEDTLS_PSA_ACCEL_ALG_RSA */
103#endif /* PSA_WANT_ALG_RSA */
John Durkopd0321952020-10-29 21:37:36 -0700104
John Durkop714e3a12020-09-29 22:07:04 -0700105#else /* MBEDTLS_PSA_CRYPTO_CONFIG */
106
107/*
108 * Ensure PSA_WANT_* defines are setup properly if MBEDTLS_PSA_CRYPTO_CONFIG
109 * is not defined
110 */
John Durkop34818822020-10-12 21:36:22 -0700111#if defined(MBEDTLS_ECDSA_C)
John Durkopd0321952020-10-29 21:37:36 -0700112#define MBEDTLS_PSA_BUILTIN_ALG_ECDSA 1
John Durkop714e3a12020-09-29 22:07:04 -0700113
John Durkopf87e3ae2020-10-26 15:25:23 -0700114// Only add in DETERMINISTIC support if ECDSA is also enabled
John Durkop34818822020-10-12 21:36:22 -0700115#if defined(MBEDTLS_ECDSA_DETERMINISTIC)
John Durkopd0321952020-10-29 21:37:36 -0700116#define MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA 1
John Durkop714e3a12020-09-29 22:07:04 -0700117#endif /* MBEDTLS_ECDSA_DETERMINISTIC */
118
John Durkopf87e3ae2020-10-26 15:25:23 -0700119#endif /* MBEDTLS_ECDSA_C */
120
John Durkopd0321952020-10-29 21:37:36 -0700121#if defined(MBEDTLS_ECDH_C)
122#define MBEDTLS_PSA_BUILTIN_ALG_ECDH 1
123#endif /* MBEDTLS_ECDH_C */
124
John Durkopf4c4cb02020-10-28 20:09:55 -0700125#if defined(MBEDTLS_ECP_C)
126#define MBEDTLS_PSA_BUILTIN_ECC_KEY_PAIR 1
127#define MBEDTLS_PSA_BUILTIN_ECC_PUBLIC_KEY 1
128#endif /* MBEDTLS_ECP_C */
129
John Durkopd0321952020-10-29 21:37:36 -0700130#if defined(MBEDTLS_MD_C)
131#define MBEDTLS_PSA_BUILTIN_ALG_HMAC 1
132#endif /* MBEDTLS_MD_C */
133
134#if defined(MBEDTLS_HKDF_C)
135#define MBEDTLS_PSA_BUILTIN_ALG_HKDF 1
136#endif /* MBEDTLS_HKDF_C */
137
John Durkopf4c4cb02020-10-28 20:09:55 -0700138#if defined(MBEDTLS_RSA_C)
John Durkopd0321952020-10-29 21:37:36 -0700139#define MBEDTLS_PSA_BUILTIN_ALG_RSA 1
140#endif /* MBEDTLS_RSA_C */
141
John Durkop2dfaf9c2020-09-24 04:30:10 -0700142#endif /* MBEDTLS_PSA_CRYPTO_CONFIG */
John Durkopd8959392020-09-20 23:09:17 -0700143
John Durkop6e33dbe2020-09-17 21:15:13 -0700144#ifdef __cplusplus
145}
146#endif
147
148#endif /* MBEDTLS_CONFIG_PSA_H */