blob: 3f00006f827a2287f0235de6bfc1d6d89b8cdea1 [file] [log] [blame]
Antonio de Angelis8bb98512024-01-16 14:13:36 +00001/*
2 * Declaration of context structures for use with the PSA driver wrapper
3 * interface. This file contains the context structures for 'primitive'
4 * operations, i.e. those operations which do not rely on other contexts.
5 *
6 * Warning: This file will be auto-generated in the future.
7 *
8 * \note This file may not be included directly. Applications must
9 * include psa/crypto.h.
10 *
11 * \note This header and its content are 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 definitions of these objects are then used by crypto_struct.h
15 * to define the implementation-defined types of PSA multi-part state objects.
16 */
17/* Copyright The Mbed TLS Contributors
18 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
19 */
20
21#ifndef PSA_CRYPTO_DRIVER_CONTEXTS_PRIMITIVES_H
22#define PSA_CRYPTO_DRIVER_CONTEXTS_PRIMITIVES_H
23
24#include "psa/crypto_driver_common.h"
25
26/* Include the context structure definitions for the Mbed TLS software drivers */
27#include "psa/crypto_builtin_primitives.h"
28
29/* Include the context structure definitions for those drivers that were
30 * declared during the autogeneration process. */
31
32#if defined(PSA_CRYPTO_DRIVER_CC3XX)
33#include "cc3xx_crypto_primitives_private.h"
34#endif /* PSA_CRYPTO_DRIVER_CC3XX */
35
36#if defined(MBEDTLS_TEST_LIBTESTDRIVER1)
37#include <libtestdriver1/include/psa/crypto.h>
38#endif
39
40#if defined(PSA_CRYPTO_DRIVER_TEST)
41
42#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
43 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
44typedef libtestdriver1_mbedtls_psa_cipher_operation_t
45 mbedtls_transparent_test_driver_cipher_operation_t;
46
47#define MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT \
48 LIBTESTDRIVER1_MBEDTLS_PSA_CIPHER_OPERATION_INIT
49#else
50typedef mbedtls_psa_cipher_operation_t
51 mbedtls_transparent_test_driver_cipher_operation_t;
52
53#define MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT \
54 MBEDTLS_PSA_CIPHER_OPERATION_INIT
55#endif /* MBEDTLS_TEST_LIBTESTDRIVER1 &&
56 LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER */
57
58#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
59 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_HASH)
60typedef libtestdriver1_mbedtls_psa_hash_operation_t
61 mbedtls_transparent_test_driver_hash_operation_t;
62
63#define MBEDTLS_TRANSPARENT_TEST_DRIVER_HASH_OPERATION_INIT \
64 LIBTESTDRIVER1_MBEDTLS_PSA_HASH_OPERATION_INIT
65#else
66typedef mbedtls_psa_hash_operation_t
67 mbedtls_transparent_test_driver_hash_operation_t;
68
69#define MBEDTLS_TRANSPARENT_TEST_DRIVER_HASH_OPERATION_INIT \
70 MBEDTLS_PSA_HASH_OPERATION_INIT
71#endif /* MBEDTLS_TEST_LIBTESTDRIVER1 &&
72 LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_HASH */
73
74typedef struct {
75 unsigned int initialised : 1;
76 mbedtls_transparent_test_driver_cipher_operation_t ctx;
77} mbedtls_opaque_test_driver_cipher_operation_t;
78
79#define MBEDTLS_OPAQUE_TEST_DRIVER_CIPHER_OPERATION_INIT \
80 { 0, MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT }
81
82#endif /* PSA_CRYPTO_DRIVER_TEST */
83
84/* Define the context to be used for an operation that is executed through the
85 * PSA Driver wrapper layer as the union of all possible driver's contexts.
86 *
87 * The union members are the driver's context structures, and the member names
88 * are formatted as `'drivername'_ctx`. This allows for procedural generation
89 * of both this file and the content of psa_crypto_driver_wrappers.h */
90
91typedef union {
92 unsigned dummy; /* Make sure this union is always non-empty */
93 mbedtls_psa_hash_operation_t mbedtls_ctx;
94#if defined(PSA_CRYPTO_DRIVER_TEST)
95 mbedtls_transparent_test_driver_hash_operation_t test_driver_ctx;
96#endif
97#if defined(PSA_CRYPTO_DRIVER_CC3XX)
98 cc3xx_hash_operation_t cc3xx_driver_ctx;
99#endif
100} psa_driver_hash_context_t;
101
102typedef union {
103 unsigned dummy; /* Make sure this union is always non-empty */
104 mbedtls_psa_cipher_operation_t mbedtls_ctx;
105#if defined(PSA_CRYPTO_DRIVER_TEST)
106 mbedtls_transparent_test_driver_cipher_operation_t transparent_test_driver_ctx;
107 mbedtls_opaque_test_driver_cipher_operation_t opaque_test_driver_ctx;
108#endif
109#if defined(PSA_CRYPTO_DRIVER_CC3XX)
110 cc3xx_cipher_operation_t cc3xx_driver_ctx;
111#endif
112} psa_driver_cipher_context_t;
113
114#endif /* PSA_CRYPTO_DRIVER_CONTEXTS_PRIMITIVES_H */
115/* End of automatically generated file. */