crypto_driver_contexts_primitives.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  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 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.
  16. */
  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. #ifndef PSA_CRYPTO_DRIVER_CONTEXTS_PRIMITIVES_H
  33. #define PSA_CRYPTO_DRIVER_CONTEXTS_PRIMITIVES_H
  34. #include "psa/crypto_driver_common.h"
  35. /* Include the context structure definitions for the Mbed TLS software drivers */
  36. #include "psa/crypto_builtin_primitives.h"
  37. /* Include the context structure definitions for those drivers that were
  38. * declared during the autogeneration process. */
  39. #if defined(MBEDTLS_TEST_LIBTESTDRIVER1)
  40. #include <libtestdriver1/include/psa/crypto.h>
  41. #endif
  42. #if defined(PSA_CRYPTO_DRIVER_TEST)
  43. #if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
  44. defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
  45. typedef libtestdriver1_mbedtls_psa_cipher_operation_t
  46. mbedtls_transparent_test_driver_cipher_operation_t;
  47. #define MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT \
  48. LIBTESTDRIVER1_MBEDTLS_PSA_CIPHER_OPERATION_INIT
  49. #else
  50. typedef mbedtls_psa_cipher_operation_t
  51. mbedtls_transparent_test_driver_cipher_operation_t;
  52. #define MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT \
  53. MBEDTLS_PSA_CIPHER_OPERATION_INIT
  54. #endif /* MBEDTLS_TEST_LIBTESTDRIVER1 &&
  55. LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER */
  56. #if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
  57. defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_HASH)
  58. typedef libtestdriver1_mbedtls_psa_hash_operation_t
  59. mbedtls_transparent_test_driver_hash_operation_t;
  60. #define MBEDTLS_TRANSPARENT_TEST_DRIVER_HASH_OPERATION_INIT \
  61. LIBTESTDRIVER1_MBEDTLS_PSA_HASH_OPERATION_INIT
  62. #else
  63. typedef mbedtls_psa_hash_operation_t
  64. mbedtls_transparent_test_driver_hash_operation_t;
  65. #define MBEDTLS_TRANSPARENT_TEST_DRIVER_HASH_OPERATION_INIT \
  66. MBEDTLS_PSA_HASH_OPERATION_INIT
  67. #endif /* MBEDTLS_TEST_LIBTESTDRIVER1 &&
  68. LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_HASH */
  69. typedef struct {
  70. unsigned int initialised : 1;
  71. mbedtls_transparent_test_driver_cipher_operation_t ctx;
  72. } mbedtls_opaque_test_driver_cipher_operation_t;
  73. #define MBEDTLS_OPAQUE_TEST_DRIVER_CIPHER_OPERATION_INIT \
  74. { 0, MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT }
  75. #endif /* PSA_CRYPTO_DRIVER_TEST */
  76. /* Define the context to be used for an operation that is executed through the
  77. * PSA Driver wrapper layer as the union of all possible driver's contexts.
  78. *
  79. * The union members are the driver's context structures, and the member names
  80. * are formatted as `'drivername'_ctx`. This allows for procedural generation
  81. * of both this file and the content of psa_crypto_driver_wrappers.c */
  82. typedef union {
  83. unsigned dummy; /* Make sure this union is always non-empty */
  84. mbedtls_psa_hash_operation_t mbedtls_ctx;
  85. #if defined(PSA_CRYPTO_DRIVER_TEST)
  86. mbedtls_transparent_test_driver_hash_operation_t test_driver_ctx;
  87. #endif
  88. } psa_driver_hash_context_t;
  89. typedef union {
  90. unsigned dummy; /* Make sure this union is always non-empty */
  91. mbedtls_psa_cipher_operation_t mbedtls_ctx;
  92. #if defined(PSA_CRYPTO_DRIVER_TEST)
  93. mbedtls_transparent_test_driver_cipher_operation_t transparent_test_driver_ctx;
  94. mbedtls_opaque_test_driver_cipher_operation_t opaque_test_driver_ctx;
  95. #endif
  96. } psa_driver_cipher_context_t;
  97. #endif /* PSA_CRYPTO_DRIVER_CONTEXTS_PRIMITIVES_H */
  98. /* End of automatically generated file. */