Steven Cooreman | dbf8ced | 2021-03-04 13:01:18 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Declaration of context structures for use with the PSA driver wrapper |
Steven Cooreman | 675501d | 2021-04-26 11:54:58 +0200 | [diff] [blame] | 3 | * interface. This file contains the context structures for 'primitive' |
| 4 | * operations, i.e. those operations which do not rely on other contexts. |
Steven Cooreman | dbf8ced | 2021-03-04 13:01:18 +0100 | [diff] [blame] | 5 | * |
| 6 | * Warning: This file will be auto-generated in the future. |
Ronald Cron | dd3b539 | 2021-04-01 15:36:50 +0200 | [diff] [blame] | 7 | * |
| 8 | * \note This file may not be included directly. Applications must |
| 9 | * include psa/crypto.h. |
| 10 | * |
Ronald Cron | 789cef8 | 2023-03-27 16:31:19 +0200 | [diff] [blame] | 11 | * \note This header and its content are not part of the Mbed TLS API and |
Ronald Cron | dd3b539 | 2021-04-01 15:36:50 +0200 | [diff] [blame] | 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 |
Ronald Cron | 789cef8 | 2023-03-27 16:31:19 +0200 | [diff] [blame] | 14 | * library. The definitions of these objects are then used by crypto_struct.h |
Ronald Cron | dd3b539 | 2021-04-01 15:36:50 +0200 | [diff] [blame] | 15 | * to define the implementation-defined types of PSA multi-part state objects. |
Steven Cooreman | dbf8ced | 2021-03-04 13:01:18 +0100 | [diff] [blame] | 16 | */ |
| 17 | /* Copyright The Mbed TLS Contributors |
Dave Rodgman | 16799db | 2023-11-02 19:47:20 +0000 | [diff] [blame^] | 18 | * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
Steven Cooreman | dbf8ced | 2021-03-04 13:01:18 +0100 | [diff] [blame] | 19 | */ |
| 20 | |
Steven Cooreman | 675501d | 2021-04-26 11:54:58 +0200 | [diff] [blame] | 21 | #ifndef PSA_CRYPTO_DRIVER_CONTEXTS_PRIMITIVES_H |
| 22 | #define PSA_CRYPTO_DRIVER_CONTEXTS_PRIMITIVES_H |
Steven Cooreman | dbf8ced | 2021-03-04 13:01:18 +0100 | [diff] [blame] | 23 | |
Steven Cooreman | dbf8ced | 2021-03-04 13:01:18 +0100 | [diff] [blame] | 24 | #include "psa/crypto_driver_common.h" |
| 25 | |
Ronald Cron | 7975fae | 2021-09-13 14:50:42 +0200 | [diff] [blame] | 26 | /* Include the context structure definitions for the Mbed TLS software drivers */ |
| 27 | #include "psa/crypto_builtin_primitives.h" |
| 28 | |
Steven Cooreman | 830aff2 | 2021-03-09 09:50:44 +0100 | [diff] [blame] | 29 | /* Include the context structure definitions for those drivers that were |
| 30 | * declared during the autogeneration process. */ |
Steven Cooreman | dbf8ced | 2021-03-04 13:01:18 +0100 | [diff] [blame] | 31 | |
Ronald Cron | 7975fae | 2021-09-13 14:50:42 +0200 | [diff] [blame] | 32 | #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) |
| 40 | typedef libtestdriver1_mbedtls_psa_cipher_operation_t |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 41 | mbedtls_transparent_test_driver_cipher_operation_t; |
Ronald Cron | 7975fae | 2021-09-13 14:50:42 +0200 | [diff] [blame] | 42 | |
| 43 | #define MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT \ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 44 | LIBTESTDRIVER1_MBEDTLS_PSA_CIPHER_OPERATION_INIT |
Ronald Cron | 7975fae | 2021-09-13 14:50:42 +0200 | [diff] [blame] | 45 | #else |
| 46 | typedef mbedtls_psa_cipher_operation_t |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 47 | mbedtls_transparent_test_driver_cipher_operation_t; |
Ronald Cron | 7975fae | 2021-09-13 14:50:42 +0200 | [diff] [blame] | 48 | |
| 49 | #define MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT \ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 50 | MBEDTLS_PSA_CIPHER_OPERATION_INIT |
Ronald Cron | 7975fae | 2021-09-13 14:50:42 +0200 | [diff] [blame] | 51 | #endif /* MBEDTLS_TEST_LIBTESTDRIVER1 && |
| 52 | LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER */ |
| 53 | |
| 54 | #if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \ |
| 55 | defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_HASH) |
| 56 | typedef libtestdriver1_mbedtls_psa_hash_operation_t |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 57 | mbedtls_transparent_test_driver_hash_operation_t; |
Ronald Cron | 7975fae | 2021-09-13 14:50:42 +0200 | [diff] [blame] | 58 | |
| 59 | #define MBEDTLS_TRANSPARENT_TEST_DRIVER_HASH_OPERATION_INIT \ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 60 | LIBTESTDRIVER1_MBEDTLS_PSA_HASH_OPERATION_INIT |
Ronald Cron | 7975fae | 2021-09-13 14:50:42 +0200 | [diff] [blame] | 61 | #else |
| 62 | typedef mbedtls_psa_hash_operation_t |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 63 | mbedtls_transparent_test_driver_hash_operation_t; |
Ronald Cron | 7975fae | 2021-09-13 14:50:42 +0200 | [diff] [blame] | 64 | |
| 65 | #define MBEDTLS_TRANSPARENT_TEST_DRIVER_HASH_OPERATION_INIT \ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 66 | MBEDTLS_PSA_HASH_OPERATION_INIT |
Ronald Cron | 7975fae | 2021-09-13 14:50:42 +0200 | [diff] [blame] | 67 | #endif /* MBEDTLS_TEST_LIBTESTDRIVER1 && |
| 68 | LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_HASH */ |
| 69 | |
| 70 | typedef 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 Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 76 | { 0, MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT } |
Ronald Cron | 7975fae | 2021-09-13 14:50:42 +0200 | [diff] [blame] | 77 | |
| 78 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
Steven Cooreman | dbf8ced | 2021-03-04 13:01:18 +0100 | [diff] [blame] | 79 | |
| 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 |
Xiaokang Qian | 845693c | 2023-09-12 03:14:54 +0000 | [diff] [blame] | 85 | * of both this file and the content of psa_crypto_driver_wrappers.h */ |
Steven Cooreman | dbf8ced | 2021-03-04 13:01:18 +0100 | [diff] [blame] | 86 | |
Steven Cooreman | b177731 | 2021-03-04 15:22:38 +0100 | [diff] [blame] | 87 | typedef union { |
Ronald Cron | e31fd11 | 2021-04-01 10:47:14 +0200 | [diff] [blame] | 88 | unsigned dummy; /* Make sure this union is always non-empty */ |
Steven Cooreman | dbf8ced | 2021-03-04 13:01:18 +0100 | [diff] [blame] | 89 | mbedtls_psa_hash_operation_t mbedtls_ctx; |
Steven Cooreman | f763810 | 2021-03-04 15:14:36 +0100 | [diff] [blame] | 90 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
Steven Cooreman | 0f8ffa8 | 2021-03-15 11:56:33 +0100 | [diff] [blame] | 91 | mbedtls_transparent_test_driver_hash_operation_t test_driver_ctx; |
Steven Cooreman | f763810 | 2021-03-04 15:14:36 +0100 | [diff] [blame] | 92 | #endif |
Steven Cooreman | b177731 | 2021-03-04 15:22:38 +0100 | [diff] [blame] | 93 | } psa_driver_hash_context_t; |
Steven Cooreman | dbf8ced | 2021-03-04 13:01:18 +0100 | [diff] [blame] | 94 | |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 95 | typedef union { |
Ronald Cron | e31fd11 | 2021-04-01 10:47:14 +0200 | [diff] [blame] | 96 | unsigned dummy; /* Make sure this union is always non-empty */ |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 97 | mbedtls_psa_cipher_operation_t mbedtls_ctx; |
| 98 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
Ronald Cron | 9198e8c | 2021-03-17 14:29:56 +0100 | [diff] [blame] | 99 | mbedtls_transparent_test_driver_cipher_operation_t transparent_test_driver_ctx; |
| 100 | mbedtls_opaque_test_driver_cipher_operation_t opaque_test_driver_ctx; |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 101 | #endif |
| 102 | } psa_driver_cipher_context_t; |
| 103 | |
Steven Cooreman | 675501d | 2021-04-26 11:54:58 +0200 | [diff] [blame] | 104 | #endif /* PSA_CRYPTO_DRIVER_CONTEXTS_PRIMITIVES_H */ |
Steven Cooreman | dbf8ced | 2021-03-04 13:01:18 +0100 | [diff] [blame] | 105 | /* End of automatically generated file. */ |