blob: 068a193bcce542009fd91e4c07e5779243ebb365 [file] [log] [blame]
Steven Cooreman3c8dd632021-04-26 12:16:27 +02001/*
2 * Declaration of context structures for use with the PSA driver wrapper
3 * interface. This file contains the context structures for 'composite'
4 * operations, i.e. those operations which need to make use of other operations
5 * from the primitives (crypto_driver_contexts_primitives.h)
6 *
7 * Warning: This file will be auto-generated in the future.
8 *
9 * \note This file may not be included directly. Applications must
10 * include psa/crypto.h.
11 *
Ronald Cron789cef82023-03-27 16:31:19 +020012 * \note This header and its content are not part of the Mbed TLS API and
Steven Cooreman3c8dd632021-04-26 12:16:27 +020013 * applications must not depend on it. Its main purpose is to define the
14 * multi-part state objects of the PSA drivers included in the cryptographic
Ronald Cron789cef82023-03-27 16:31:19 +020015 * library. The definitions of these objects are then used by crypto_struct.h
Steven Cooreman3c8dd632021-04-26 12:16:27 +020016 * to define the implementation-defined types of PSA multi-part state objects.
17 */
18/* Copyright The Mbed TLS Contributors
19 * SPDX-License-Identifier: Apache-2.0
20 *
21 * Licensed under the Apache License, Version 2.0 (the "License"); you may
22 * not use this file except in compliance with the License.
23 * You may obtain a copy of the License at
24 *
25 * http://www.apache.org/licenses/LICENSE-2.0
26 *
27 * Unless required by applicable law or agreed to in writing, software
28 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
29 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30 * See the License for the specific language governing permissions and
31 * limitations under the License.
32 */
33
34#ifndef PSA_CRYPTO_DRIVER_CONTEXTS_COMPOSITES_H
35#define PSA_CRYPTO_DRIVER_CONTEXTS_COMPOSITES_H
36
37#include "psa/crypto_driver_common.h"
38
Ronald Cron7975fae2021-09-13 14:50:42 +020039/* Include the context structure definitions for the Mbed TLS software drivers */
40#include "psa/crypto_builtin_composites.h"
41
Steven Cooreman3c8dd632021-04-26 12:16:27 +020042/* Include the context structure definitions for those drivers that were
43 * declared during the autogeneration process. */
44
Ronald Cron7975fae2021-09-13 14:50:42 +020045#if defined(MBEDTLS_TEST_LIBTESTDRIVER1)
46#include <libtestdriver1/include/psa/crypto.h>
47#endif
48
49#if defined(PSA_CRYPTO_DRIVER_TEST)
50#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
51 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_MAC)
52typedef libtestdriver1_mbedtls_psa_mac_operation_t
Gilles Peskine449bd832023-01-11 14:50:10 +010053 mbedtls_transparent_test_driver_mac_operation_t;
Ronald Cron7975fae2021-09-13 14:50:42 +020054typedef libtestdriver1_mbedtls_psa_mac_operation_t
Gilles Peskine449bd832023-01-11 14:50:10 +010055 mbedtls_opaque_test_driver_mac_operation_t;
Ronald Cron7975fae2021-09-13 14:50:42 +020056
57#define MBEDTLS_TRANSPARENT_TEST_DRIVER_MAC_OPERATION_INIT \
Gilles Peskine449bd832023-01-11 14:50:10 +010058 LIBTESTDRIVER1_MBEDTLS_PSA_MAC_OPERATION_INIT
Ronald Cron7975fae2021-09-13 14:50:42 +020059#define MBEDTLS_OPAQUE_TEST_DRIVER_MAC_OPERATION_INIT \
Gilles Peskine449bd832023-01-11 14:50:10 +010060 LIBTESTDRIVER1_MBEDTLS_PSA_MAC_OPERATION_INIT
Ronald Cron7975fae2021-09-13 14:50:42 +020061
62#else
63typedef mbedtls_psa_mac_operation_t
Gilles Peskine449bd832023-01-11 14:50:10 +010064 mbedtls_transparent_test_driver_mac_operation_t;
Ronald Cron7975fae2021-09-13 14:50:42 +020065typedef mbedtls_psa_mac_operation_t
Gilles Peskine449bd832023-01-11 14:50:10 +010066 mbedtls_opaque_test_driver_mac_operation_t;
Ronald Cron7975fae2021-09-13 14:50:42 +020067
68#define MBEDTLS_TRANSPARENT_TEST_DRIVER_MAC_OPERATION_INIT \
Gilles Peskine449bd832023-01-11 14:50:10 +010069 MBEDTLS_PSA_MAC_OPERATION_INIT
Ronald Cron7975fae2021-09-13 14:50:42 +020070#define MBEDTLS_OPAQUE_TEST_DRIVER_MAC_OPERATION_INIT \
Gilles Peskine449bd832023-01-11 14:50:10 +010071 MBEDTLS_PSA_MAC_OPERATION_INIT
Ronald Cron7975fae2021-09-13 14:50:42 +020072
73#endif /* MBEDTLS_TEST_LIBTESTDRIVER1 && LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_MAC */
74
75#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
76 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_AEAD)
77typedef libtestdriver1_mbedtls_psa_aead_operation_t
Gilles Peskine449bd832023-01-11 14:50:10 +010078 mbedtls_transparent_test_driver_aead_operation_t;
Ronald Cron7975fae2021-09-13 14:50:42 +020079
80#define MBEDTLS_TRANSPARENT_TEST_DRIVER_AEAD_OPERATION_INIT \
Gilles Peskine449bd832023-01-11 14:50:10 +010081 LIBTESTDRIVER1_MBEDTLS_PSA_AEAD_OPERATION_INIT
Ronald Cron7975fae2021-09-13 14:50:42 +020082#else
83typedef mbedtls_psa_aead_operation_t
Gilles Peskine449bd832023-01-11 14:50:10 +010084 mbedtls_transparent_test_driver_aead_operation_t;
Ronald Cron7975fae2021-09-13 14:50:42 +020085
86#define MBEDTLS_TRANSPARENT_TEST_DRIVER_AEAD_OPERATION_INIT \
Gilles Peskine449bd832023-01-11 14:50:10 +010087 MBEDTLS_PSA_AEAD_OPERATION_INIT
Ronald Cron7975fae2021-09-13 14:50:42 +020088
89#endif /* MBEDTLS_TEST_LIBTESTDRIVER1 && LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_AEAD */
90
Przemek Stekiel96ae8b92022-12-07 11:52:08 +010091#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
92 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_PAKE)
93
94typedef libtestdriver1_mbedtls_psa_pake_operation_t
95 mbedtls_transparent_test_driver_pake_operation_t;
Przemek Stekiel251e86a2023-02-17 14:30:50 +010096typedef libtestdriver1_mbedtls_psa_pake_operation_t
Przemek Stekiel96ae8b92022-12-07 11:52:08 +010097 mbedtls_opaque_test_driver_pake_operation_t;
98
99#define MBEDTLS_TRANSPARENT_TEST_DRIVER_PAKE_OPERATION_INIT \
100 LIBTESTDRIVER1_MBEDTLS_PSA_PAKE_OPERATION_INIT
101#define MBEDTLS_OPAQUE_TEST_DRIVER_PAKE_OPERATION_INIT \
102 LIBTESTDRIVER1_MBEDTLS_PSA_PAKE_OPERATION_INIT
103
104#else
105typedef mbedtls_psa_pake_operation_t
106 mbedtls_transparent_test_driver_pake_operation_t;
107typedef mbedtls_psa_pake_operation_t
108 mbedtls_opaque_test_driver_pake_operation_t;
109
110#define MBEDTLS_TRANSPARENT_TEST_DRIVER_PAKE_OPERATION_INIT \
111 MBEDTLS_PSA_PAKE_OPERATION_INIT
112#define MBEDTLS_OPAQUE_TEST_DRIVER_PAKE_OPERATION_INIT \
113 MBEDTLS_PSA_PAKE_OPERATION_INIT
114
115#endif /* MBEDTLS_TEST_LIBTESTDRIVER1 && LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_PAKE */
116
Ronald Cron7975fae2021-09-13 14:50:42 +0200117#endif /* PSA_CRYPTO_DRIVER_TEST */
Steven Cooreman3c8dd632021-04-26 12:16:27 +0200118
119/* Define the context to be used for an operation that is executed through the
120 * PSA Driver wrapper layer as the union of all possible driver's contexts.
121 *
122 * The union members are the driver's context structures, and the member names
123 * are formatted as `'drivername'_ctx`. This allows for procedural generation
124 * of both this file and the content of psa_crypto_driver_wrappers.c */
125
Steven Cooremand13a70f2021-03-19 15:24:23 +0100126typedef union {
127 unsigned dummy; /* Make sure this union is always non-empty */
128 mbedtls_psa_mac_operation_t mbedtls_ctx;
129#if defined(PSA_CRYPTO_DRIVER_TEST)
130 mbedtls_transparent_test_driver_mac_operation_t transparent_test_driver_ctx;
131 mbedtls_opaque_test_driver_mac_operation_t opaque_test_driver_ctx;
132#endif
133} psa_driver_mac_context_t;
134
Paul Elliott3dc1c242021-05-20 18:32:57 +0100135typedef union {
136 unsigned dummy; /* Make sure this union is always non-empty */
137 mbedtls_psa_aead_operation_t mbedtls_ctx;
138#if defined(PSA_CRYPTO_DRIVER_TEST)
139 mbedtls_transparent_test_driver_aead_operation_t transparent_test_driver_ctx;
140#endif
141} psa_driver_aead_context_t;
142
Paul Elliott588f8ed2022-12-02 18:10:26 +0000143typedef union {
144 unsigned dummy; /* Make sure this union is always non-empty */
145 mbedtls_psa_sign_hash_interruptible_operation_t mbedtls_ctx;
146} psa_driver_sign_hash_interruptible_context_t;
147
148typedef union {
149 unsigned dummy; /* Make sure this union is always non-empty */
150 mbedtls_psa_verify_hash_interruptible_operation_t mbedtls_ctx;
151} psa_driver_verify_hash_interruptible_context_t;
152
Przemek Stekiel96ae8b92022-12-07 11:52:08 +0100153typedef union {
154 unsigned dummy; /* Make sure this union is always non-empty */
155 mbedtls_psa_pake_operation_t mbedtls_ctx;
156#if defined(PSA_CRYPTO_DRIVER_TEST)
157 mbedtls_transparent_test_driver_pake_operation_t transparent_test_driver_ctx;
158 mbedtls_opaque_test_driver_pake_operation_t opaque_test_driver_ctx;
159#endif
160} psa_driver_pake_context_t;
161
Steven Cooreman3c8dd632021-04-26 12:16:27 +0200162#endif /* PSA_CRYPTO_DRIVER_CONTEXTS_COMPOSITES_H */
163/* End of automatically generated file. */