blob: 81e87113b537bf23a029b752eb1468a37b6d9386 [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;
32 /* Count the amount of times PAKE driver functions are called. */
33 unsigned long hits;
34 /* Status returned by the last PAKE driver function call. */
35 psa_status_t driver_status;
36 /* Output returned by pake_output */
37 void *forced_output;
38 size_t forced_output_length;
39} mbedtls_test_driver_pake_hooks_t;
40
41#define MBEDTLS_TEST_DRIVER_PAKE_INIT { 0, 0, 0, NULL, 0 }
42static inline mbedtls_test_driver_pake_hooks_t
43mbedtls_test_driver_pake_hooks_init(void)
44{
45 const mbedtls_test_driver_pake_hooks_t v = MBEDTLS_TEST_DRIVER_PAKE_INIT;
46 return v;
47}
48
49extern mbedtls_test_driver_pake_hooks_t mbedtls_test_driver_pake_hooks;
50
51psa_status_t mbedtls_test_transparent_pake_setup(
52 mbedtls_transparent_test_driver_pake_operation_t *operation,
53 const psa_pake_cipher_suite_t *cipher_suite);
54
55psa_status_t mbedtls_test_transparent_set_password_key(
56 const psa_key_attributes_t *attributes,
57 mbedtls_transparent_test_driver_pake_operation_t *operation,
58 uint8_t *key_buffer,
59 size_t key_size);
60
61psa_status_t mbedtls_test_transparent_pake_set_user(
62 mbedtls_transparent_test_driver_pake_operation_t *operation,
63 const uint8_t *user_id,
64 size_t user_id_len);
65
66psa_status_t mbedtls_test_transparent_pake_set_peer(
67 mbedtls_transparent_test_driver_pake_operation_t *operation,
68 const uint8_t *peer_id,
69 size_t peer_id_len);
70
71psa_status_t mbedtls_test_transparent_pake_set_role(
72 mbedtls_transparent_test_driver_pake_operation_t *operation,
73 psa_pake_role_t role);
74
75psa_status_t mbedtls_test_transparent_pake_output(
76 mbedtls_transparent_test_driver_pake_operation_t *operation,
77 psa_pake_step_t step,
78 uint8_t *output,
79 size_t output_size,
80 size_t *output_length);
81
82psa_status_t mbedtls_test_transparent_pake_input(
83 mbedtls_transparent_test_driver_pake_operation_t *operation,
84 psa_pake_step_t step,
85 const uint8_t *input,
86 size_t input_length);
87
88psa_status_t mbedtls_test_transparent_pake_get_implicit_key(
89 mbedtls_transparent_test_driver_pake_operation_t *operation,
90 psa_key_derivation_operation_t *output);
91
92psa_status_t mbedtls_test_transparent_pake_abort(
93 mbedtls_transparent_test_driver_pake_operation_t *operation);
94
95psa_status_t mbedtls_test_opaque_pake_setup(
96 mbedtls_opaque_test_driver_pake_operation_t *operation,
97 const psa_pake_cipher_suite_t *cipher_suite);
98
99psa_status_t mbedtls_test_opaque_set_password_key(
100 const psa_key_attributes_t *attributes,
101 mbedtls_opaque_test_driver_pake_operation_t *operation,
102 uint8_t *key_buffer,
103 size_t key_size);
104
105psa_status_t mbedtls_test_opaque_pake_set_user(
106 mbedtls_opaque_test_driver_pake_operation_t *operation,
107 const uint8_t *user_id,
108 size_t user_id_len);
109
110psa_status_t mbedtls_test_opaque_pake_set_peer(
111 mbedtls_opaque_test_driver_pake_operation_t *operation,
112 const uint8_t *peer_id,
113 size_t peer_id_len);
114
115psa_status_t mbedtls_test_opaque_pake_set_role(
116 mbedtls_opaque_test_driver_pake_operation_t *operation,
117 psa_pake_role_t role);
118
119psa_status_t mbedtls_test_opaque_pake_output(
120 mbedtls_opaque_test_driver_pake_operation_t *operation,
121 psa_pake_step_t step,
122 uint8_t *output,
123 size_t output_size,
124 size_t *output_length);
125
126psa_status_t mbedtls_test_opaque_pake_input(
127 mbedtls_opaque_test_driver_pake_operation_t *operation,
128 psa_pake_step_t step,
129 const uint8_t *input,
130 size_t input_length);
131
132psa_status_t mbedtls_test_opaque_pake_get_implicit_key(
133 mbedtls_opaque_test_driver_pake_operation_t *operation,
134 psa_key_derivation_operation_t *output);
135
136psa_status_t mbedtls_test_opaque_pake_abort(
137 mbedtls_opaque_test_driver_pake_operation_t *operation);
138
139#endif /* PSA_CRYPTO_DRIVER_TEST */
140#endif /* PSA_CRYPTO_TEST_DRIVERS_PAKE_H */