psa_crypto_invasive.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /**
  2. * \file psa_crypto_invasive.h
  3. *
  4. * \brief PSA cryptography module: invasive interfaces for test only.
  5. *
  6. * The interfaces in this file are intended for testing purposes only.
  7. * They MUST NOT be made available to clients over IPC in integrations
  8. * with isolation, and they SHOULD NOT be made available in library
  9. * integrations except when building the library for testing.
  10. */
  11. /*
  12. * Copyright The Mbed TLS Contributors
  13. * SPDX-License-Identifier: Apache-2.0
  14. *
  15. * Licensed under the Apache License, Version 2.0 (the "License"); you may
  16. * not use this file except in compliance with the License.
  17. * You may obtain a copy of the License at
  18. *
  19. * http://www.apache.org/licenses/LICENSE-2.0
  20. *
  21. * Unless required by applicable law or agreed to in writing, software
  22. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  23. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  24. * See the License for the specific language governing permissions and
  25. * limitations under the License.
  26. */
  27. #ifndef PSA_CRYPTO_INVASIVE_H
  28. #define PSA_CRYPTO_INVASIVE_H
  29. #include "mbedtls/build_info.h"
  30. #include "psa/crypto.h"
  31. #include "common.h"
  32. #include "mbedtls/entropy.h"
  33. #if !defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
  34. /** \brief Configure entropy sources.
  35. *
  36. * This function may only be called before a call to psa_crypto_init(),
  37. * or after a call to mbedtls_psa_crypto_free() and before any
  38. * subsequent call to psa_crypto_init().
  39. *
  40. * This function is only intended for test purposes. The functionality
  41. * it provides is also useful for system integrators, but
  42. * system integrators should configure entropy drivers instead of
  43. * breaking through to the Mbed TLS API.
  44. *
  45. * \param entropy_init Function to initialize the entropy context
  46. * and set up the desired entropy sources.
  47. * It is called by psa_crypto_init().
  48. * By default this is mbedtls_entropy_init().
  49. * This function cannot report failures directly.
  50. * To indicate a failure, set the entropy context
  51. * to a state where mbedtls_entropy_func() will
  52. * return an error.
  53. * \param entropy_free Function to free the entropy context
  54. * and associated resources.
  55. * It is called by mbedtls_psa_crypto_free().
  56. * By default this is mbedtls_entropy_free().
  57. *
  58. * \retval #PSA_SUCCESS
  59. * Success.
  60. * \retval #PSA_ERROR_NOT_PERMITTED
  61. * The caller does not have the permission to configure
  62. * entropy sources.
  63. * \retval #PSA_ERROR_BAD_STATE
  64. * The library has already been initialized.
  65. */
  66. psa_status_t mbedtls_psa_crypto_configure_entropy_sources(
  67. void (* entropy_init)(mbedtls_entropy_context *ctx),
  68. void (* entropy_free)(mbedtls_entropy_context *ctx));
  69. #endif /* !defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) */
  70. #if defined(MBEDTLS_TEST_HOOKS) && defined(MBEDTLS_PSA_CRYPTO_C)
  71. psa_status_t psa_mac_key_can_do(
  72. psa_algorithm_t algorithm,
  73. psa_key_type_t key_type);
  74. #endif /* MBEDTLS_TEST_HOOKS && MBEDTLS_PSA_CRYPTO_C */
  75. #endif /* PSA_CRYPTO_INVASIVE_H */