crypto_driver_contexts_primitives.h 4.0 KB

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