blob: 7d096208b4baf4787be92d207776748fef7e7e1a [file] [log] [blame]
Steven Cooremandbf8ced2021-03-04 13:01:18 +01001/*
2 * Declaration of context structures for use with the PSA driver wrapper
Steven Cooreman675501d2021-04-26 11:54:58 +02003 * interface. This file contains the context structures for 'primitive'
4 * operations, i.e. those operations which do not rely on other contexts.
Steven Cooremandbf8ced2021-03-04 13:01:18 +01005 *
6 * Warning: This file will be auto-generated in the future.
Ronald Crondd3b5392021-04-01 15:36:50 +02007 *
8 * \note This file may not be included directly. Applications must
9 * include psa/crypto.h.
10 *
11 * \note This header and its content is not part of the Mbed TLS API and
12 * applications must not depend on it. Its main purpose is to define the
13 * multi-part state objects of the PSA drivers included in the cryptographic
14 * library. The definition of these objects are then used by crypto_struct.h
15 * to define the implementation-defined types of PSA multi-part state objects.
Steven Cooremandbf8ced2021-03-04 13:01:18 +010016 */
17/* Copyright The Mbed TLS Contributors
18 * SPDX-License-Identifier: Apache-2.0
19 *
20 * Licensed under the Apache License, Version 2.0 (the "License"); you may
21 * not use this file except in compliance with the License.
22 * You may obtain a copy of the License at
23 *
24 * http://www.apache.org/licenses/LICENSE-2.0
25 *
26 * Unless required by applicable law or agreed to in writing, software
27 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
28 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29 * See the License for the specific language governing permissions and
30 * limitations under the License.
31 */
32
Steven Cooreman675501d2021-04-26 11:54:58 +020033#ifndef PSA_CRYPTO_DRIVER_CONTEXTS_PRIMITIVES_H
34#define PSA_CRYPTO_DRIVER_CONTEXTS_PRIMITIVES_H
Steven Cooremandbf8ced2021-03-04 13:01:18 +010035
Steven Cooremandbf8ced2021-03-04 13:01:18 +010036#include "psa/crypto_driver_common.h"
37
Ronald Cron7975fae2021-09-13 14:50:42 +020038/* Include the context structure definitions for the Mbed TLS software drivers */
39#include "psa/crypto_builtin_primitives.h"
40
Steven Cooreman830aff22021-03-09 09:50:44 +010041/* Include the context structure definitions for those drivers that were
42 * declared during the autogeneration process. */
Steven Cooremandbf8ced2021-03-04 13:01:18 +010043
Ronald Cron7975fae2021-09-13 14:50:42 +020044#if defined(MBEDTLS_TEST_LIBTESTDRIVER1)
45#include <libtestdriver1/include/psa/crypto.h>
46#endif
47
Przemek Stekield91bcb72022-11-22 14:00:51 +010048#include "mbedtls/ecjpake.h"
49
Ronald Cron7975fae2021-09-13 14:50:42 +020050#if defined(PSA_CRYPTO_DRIVER_TEST)
51
52#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
53 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
54typedef libtestdriver1_mbedtls_psa_cipher_operation_t
Gilles Peskine449bd832023-01-11 14:50:10 +010055 mbedtls_transparent_test_driver_cipher_operation_t;
Ronald Cron7975fae2021-09-13 14:50:42 +020056
57#define MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT \
Gilles Peskine449bd832023-01-11 14:50:10 +010058 LIBTESTDRIVER1_MBEDTLS_PSA_CIPHER_OPERATION_INIT
Ronald Cron7975fae2021-09-13 14:50:42 +020059#else
60typedef mbedtls_psa_cipher_operation_t
Gilles Peskine449bd832023-01-11 14:50:10 +010061 mbedtls_transparent_test_driver_cipher_operation_t;
Ronald Cron7975fae2021-09-13 14:50:42 +020062
63#define MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT \
Gilles Peskine449bd832023-01-11 14:50:10 +010064 MBEDTLS_PSA_CIPHER_OPERATION_INIT
Ronald Cron7975fae2021-09-13 14:50:42 +020065#endif /* MBEDTLS_TEST_LIBTESTDRIVER1 &&
66 LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER */
67
68#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
69 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_HASH)
70typedef libtestdriver1_mbedtls_psa_hash_operation_t
Gilles Peskine449bd832023-01-11 14:50:10 +010071 mbedtls_transparent_test_driver_hash_operation_t;
Ronald Cron7975fae2021-09-13 14:50:42 +020072
73#define MBEDTLS_TRANSPARENT_TEST_DRIVER_HASH_OPERATION_INIT \
Gilles Peskine449bd832023-01-11 14:50:10 +010074 LIBTESTDRIVER1_MBEDTLS_PSA_HASH_OPERATION_INIT
Ronald Cron7975fae2021-09-13 14:50:42 +020075#else
76typedef mbedtls_psa_hash_operation_t
Gilles Peskine449bd832023-01-11 14:50:10 +010077 mbedtls_transparent_test_driver_hash_operation_t;
Ronald Cron7975fae2021-09-13 14:50:42 +020078
79#define MBEDTLS_TRANSPARENT_TEST_DRIVER_HASH_OPERATION_INIT \
Gilles Peskine449bd832023-01-11 14:50:10 +010080 MBEDTLS_PSA_HASH_OPERATION_INIT
Ronald Cron7975fae2021-09-13 14:50:42 +020081#endif /* MBEDTLS_TEST_LIBTESTDRIVER1 &&
82 LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_HASH */
83
84typedef struct {
85 unsigned int initialised : 1;
86 mbedtls_transparent_test_driver_cipher_operation_t ctx;
87} mbedtls_opaque_test_driver_cipher_operation_t;
88
89#define MBEDTLS_OPAQUE_TEST_DRIVER_CIPHER_OPERATION_INIT \
Gilles Peskine449bd832023-01-11 14:50:10 +010090 { 0, MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT }
Ronald Cron7975fae2021-09-13 14:50:42 +020091
Przemek Stekield91bcb72022-11-22 14:00:51 +010092#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
93 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_PAKE)
94
95typedef libtestdriver1_mbedtls_psa_pake_operation_t
96 mbedtls_transparent_test_driver_pake_operation_t;
97typedef libtestdriver1_psa_pake_operation_t
98 mbedtls_opaque_test_driver_pake_operation_t;
99
100#define MBEDTLS_TRANSPARENT_TEST_DRIVER_PAKE_OPERATION_INIT \
101 LIBTESTDRIVER1_MBEDTLS_PSA_PAKE_OPERATION_INIT
102#define MBEDTLS_OPAQUE_TEST_DRIVER_PAKE_OPERATION_INIT \
103 LIBTESTDRIVER1_MBEDTLS_PSA_PAKE_OPERATION_INIT
104
105#else
106typedef mbedtls_psa_pake_operation_t
107 mbedtls_transparent_test_driver_pake_operation_t;
108typedef mbedtls_psa_pake_operation_t
109 mbedtls_opaque_test_driver_pake_operation_t;
110
111#define MBEDTLS_TRANSPARENT_TEST_DRIVER_PAKE_OPERATION_INIT \
112 MBEDTLS_PSA_PAKE_OPERATION_INIT
113#define MBEDTLS_OPAQUE_TEST_DRIVER_PAKE_OPERATION_INIT \
114 MBEDTLS_PSA_PAKE_OPERATION_INIT
115
116#endif /* MBEDTLS_TEST_LIBTESTDRIVER1 && LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_PAKE */
117
Ronald Cron7975fae2021-09-13 14:50:42 +0200118#endif /* PSA_CRYPTO_DRIVER_TEST */
Steven Cooremandbf8ced2021-03-04 13:01:18 +0100119
120/* Define the context to be used for an operation that is executed through the
121 * PSA Driver wrapper layer as the union of all possible driver's contexts.
122 *
123 * The union members are the driver's context structures, and the member names
124 * are formatted as `'drivername'_ctx`. This allows for procedural generation
125 * of both this file and the content of psa_crypto_driver_wrappers.c */
126
Steven Cooremanb1777312021-03-04 15:22:38 +0100127typedef union {
Ronald Crone31fd112021-04-01 10:47:14 +0200128 unsigned dummy; /* Make sure this union is always non-empty */
Steven Cooremandbf8ced2021-03-04 13:01:18 +0100129 mbedtls_psa_hash_operation_t mbedtls_ctx;
Steven Cooremanf7638102021-03-04 15:14:36 +0100130#if defined(PSA_CRYPTO_DRIVER_TEST)
Steven Cooreman0f8ffa82021-03-15 11:56:33 +0100131 mbedtls_transparent_test_driver_hash_operation_t test_driver_ctx;
Steven Cooremanf7638102021-03-04 15:14:36 +0100132#endif
Steven Cooremanb1777312021-03-04 15:22:38 +0100133} psa_driver_hash_context_t;
Steven Cooremandbf8ced2021-03-04 13:01:18 +0100134
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100135typedef union {
Ronald Crone31fd112021-04-01 10:47:14 +0200136 unsigned dummy; /* Make sure this union is always non-empty */
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100137 mbedtls_psa_cipher_operation_t mbedtls_ctx;
138#if defined(PSA_CRYPTO_DRIVER_TEST)
Ronald Cron9198e8c2021-03-17 14:29:56 +0100139 mbedtls_transparent_test_driver_cipher_operation_t transparent_test_driver_ctx;
140 mbedtls_opaque_test_driver_cipher_operation_t opaque_test_driver_ctx;
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100141#endif
142} psa_driver_cipher_context_t;
143
Przemek Stekield91bcb72022-11-22 14:00:51 +0100144typedef union {
145 unsigned dummy; /* Make sure this union is always non-empty */
146 mbedtls_psa_pake_operation_t mbedtls_ctx;
147#if defined(PSA_CRYPTO_DRIVER_TEST)
148 mbedtls_transparent_test_driver_pake_operation_t transparent_test_driver_ctx;
149 mbedtls_opaque_test_driver_pake_operation_t opaque_test_driver_ctx;
150#endif
151} psa_driver_pake_context_t;
152
Steven Cooreman675501d2021-04-26 11:54:58 +0200153#endif /* PSA_CRYPTO_DRIVER_CONTEXTS_PRIMITIVES_H */
Steven Cooremandbf8ced2021-03-04 13:01:18 +0100154/* End of automatically generated file. */