aead.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Test driver for AEAD driver entry points.
  3. */
  4. /* Copyright The Mbed TLS Contributors
  5. * SPDX-License-Identifier: Apache-2.0
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License"); you may
  8. * not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. */
  19. #ifndef PSA_CRYPTO_TEST_DRIVERS_AEAD_H
  20. #define PSA_CRYPTO_TEST_DRIVERS_AEAD_H
  21. #if !defined(MBEDTLS_CONFIG_FILE)
  22. #include "mbedtls/config.h"
  23. #else
  24. #include MBEDTLS_CONFIG_FILE
  25. #endif
  26. #if defined(PSA_CRYPTO_DRIVER_TEST)
  27. #include <psa/crypto_driver_common.h>
  28. typedef struct {
  29. /* If not PSA_SUCCESS, return this error code instead of processing the
  30. * function call. */
  31. psa_status_t forced_status;
  32. /* Count the amount of times AEAD driver functions are called. */
  33. unsigned long hits;
  34. /* Status returned by the last AEAD driver function call. */
  35. psa_status_t driver_status;
  36. } mbedtls_test_driver_aead_hooks_t;
  37. #define MBEDTLS_TEST_DRIVER_AEAD_INIT { 0, 0, 0 }
  38. static inline mbedtls_test_driver_aead_hooks_t
  39. mbedtls_test_driver_aead_hooks_init( void )
  40. {
  41. const mbedtls_test_driver_aead_hooks_t v = MBEDTLS_TEST_DRIVER_AEAD_INIT;
  42. return( v );
  43. }
  44. extern mbedtls_test_driver_aead_hooks_t mbedtls_test_driver_aead_hooks;
  45. psa_status_t mbedtls_test_transparent_aead_encrypt(
  46. const psa_key_attributes_t *attributes,
  47. const uint8_t *key_buffer, size_t key_buffer_size,
  48. psa_algorithm_t alg,
  49. const uint8_t *nonce, size_t nonce_length,
  50. const uint8_t *additional_data, size_t additional_data_length,
  51. const uint8_t *plaintext, size_t plaintext_length,
  52. uint8_t *ciphertext, size_t ciphertext_size, size_t *ciphertext_length );
  53. psa_status_t mbedtls_test_transparent_aead_decrypt(
  54. const psa_key_attributes_t *attributes,
  55. const uint8_t *key_buffer, size_t key_buffer_size,
  56. psa_algorithm_t alg,
  57. const uint8_t *nonce, size_t nonce_length,
  58. const uint8_t *additional_data, size_t additional_data_length,
  59. const uint8_t *ciphertext, size_t ciphertext_length,
  60. uint8_t *plaintext, size_t plaintext_size, size_t *plaintext_length );
  61. #endif /* PSA_CRYPTO_DRIVER_TEST */
  62. #endif /* PSA_CRYPTO_TEST_DRIVERS_AEAD_H */