1 /*
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  *
12  * \note This header and its content is not part of the Mbed TLS API and
13  * 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
15  * library. The definition of these objects are then used by crypto_struct.h
16  * 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 
39 /* Include the context structure definitions for the Mbed TLS software drivers */
40 #include "psa/crypto_builtin_composites.h"
41 
42 /* Include the context structure definitions for those drivers that were
43  * declared during the autogeneration process. */
44 #if defined(PSA_CRYPTO_DRIVER_CC3XX)
45 #include "cc3xx_crypto_primitives_private.h"
46 #endif
47 
48 #if defined(MBEDTLS_TEST_LIBTESTDRIVER1)
49 #include <libtestdriver1/include/psa/crypto.h>
50 #endif
51 
52 #if defined(PSA_CRYPTO_DRIVER_TEST)
53 #if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
54     defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_MAC)
55 typedef libtestdriver1_mbedtls_psa_mac_operation_t
56     mbedtls_transparent_test_driver_mac_operation_t;
57 typedef libtestdriver1_mbedtls_psa_mac_operation_t
58     mbedtls_opaque_test_driver_mac_operation_t;
59 
60 #define MBEDTLS_TRANSPARENT_TEST_DRIVER_MAC_OPERATION_INIT \
61     LIBTESTDRIVER1_MBEDTLS_PSA_MAC_OPERATION_INIT
62 #define MBEDTLS_OPAQUE_TEST_DRIVER_MAC_OPERATION_INIT \
63     LIBTESTDRIVER1_MBEDTLS_PSA_MAC_OPERATION_INIT
64 
65 #else
66 typedef mbedtls_psa_mac_operation_t
67     mbedtls_transparent_test_driver_mac_operation_t;
68 typedef mbedtls_psa_mac_operation_t
69     mbedtls_opaque_test_driver_mac_operation_t;
70 
71 #define MBEDTLS_TRANSPARENT_TEST_DRIVER_MAC_OPERATION_INIT \
72     MBEDTLS_PSA_MAC_OPERATION_INIT
73 #define MBEDTLS_OPAQUE_TEST_DRIVER_MAC_OPERATION_INIT \
74     MBEDTLS_PSA_MAC_OPERATION_INIT
75 
76 #endif /* MBEDTLS_TEST_LIBTESTDRIVER1 && LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_MAC */
77 
78 #if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
79     defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_AEAD)
80 typedef libtestdriver1_mbedtls_psa_aead_operation_t
81     mbedtls_transparent_test_driver_aead_operation_t;
82 
83 #define MBEDTLS_TRANSPARENT_TEST_DRIVER_AEAD_OPERATION_INIT \
84     LIBTESTDRIVER1_MBEDTLS_PSA_AEAD_OPERATION_INIT
85 #else
86 typedef mbedtls_psa_aead_operation_t
87     mbedtls_transparent_test_driver_aead_operation_t;
88 
89 #define MBEDTLS_TRANSPARENT_TEST_DRIVER_AEAD_OPERATION_INIT \
90     MBEDTLS_PSA_AEAD_OPERATION_INIT
91 
92 #endif /* MBEDTLS_TEST_LIBTESTDRIVER1 && LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_AEAD */
93 
94 #if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
95     defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_PAKE)
96 
97 typedef libtestdriver1_mbedtls_psa_pake_operation_t
98     mbedtls_transparent_test_driver_pake_operation_t;
99 typedef libtestdriver1_mbedtls_psa_pake_operation_t
100     mbedtls_opaque_test_driver_pake_operation_t;
101 
102 #define MBEDTLS_TRANSPARENT_TEST_DRIVER_PAKE_OPERATION_INIT \
103     LIBTESTDRIVER1_MBEDTLS_PSA_PAKE_OPERATION_INIT
104 #define MBEDTLS_OPAQUE_TEST_DRIVER_PAKE_OPERATION_INIT \
105     LIBTESTDRIVER1_MBEDTLS_PSA_PAKE_OPERATION_INIT
106 
107 #else
108 typedef mbedtls_psa_pake_operation_t
109     mbedtls_transparent_test_driver_pake_operation_t;
110 typedef mbedtls_psa_pake_operation_t
111     mbedtls_opaque_test_driver_pake_operation_t;
112 
113 #define MBEDTLS_TRANSPARENT_TEST_DRIVER_PAKE_OPERATION_INIT \
114     MBEDTLS_PSA_PAKE_OPERATION_INIT
115 #define MBEDTLS_OPAQUE_TEST_DRIVER_PAKE_OPERATION_INIT \
116     MBEDTLS_PSA_PAKE_OPERATION_INIT
117 
118 #endif /* MBEDTLS_TEST_LIBTESTDRIVER1 && LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_PAKE */
119 
120 #endif /* PSA_CRYPTO_DRIVER_TEST */
121 
122 /* Define the context to be used for an operation that is executed through the
123  * PSA Driver wrapper layer as the union of all possible driver's contexts.
124  *
125  * The union members are the driver's context structures, and the member names
126  * are formatted as `'drivername'_ctx`. This allows for procedural generation
127  * of both this file and the content of psa_crypto_driver_wrappers.c */
128 
129 typedef union {
130     unsigned dummy; /* Make sure this union is always non-empty */
131     mbedtls_psa_mac_operation_t mbedtls_ctx;
132 #if defined(PSA_CRYPTO_DRIVER_TEST)
133     mbedtls_transparent_test_driver_mac_operation_t transparent_test_driver_ctx;
134     mbedtls_opaque_test_driver_mac_operation_t opaque_test_driver_ctx;
135 #endif
136 #if defined(PSA_CRYPTO_DRIVER_CC3XX)
137     cc3xx_mac_operation_t cc3xx_driver_ctx;
138 #endif
139 } psa_driver_mac_context_t;
140 
141 typedef union {
142     unsigned dummy; /* Make sure this union is always non-empty */
143     mbedtls_psa_aead_operation_t mbedtls_ctx;
144 #if defined(PSA_CRYPTO_DRIVER_TEST)
145     mbedtls_transparent_test_driver_aead_operation_t transparent_test_driver_ctx;
146 #endif
147 #if defined(PSA_CRYPTO_DRIVER_CC3XX)
148     cc3xx_aead_operation_t cc3xx_driver_ctx;
149 #endif /* PSA_CRYPTO_DRIVER_CC3XX */
150 } psa_driver_aead_context_t;
151 
152 typedef union {
153     unsigned dummy; /* Make sure this union is always non-empty */
154     mbedtls_psa_sign_hash_interruptible_operation_t mbedtls_ctx;
155 } psa_driver_sign_hash_interruptible_context_t;
156 
157 typedef union {
158     unsigned dummy; /* Make sure this union is always non-empty */
159     mbedtls_psa_verify_hash_interruptible_operation_t mbedtls_ctx;
160 } psa_driver_verify_hash_interruptible_context_t;
161 
162 typedef union {
163     unsigned dummy; /* Make sure this union is always non-empty */
164     mbedtls_psa_pake_operation_t mbedtls_ctx;
165 #if defined(PSA_CRYPTO_DRIVER_TEST)
166     mbedtls_transparent_test_driver_pake_operation_t transparent_test_driver_ctx;
167     mbedtls_opaque_test_driver_pake_operation_t opaque_test_driver_ctx;
168 #endif
169 } psa_driver_pake_context_t;
170 
171 #endif /* PSA_CRYPTO_DRIVER_CONTEXTS_COMPOSITES_H */
172 /* End of automatically generated file. */
173