blob: 8f90630da853e2d33a1db3d90e36fa1c18c10090 [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
66#endif /* !defined(MBEDTLS_PSA_ACCEL_ALG_ECDH) */
67#endif /* defined(PSA_WANT_ALG_ECDH) */
68
69#if defined(PSA_WANT_ALG_HMAC)
70#if !defined(MBEDTLS_PSA_ACCEL_ALG_HMAC)
71#define MBEDTLS_PSA_BUILTIN_ALG_HMAC 1
72#define MBEDTLS_MD_C
73#endif /* !defined(MBEDTLS_PSA_ACCEL_ALG_HMAC) */
74#endif /* defined(PSA_WANT_ALG_HMAC) */
75
76#if defined(PSA_WANT_ALG_HKDF)
77#if !defined(MBEDTLS_PSA_ACCEL_ALG_HKDF)
78#define MBEDTLS_PSA_BUILTIN_ALG_HKDF 1
79#define MBEDTLS_HKDF_C
80#define MBEDTLS_MD_C
81#endif /* !defined(MBEDTLS_PSA_ACCEL_ALG_HKDF) */
82#endif /* defined(PSA_WANT_ALG_HKDF) */
83
84#if defined(PSA_WANT_ALG_RSA)
85#if !defined(MBEDTLS_PSA_ACCEL_ALG_RSA)
86#define MBEDTLS_PSA_BUILTIN_ALG_RSA
87#define MBEDTLS_RSA_C
88#define MBEDTLS_BIGNUM_C
89#define MBEDTLS_OID_C
90#endif /* !defined(MBEDTLS_PSA_ACCEL_ALG_RSA) */
91#endif /* defined(PSA_WANT_ALG_RSA) */
92
John Durkop714e3a12020-09-29 22:07:04 -070093#else /* MBEDTLS_PSA_CRYPTO_CONFIG */
94
95/*
96 * Ensure PSA_WANT_* defines are setup properly if MBEDTLS_PSA_CRYPTO_CONFIG
97 * is not defined
98 */
John Durkop34818822020-10-12 21:36:22 -070099#if defined(MBEDTLS_ECDSA_C)
John Durkopd0321952020-10-29 21:37:36 -0700100#define MBEDTLS_PSA_BUILTIN_ALG_ECDSA 1
John Durkop714e3a12020-09-29 22:07:04 -0700101
John Durkopf87e3ae2020-10-26 15:25:23 -0700102// Only add in DETERMINISTIC support if ECDSA is also enabled
John Durkop34818822020-10-12 21:36:22 -0700103#if defined(MBEDTLS_ECDSA_DETERMINISTIC)
John Durkopd0321952020-10-29 21:37:36 -0700104#define MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA 1
John Durkop714e3a12020-09-29 22:07:04 -0700105#endif /* MBEDTLS_ECDSA_DETERMINISTIC */
106
John Durkopf87e3ae2020-10-26 15:25:23 -0700107#endif /* MBEDTLS_ECDSA_C */
108
John Durkopd0321952020-10-29 21:37:36 -0700109#if defined(MBEDTLS_ECDH_C)
110#define MBEDTLS_PSA_BUILTIN_ALG_ECDH 1
111#endif /* MBEDTLS_ECDH_C */
112
113#if defined(MBEDTLS_MD_C)
114#define MBEDTLS_PSA_BUILTIN_ALG_HMAC 1
115#endif /* MBEDTLS_MD_C */
116
117#if defined(MBEDTLS_HKDF_C)
118#define MBEDTLS_PSA_BUILTIN_ALG_HKDF 1
119#endif /* MBEDTLS_HKDF_C */
120
121#ifdef MBEDTLS_RSA_C
122#define MBEDTLS_PSA_BUILTIN_ALG_RSA 1
123#endif /* MBEDTLS_RSA_C */
124
John Durkop2dfaf9c2020-09-24 04:30:10 -0700125#endif /* MBEDTLS_PSA_CRYPTO_CONFIG */
John Durkopd8959392020-09-20 23:09:17 -0700126
John Durkop6e33dbe2020-09-17 21:15:13 -0700127#ifdef __cplusplus
128}
129#endif
130
131#endif /* MBEDTLS_CONFIG_PSA_H */