blob: d292ca0daf5f7279218a32dccb2622d6e85fe926 [file] [log] [blame]
Przemek Stekield3da0402022-11-22 13:53:26 +01001/*
2 * Test driver for PAKE driver entry points.
3 */
4/* Copyright The Mbed TLS Contributors
Dave Rodgman16799db2023-11-02 19:47:20 +00005 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
Przemek Stekield3da0402022-11-22 13:53:26 +01006 */
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
16typedef struct {
17 /* If not PSA_SUCCESS, return this error code instead of processing the
18 * function call. */
19 psa_status_t forced_status;
Przemek Stekiel95629ab2022-12-14 08:22:25 +010020 /* 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;
Przemek Stekield3da0402022-11-22 13:53:26 +010023 /* Count the amount of times PAKE driver functions are called. */
Przemek Stekield59d2a42023-02-22 11:02:40 +010024 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;
Przemek Stekield3da0402022-11-22 13:53:26 +010032 /* 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
Przemek Stekiel083745e2023-02-23 17:28:23 +010039#define MBEDTLS_TEST_DRIVER_PAKE_INIT { PSA_SUCCESS, PSA_SUCCESS, { 0, 0, 0, 0, 0, 0 }, PSA_SUCCESS, \
40 NULL, 0 }
Przemek Stekield3da0402022-11-22 13:53:26 +010041static inline mbedtls_test_driver_pake_hooks_t
42mbedtls_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
48extern mbedtls_test_driver_pake_hooks_t mbedtls_test_driver_pake_hooks;
49
50psa_status_t mbedtls_test_transparent_pake_setup(
51 mbedtls_transparent_test_driver_pake_operation_t *operation,
Przemek Stekiel51eac532022-12-07 11:04:51 +010052 const psa_crypto_driver_pake_inputs_t *inputs);
Przemek Stekield3da0402022-11-22 13:53:26 +010053
54psa_status_t mbedtls_test_transparent_pake_output(
55 mbedtls_transparent_test_driver_pake_operation_t *operation,
Przemek Stekiel251e86a2023-02-17 14:30:50 +010056 psa_crypto_driver_pake_step_t step,
Przemek Stekield3da0402022-11-22 13:53:26 +010057 uint8_t *output,
58 size_t output_size,
59 size_t *output_length);
60
61psa_status_t mbedtls_test_transparent_pake_input(
62 mbedtls_transparent_test_driver_pake_operation_t *operation,
Przemek Stekiel251e86a2023-02-17 14:30:50 +010063 psa_crypto_driver_pake_step_t step,
Przemek Stekield3da0402022-11-22 13:53:26 +010064 const uint8_t *input,
65 size_t input_length);
66
67psa_status_t mbedtls_test_transparent_pake_get_implicit_key(
68 mbedtls_transparent_test_driver_pake_operation_t *operation,
Przemek Stekiel6b648622023-02-19 22:55:33 +010069 uint8_t *output, size_t output_size, size_t *output_length);
Przemek Stekield3da0402022-11-22 13:53:26 +010070
71psa_status_t mbedtls_test_transparent_pake_abort(
72 mbedtls_transparent_test_driver_pake_operation_t *operation);
73
Przemek Stekield3da0402022-11-22 13:53:26 +010074#endif /* PSA_CRYPTO_DRIVER_TEST */
75#endif /* PSA_CRYPTO_TEST_DRIVERS_PAKE_H */