blob: 9a6db01be42ad70e2c13e984ed75a45501a9dcad [file] [log] [blame]
Steven Cooremandbf8ced2021-03-04 13:01:18 +01001/*
2 * Declaration of context structures for use with the PSA driver wrapper
Steven Cooreman040d1ce2021-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
Dave Rodgman7ff79652023-11-03 12:04:52 +000018 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
Steven Cooremandbf8ced2021-03-04 13:01:18 +010019 */
20
Steven Cooreman040d1ce2021-04-26 11:54:58 +020021#ifndef PSA_CRYPTO_DRIVER_CONTEXTS_PRIMITIVES_H
22#define PSA_CRYPTO_DRIVER_CONTEXTS_PRIMITIVES_H
Steven Cooremandbf8ced2021-03-04 13:01:18 +010023
Steven Cooremandbf8ced2021-03-04 13:01:18 +010024#include "psa/crypto_driver_common.h"
25
Ronald Cronb814bda2021-09-13 14:50:42 +020026/* Include the context structure definitions for the Mbed TLS software drivers */
27#include "psa/crypto_builtin_primitives.h"
28
Steven Cooreman830aff22021-03-09 09:50:44 +010029/* Include the context structure definitions for those drivers that were
30 * declared during the autogeneration process. */
Steven Cooremandbf8ced2021-03-04 13:01:18 +010031
Ronald Cronb814bda2021-09-13 14:50:42 +020032#if defined(MBEDTLS_TEST_LIBTESTDRIVER1)
33#include <libtestdriver1/include/psa/crypto.h>
34#endif
35
36#if defined(PSA_CRYPTO_DRIVER_TEST)
37
38#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
39 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
40typedef libtestdriver1_mbedtls_psa_cipher_operation_t
Gilles Peskine1b6c09a2023-01-11 14:52:35 +010041 mbedtls_transparent_test_driver_cipher_operation_t;
Ronald Cronb814bda2021-09-13 14:50:42 +020042
43#define MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT \
Gilles Peskine1b6c09a2023-01-11 14:52:35 +010044 LIBTESTDRIVER1_MBEDTLS_PSA_CIPHER_OPERATION_INIT
Ronald Cronb814bda2021-09-13 14:50:42 +020045#else
46typedef mbedtls_psa_cipher_operation_t
Gilles Peskine1b6c09a2023-01-11 14:52:35 +010047 mbedtls_transparent_test_driver_cipher_operation_t;
Ronald Cronb814bda2021-09-13 14:50:42 +020048
49#define MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT \
Gilles Peskine1b6c09a2023-01-11 14:52:35 +010050 MBEDTLS_PSA_CIPHER_OPERATION_INIT
Ronald Cronb814bda2021-09-13 14:50:42 +020051#endif /* MBEDTLS_TEST_LIBTESTDRIVER1 &&
52 LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER */
53
54#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
55 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_HASH)
56typedef libtestdriver1_mbedtls_psa_hash_operation_t
Gilles Peskine1b6c09a2023-01-11 14:52:35 +010057 mbedtls_transparent_test_driver_hash_operation_t;
Ronald Cronb814bda2021-09-13 14:50:42 +020058
59#define MBEDTLS_TRANSPARENT_TEST_DRIVER_HASH_OPERATION_INIT \
Gilles Peskine1b6c09a2023-01-11 14:52:35 +010060 LIBTESTDRIVER1_MBEDTLS_PSA_HASH_OPERATION_INIT
Ronald Cronb814bda2021-09-13 14:50:42 +020061#else
62typedef mbedtls_psa_hash_operation_t
Gilles Peskine1b6c09a2023-01-11 14:52:35 +010063 mbedtls_transparent_test_driver_hash_operation_t;
Ronald Cronb814bda2021-09-13 14:50:42 +020064
65#define MBEDTLS_TRANSPARENT_TEST_DRIVER_HASH_OPERATION_INIT \
Gilles Peskine1b6c09a2023-01-11 14:52:35 +010066 MBEDTLS_PSA_HASH_OPERATION_INIT
Ronald Cronb814bda2021-09-13 14:50:42 +020067#endif /* MBEDTLS_TEST_LIBTESTDRIVER1 &&
68 LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_HASH */
69
70typedef struct {
71 unsigned int initialised : 1;
72 mbedtls_transparent_test_driver_cipher_operation_t ctx;
73} mbedtls_opaque_test_driver_cipher_operation_t;
74
75#define MBEDTLS_OPAQUE_TEST_DRIVER_CIPHER_OPERATION_INIT \
Gilles Peskine1b6c09a2023-01-11 14:52:35 +010076 { 0, MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT }
Ronald Cronb814bda2021-09-13 14:50:42 +020077
78#endif /* PSA_CRYPTO_DRIVER_TEST */
Steven Cooremandbf8ced2021-03-04 13:01:18 +010079
80/* Define the context to be used for an operation that is executed through the
81 * PSA Driver wrapper layer as the union of all possible driver's contexts.
82 *
83 * The union members are the driver's context structures, and the member names
84 * are formatted as `'drivername'_ctx`. This allows for procedural generation
85 * of both this file and the content of psa_crypto_driver_wrappers.c */
86
Steven Cooremanb1777312021-03-04 15:22:38 +010087typedef union {
Ronald Crone31fd112021-04-01 10:47:14 +020088 unsigned dummy; /* Make sure this union is always non-empty */
Steven Cooremandbf8ced2021-03-04 13:01:18 +010089 mbedtls_psa_hash_operation_t mbedtls_ctx;
Steven Cooremanf7638102021-03-04 15:14:36 +010090#if defined(PSA_CRYPTO_DRIVER_TEST)
Steven Cooreman0f8ffa82021-03-15 11:56:33 +010091 mbedtls_transparent_test_driver_hash_operation_t test_driver_ctx;
Steven Cooremanf7638102021-03-04 15:14:36 +010092#endif
Steven Cooremanb1777312021-03-04 15:22:38 +010093} psa_driver_hash_context_t;
Steven Cooremandbf8ced2021-03-04 13:01:18 +010094
Ronald Cron7cb9c3d2021-03-10 12:21:48 +010095typedef union {
Ronald Crone31fd112021-04-01 10:47:14 +020096 unsigned dummy; /* Make sure this union is always non-empty */
Ronald Cron7cb9c3d2021-03-10 12:21:48 +010097 mbedtls_psa_cipher_operation_t mbedtls_ctx;
98#if defined(PSA_CRYPTO_DRIVER_TEST)
Ronald Cron9198e8c2021-03-17 14:29:56 +010099 mbedtls_transparent_test_driver_cipher_operation_t transparent_test_driver_ctx;
100 mbedtls_opaque_test_driver_cipher_operation_t opaque_test_driver_ctx;
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100101#endif
102} psa_driver_cipher_context_t;
103
Steven Cooreman040d1ce2021-04-26 11:54:58 +0200104#endif /* PSA_CRYPTO_DRIVER_CONTEXTS_PRIMITIVES_H */
Steven Cooremandbf8ced2021-03-04 13:01:18 +0100105/* End of automatically generated file. */