key_agreement.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Test driver for key agreement functions.
  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_KEY_AGREEMENT_H
  20. #define PSA_CRYPTO_TEST_DRIVERS_KEY_AGREEMENT_H
  21. #include "mbedtls/build_info.h"
  22. #if defined(PSA_CRYPTO_DRIVER_TEST)
  23. #include <psa/crypto_driver_common.h>
  24. typedef struct {
  25. /* If non-null, on success, copy this to the output. */
  26. void *forced_output;
  27. size_t forced_output_length;
  28. /* If not PSA_SUCCESS, return this error code instead of processing the
  29. * function call. */
  30. psa_status_t forced_status;
  31. /* Count the amount of times one of the signature driver functions is called. */
  32. unsigned long hits;
  33. } mbedtls_test_driver_key_agreement_hooks_t;
  34. #define MBEDTLS_TEST_DRIVER_KEY_AGREEMENT_INIT { NULL, 0, PSA_SUCCESS, 0 }
  35. static inline mbedtls_test_driver_key_agreement_hooks_t
  36. mbedtls_test_driver_key_agreement_hooks_init(void)
  37. {
  38. const mbedtls_test_driver_key_agreement_hooks_t
  39. v = MBEDTLS_TEST_DRIVER_KEY_AGREEMENT_INIT;
  40. return v;
  41. }
  42. extern mbedtls_test_driver_key_agreement_hooks_t
  43. mbedtls_test_driver_key_agreement_hooks;
  44. psa_status_t mbedtls_test_transparent_key_agreement(
  45. const psa_key_attributes_t *attributes,
  46. const uint8_t *key_buffer,
  47. size_t key_buffer_size,
  48. psa_algorithm_t alg,
  49. const uint8_t *peer_key,
  50. size_t peer_key_length,
  51. uint8_t *shared_secret,
  52. size_t shared_secret_size,
  53. size_t *shared_secret_length);
  54. psa_status_t mbedtls_test_opaque_key_agreement(
  55. const psa_key_attributes_t *attributes,
  56. const uint8_t *key_buffer,
  57. size_t key_buffer_size,
  58. psa_algorithm_t alg,
  59. const uint8_t *peer_key,
  60. size_t peer_key_length,
  61. uint8_t *shared_secret,
  62. size_t shared_secret_size,
  63. size_t *shared_secret_length);
  64. #endif /*PSA_CRYPTO_DRIVER_TEST */
  65. #endif /* PSA_CRYPTO_TEST_DRIVERS_KEY_AGREEMENT_H */