1 /*
2 * Test driver for PAKE driver entry points.
3 */
4 /* Copyright The Mbed TLS Contributors
5 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
6 */
7
8 #ifndef PSA_CRYPTO_TEST_DRIVERS_PAKE_H
9 #define PSA_CRYPTO_TEST_DRIVERS_PAKE_H
10
11 #include "mbedtls/build_info.h"
12
13 #if defined(PSA_CRYPTO_DRIVER_TEST)
14 #include <psa/crypto_driver_common.h>
15
16 typedef struct {
17 /* If not PSA_SUCCESS, return this error code instead of processing the
18 * function call. */
19 psa_status_t forced_status;
20 /* PAKE driver setup is executed on the first call to
21 pake_output/pake_input (added to distinguish forced statuses). */
22 psa_status_t forced_setup_status;
23 /* Count the amount of times PAKE driver functions are called. */
24 struct {
25 unsigned long total;
26 unsigned long setup;
27 unsigned long input;
28 unsigned long output;
29 unsigned long implicit_key;
30 unsigned long abort;
31 } hits;
32 /* Status returned by the last PAKE driver function call. */
33 psa_status_t driver_status;
34 /* Output returned by pake_output */
35 void *forced_output;
36 size_t forced_output_length;
37 } mbedtls_test_driver_pake_hooks_t;
38
39 #define MBEDTLS_TEST_DRIVER_PAKE_INIT { PSA_SUCCESS, PSA_SUCCESS, { 0, 0, 0, 0, 0, 0 }, PSA_SUCCESS, \
40 NULL, 0 }
41 static inline mbedtls_test_driver_pake_hooks_t
mbedtls_test_driver_pake_hooks_init(void)42 mbedtls_test_driver_pake_hooks_init(void)
43 {
44 const mbedtls_test_driver_pake_hooks_t v = MBEDTLS_TEST_DRIVER_PAKE_INIT;
45 return v;
46 }
47
48 extern mbedtls_test_driver_pake_hooks_t mbedtls_test_driver_pake_hooks;
49
50 psa_status_t mbedtls_test_transparent_pake_setup(
51 mbedtls_transparent_test_driver_pake_operation_t *operation,
52 const psa_crypto_driver_pake_inputs_t *inputs);
53
54 psa_status_t mbedtls_test_transparent_pake_output(
55 mbedtls_transparent_test_driver_pake_operation_t *operation,
56 psa_crypto_driver_pake_step_t step,
57 uint8_t *output,
58 size_t output_size,
59 size_t *output_length);
60
61 psa_status_t mbedtls_test_transparent_pake_input(
62 mbedtls_transparent_test_driver_pake_operation_t *operation,
63 psa_crypto_driver_pake_step_t step,
64 const uint8_t *input,
65 size_t input_length);
66
67 psa_status_t mbedtls_test_transparent_pake_get_implicit_key(
68 mbedtls_transparent_test_driver_pake_operation_t *operation,
69 uint8_t *output, size_t output_size, size_t *output_length);
70
71 psa_status_t mbedtls_test_transparent_pake_abort(
72 mbedtls_transparent_test_driver_pake_operation_t *operation);
73
74 #endif /* PSA_CRYPTO_DRIVER_TEST */
75 #endif /* PSA_CRYPTO_TEST_DRIVERS_PAKE_H */
76