pake.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Test driver for PAKE 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_PAKE_H
  20. #define PSA_CRYPTO_TEST_DRIVERS_PAKE_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 not PSA_SUCCESS, return this error code instead of processing the
  26. * function call. */
  27. psa_status_t forced_status;
  28. /* PAKE driver setup is executed on the first call to
  29. pake_output/pake_input (added to distinguish forced statuses). */
  30. psa_status_t forced_setup_status;
  31. /* Count the amount of times PAKE driver functions are called. */
  32. struct {
  33. unsigned long total;
  34. unsigned long setup;
  35. unsigned long input;
  36. unsigned long output;
  37. unsigned long implicit_key;
  38. unsigned long abort;
  39. } hits;
  40. /* Status returned by the last PAKE driver function call. */
  41. psa_status_t driver_status;
  42. /* Output returned by pake_output */
  43. void *forced_output;
  44. size_t forced_output_length;
  45. } mbedtls_test_driver_pake_hooks_t;
  46. #define MBEDTLS_TEST_DRIVER_PAKE_INIT { PSA_SUCCESS, PSA_SUCCESS, { 0, 0, 0, 0, 0, 0 }, PSA_SUCCESS, \
  47. NULL, 0 }
  48. static inline mbedtls_test_driver_pake_hooks_t
  49. mbedtls_test_driver_pake_hooks_init(void)
  50. {
  51. const mbedtls_test_driver_pake_hooks_t v = MBEDTLS_TEST_DRIVER_PAKE_INIT;
  52. return v;
  53. }
  54. extern mbedtls_test_driver_pake_hooks_t mbedtls_test_driver_pake_hooks;
  55. psa_status_t mbedtls_test_transparent_pake_setup(
  56. mbedtls_transparent_test_driver_pake_operation_t *operation,
  57. const psa_crypto_driver_pake_inputs_t *inputs);
  58. psa_status_t mbedtls_test_transparent_pake_output(
  59. mbedtls_transparent_test_driver_pake_operation_t *operation,
  60. psa_crypto_driver_pake_step_t step,
  61. uint8_t *output,
  62. size_t output_size,
  63. size_t *output_length);
  64. psa_status_t mbedtls_test_transparent_pake_input(
  65. mbedtls_transparent_test_driver_pake_operation_t *operation,
  66. psa_crypto_driver_pake_step_t step,
  67. const uint8_t *input,
  68. size_t input_length);
  69. psa_status_t mbedtls_test_transparent_pake_get_implicit_key(
  70. mbedtls_transparent_test_driver_pake_operation_t *operation,
  71. uint8_t *output, size_t output_size, size_t *output_length);
  72. psa_status_t mbedtls_test_transparent_pake_abort(
  73. mbedtls_transparent_test_driver_pake_operation_t *operation);
  74. #endif /* PSA_CRYPTO_DRIVER_TEST */
  75. #endif /* PSA_CRYPTO_TEST_DRIVERS_PAKE_H */