blob: 331ee49da740bb29f5f7a300ef2df54aa08fefc2 [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. */
Przemek Stekield59d2a42023-02-22 11:02:40 +010036 struct {
37 unsigned long total;
38 unsigned long setup;
39 unsigned long input;
40 unsigned long output;
41 unsigned long implicit_key;
42 unsigned long abort;
43 } hits;
Przemek Stekield3da0402022-11-22 13:53:26 +010044 /* Status returned by the last PAKE driver function call. */
45 psa_status_t driver_status;
46 /* Output returned by pake_output */
47 void *forced_output;
48 size_t forced_output_length;
49} mbedtls_test_driver_pake_hooks_t;
50
Przemek Stekiel083745e2023-02-23 17:28:23 +010051#define MBEDTLS_TEST_DRIVER_PAKE_INIT { PSA_SUCCESS, PSA_SUCCESS, { 0, 0, 0, 0, 0, 0 }, PSA_SUCCESS, \
52 NULL, 0 }
Przemek Stekield3da0402022-11-22 13:53:26 +010053static inline mbedtls_test_driver_pake_hooks_t
54mbedtls_test_driver_pake_hooks_init(void)
55{
56 const mbedtls_test_driver_pake_hooks_t v = MBEDTLS_TEST_DRIVER_PAKE_INIT;
57 return v;
58}
59
60extern mbedtls_test_driver_pake_hooks_t mbedtls_test_driver_pake_hooks;
61
62psa_status_t mbedtls_test_transparent_pake_setup(
63 mbedtls_transparent_test_driver_pake_operation_t *operation,
Przemek Stekiel51eac532022-12-07 11:04:51 +010064 const psa_crypto_driver_pake_inputs_t *inputs);
Przemek Stekield3da0402022-11-22 13:53:26 +010065
66psa_status_t mbedtls_test_transparent_pake_output(
67 mbedtls_transparent_test_driver_pake_operation_t *operation,
Przemek Stekiel251e86a2023-02-17 14:30:50 +010068 psa_crypto_driver_pake_step_t step,
Przemek Stekield3da0402022-11-22 13:53:26 +010069 uint8_t *output,
70 size_t output_size,
71 size_t *output_length);
72
73psa_status_t mbedtls_test_transparent_pake_input(
74 mbedtls_transparent_test_driver_pake_operation_t *operation,
Przemek Stekiel251e86a2023-02-17 14:30:50 +010075 psa_crypto_driver_pake_step_t step,
Przemek Stekield3da0402022-11-22 13:53:26 +010076 const uint8_t *input,
77 size_t input_length);
78
79psa_status_t mbedtls_test_transparent_pake_get_implicit_key(
80 mbedtls_transparent_test_driver_pake_operation_t *operation,
Przemek Stekiel6b648622023-02-19 22:55:33 +010081 uint8_t *output, size_t output_size, size_t *output_length);
Przemek Stekield3da0402022-11-22 13:53:26 +010082
83psa_status_t mbedtls_test_transparent_pake_abort(
84 mbedtls_transparent_test_driver_pake_operation_t *operation);
85
Przemek Stekield3da0402022-11-22 13:53:26 +010086#endif /* PSA_CRYPTO_DRIVER_TEST */
87#endif /* PSA_CRYPTO_TEST_DRIVERS_PAKE_H */