blob: 1f530081a5dbff4eef602ec6be1cd7cca724c2d1 [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
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
20#ifndef PSA_CRYPTO_TEST_DRIVERS_PAKE_H
21#define PSA_CRYPTO_TEST_DRIVERS_PAKE_H
22
23#include "mbedtls/build_info.h"
24
25#if defined(PSA_CRYPTO_DRIVER_TEST)
26#include <psa/crypto_driver_common.h>
27
28typedef struct {
29 /* If not PSA_SUCCESS, return this error code instead of processing the
30 * function call. */
31 psa_status_t forced_status;
Przemek Stekiel95629ab2022-12-14 08:22:25 +010032 /* PAKE driver setup is executed on the first call to
33 pake_output/pake_input (added to distinguish forced statuses). */
34 psa_status_t forced_setup_status;
Przemek Stekield3da0402022-11-22 13:53:26 +010035 /* Count the amount of times PAKE driver functions are called. */
36 unsigned long hits;
37 /* Status returned by the last PAKE driver function call. */
38 psa_status_t driver_status;
39 /* Output returned by pake_output */
40 void *forced_output;
41 size_t forced_output_length;
42} mbedtls_test_driver_pake_hooks_t;
43
Przemek Stekiel95629ab2022-12-14 08:22:25 +010044#define MBEDTLS_TEST_DRIVER_PAKE_INIT { PSA_SUCCESS, PSA_SUCCESS, 0, PSA_SUCCESS, NULL, 0 }
Przemek Stekield3da0402022-11-22 13:53:26 +010045static inline mbedtls_test_driver_pake_hooks_t
46mbedtls_test_driver_pake_hooks_init(void)
47{
48 const mbedtls_test_driver_pake_hooks_t v = MBEDTLS_TEST_DRIVER_PAKE_INIT;
49 return v;
50}
51
52extern mbedtls_test_driver_pake_hooks_t mbedtls_test_driver_pake_hooks;
53
54psa_status_t mbedtls_test_transparent_pake_setup(
55 mbedtls_transparent_test_driver_pake_operation_t *operation,
Przemek Stekiel51eac532022-12-07 11:04:51 +010056 const psa_crypto_driver_pake_inputs_t *inputs);
Przemek Stekield3da0402022-11-22 13:53:26 +010057
58psa_status_t mbedtls_test_transparent_pake_output(
59 mbedtls_transparent_test_driver_pake_operation_t *operation,
60 psa_pake_step_t step,
Przemek Stekiele12ed362022-12-21 12:54:46 +010061 const psa_pake_computation_stage_t *computation_stage,
Przemek Stekield3da0402022-11-22 13:53:26 +010062 uint8_t *output,
63 size_t output_size,
64 size_t *output_length);
65
66psa_status_t mbedtls_test_transparent_pake_input(
67 mbedtls_transparent_test_driver_pake_operation_t *operation,
68 psa_pake_step_t step,
Przemek Stekiele12ed362022-12-21 12:54:46 +010069 const psa_pake_computation_stage_t *computation_stage,
Przemek Stekield3da0402022-11-22 13:53:26 +010070 const uint8_t *input,
71 size_t input_length);
72
73psa_status_t mbedtls_test_transparent_pake_get_implicit_key(
74 mbedtls_transparent_test_driver_pake_operation_t *operation,
Przemek Stekiel0c781802022-11-29 14:53:13 +010075 uint8_t *output, size_t *output_size);
Przemek Stekield3da0402022-11-22 13:53:26 +010076
77psa_status_t mbedtls_test_transparent_pake_abort(
78 mbedtls_transparent_test_driver_pake_operation_t *operation);
79
80psa_status_t mbedtls_test_opaque_pake_setup(
81 mbedtls_opaque_test_driver_pake_operation_t *operation,
Przemek Stekiel51eac532022-12-07 11:04:51 +010082 const psa_crypto_driver_pake_inputs_t *inputs);
Przemek Stekield3da0402022-11-22 13:53:26 +010083
84psa_status_t mbedtls_test_opaque_set_password_key(
85 const psa_key_attributes_t *attributes,
86 mbedtls_opaque_test_driver_pake_operation_t *operation,
87 uint8_t *key_buffer,
88 size_t key_size);
89
90psa_status_t mbedtls_test_opaque_pake_set_user(
91 mbedtls_opaque_test_driver_pake_operation_t *operation,
92 const uint8_t *user_id,
93 size_t user_id_len);
94
95psa_status_t mbedtls_test_opaque_pake_set_peer(
96 mbedtls_opaque_test_driver_pake_operation_t *operation,
97 const uint8_t *peer_id,
98 size_t peer_id_len);
99
100psa_status_t mbedtls_test_opaque_pake_set_role(
101 mbedtls_opaque_test_driver_pake_operation_t *operation,
102 psa_pake_role_t role);
103
104psa_status_t mbedtls_test_opaque_pake_output(
105 mbedtls_opaque_test_driver_pake_operation_t *operation,
106 psa_pake_step_t step,
Przemek Stekiele12ed362022-12-21 12:54:46 +0100107 const psa_pake_computation_stage_t *computation_stage,
Przemek Stekield3da0402022-11-22 13:53:26 +0100108 uint8_t *output,
109 size_t output_size,
110 size_t *output_length);
111
112psa_status_t mbedtls_test_opaque_pake_input(
113 mbedtls_opaque_test_driver_pake_operation_t *operation,
114 psa_pake_step_t step,
Przemek Stekiele12ed362022-12-21 12:54:46 +0100115 const psa_pake_computation_stage_t *computation_stage,
Przemek Stekield3da0402022-11-22 13:53:26 +0100116 const uint8_t *input,
117 size_t input_length);
118
119psa_status_t mbedtls_test_opaque_pake_get_implicit_key(
120 mbedtls_opaque_test_driver_pake_operation_t *operation,
Przemek Stekiel0c781802022-11-29 14:53:13 +0100121 uint8_t *output, size_t *output_size);
Przemek Stekield3da0402022-11-22 13:53:26 +0100122
123psa_status_t mbedtls_test_opaque_pake_abort(
124 mbedtls_opaque_test_driver_pake_operation_t *operation);
125
126#endif /* PSA_CRYPTO_DRIVER_TEST */
127#endif /* PSA_CRYPTO_TEST_DRIVERS_PAKE_H */