Przemek Stekiel | d3da040 | 2022-11-22 13:53:26 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 28 | typedef struct { |
| 29 | /* If not PSA_SUCCESS, return this error code instead of processing the |
| 30 | * function call. */ |
| 31 | psa_status_t forced_status; |
Przemek Stekiel | 95629ab | 2022-12-14 08:22:25 +0100 | [diff] [blame] | 32 | /* 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 Stekiel | d3da040 | 2022-11-22 13:53:26 +0100 | [diff] [blame] | 35 | /* 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 Stekiel | 95629ab | 2022-12-14 08:22:25 +0100 | [diff] [blame] | 44 | #define MBEDTLS_TEST_DRIVER_PAKE_INIT { PSA_SUCCESS, PSA_SUCCESS, 0, PSA_SUCCESS, NULL, 0 } |
Przemek Stekiel | d3da040 | 2022-11-22 13:53:26 +0100 | [diff] [blame] | 45 | static inline mbedtls_test_driver_pake_hooks_t |
| 46 | mbedtls_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 | |
| 52 | extern mbedtls_test_driver_pake_hooks_t mbedtls_test_driver_pake_hooks; |
| 53 | |
| 54 | psa_status_t mbedtls_test_transparent_pake_setup( |
| 55 | mbedtls_transparent_test_driver_pake_operation_t *operation, |
Przemek Stekiel | 51eac53 | 2022-12-07 11:04:51 +0100 | [diff] [blame] | 56 | const psa_crypto_driver_pake_inputs_t *inputs); |
Przemek Stekiel | d3da040 | 2022-11-22 13:53:26 +0100 | [diff] [blame] | 57 | |
| 58 | psa_status_t mbedtls_test_transparent_pake_output( |
| 59 | mbedtls_transparent_test_driver_pake_operation_t *operation, |
Przemek Stekiel | 251e86a | 2023-02-17 14:30:50 +0100 | [diff] [blame^] | 60 | psa_crypto_driver_pake_step_t step, |
Przemek Stekiel | d3da040 | 2022-11-22 13:53:26 +0100 | [diff] [blame] | 61 | uint8_t *output, |
| 62 | size_t output_size, |
| 63 | size_t *output_length); |
| 64 | |
| 65 | psa_status_t mbedtls_test_transparent_pake_input( |
| 66 | mbedtls_transparent_test_driver_pake_operation_t *operation, |
Przemek Stekiel | 251e86a | 2023-02-17 14:30:50 +0100 | [diff] [blame^] | 67 | psa_crypto_driver_pake_step_t step, |
Przemek Stekiel | d3da040 | 2022-11-22 13:53:26 +0100 | [diff] [blame] | 68 | const uint8_t *input, |
| 69 | size_t input_length); |
| 70 | |
| 71 | psa_status_t mbedtls_test_transparent_pake_get_implicit_key( |
| 72 | mbedtls_transparent_test_driver_pake_operation_t *operation, |
Przemek Stekiel | 0c78180 | 2022-11-29 14:53:13 +0100 | [diff] [blame] | 73 | uint8_t *output, size_t *output_size); |
Przemek Stekiel | d3da040 | 2022-11-22 13:53:26 +0100 | [diff] [blame] | 74 | |
| 75 | psa_status_t mbedtls_test_transparent_pake_abort( |
| 76 | mbedtls_transparent_test_driver_pake_operation_t *operation); |
| 77 | |
| 78 | psa_status_t mbedtls_test_opaque_pake_setup( |
| 79 | mbedtls_opaque_test_driver_pake_operation_t *operation, |
Przemek Stekiel | 51eac53 | 2022-12-07 11:04:51 +0100 | [diff] [blame] | 80 | const psa_crypto_driver_pake_inputs_t *inputs); |
Przemek Stekiel | d3da040 | 2022-11-22 13:53:26 +0100 | [diff] [blame] | 81 | |
| 82 | psa_status_t mbedtls_test_opaque_set_password_key( |
| 83 | const psa_key_attributes_t *attributes, |
| 84 | mbedtls_opaque_test_driver_pake_operation_t *operation, |
| 85 | uint8_t *key_buffer, |
| 86 | size_t key_size); |
| 87 | |
| 88 | psa_status_t mbedtls_test_opaque_pake_set_user( |
| 89 | mbedtls_opaque_test_driver_pake_operation_t *operation, |
| 90 | const uint8_t *user_id, |
| 91 | size_t user_id_len); |
| 92 | |
| 93 | psa_status_t mbedtls_test_opaque_pake_set_peer( |
| 94 | mbedtls_opaque_test_driver_pake_operation_t *operation, |
| 95 | const uint8_t *peer_id, |
| 96 | size_t peer_id_len); |
| 97 | |
| 98 | psa_status_t mbedtls_test_opaque_pake_set_role( |
| 99 | mbedtls_opaque_test_driver_pake_operation_t *operation, |
| 100 | psa_pake_role_t role); |
| 101 | |
| 102 | psa_status_t mbedtls_test_opaque_pake_output( |
| 103 | mbedtls_opaque_test_driver_pake_operation_t *operation, |
Przemek Stekiel | 251e86a | 2023-02-17 14:30:50 +0100 | [diff] [blame^] | 104 | psa_crypto_driver_pake_step_t step, |
Przemek Stekiel | d3da040 | 2022-11-22 13:53:26 +0100 | [diff] [blame] | 105 | uint8_t *output, |
| 106 | size_t output_size, |
| 107 | size_t *output_length); |
| 108 | |
| 109 | psa_status_t mbedtls_test_opaque_pake_input( |
| 110 | mbedtls_opaque_test_driver_pake_operation_t *operation, |
Przemek Stekiel | 251e86a | 2023-02-17 14:30:50 +0100 | [diff] [blame^] | 111 | psa_crypto_driver_pake_step_t step, |
Przemek Stekiel | d3da040 | 2022-11-22 13:53:26 +0100 | [diff] [blame] | 112 | const uint8_t *input, |
| 113 | size_t input_length); |
| 114 | |
| 115 | psa_status_t mbedtls_test_opaque_pake_get_implicit_key( |
| 116 | mbedtls_opaque_test_driver_pake_operation_t *operation, |
Przemek Stekiel | 0c78180 | 2022-11-29 14:53:13 +0100 | [diff] [blame] | 117 | uint8_t *output, size_t *output_size); |
Przemek Stekiel | d3da040 | 2022-11-22 13:53:26 +0100 | [diff] [blame] | 118 | |
| 119 | psa_status_t mbedtls_test_opaque_pake_abort( |
| 120 | mbedtls_opaque_test_driver_pake_operation_t *operation); |
| 121 | |
| 122 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 123 | #endif /* PSA_CRYPTO_TEST_DRIVERS_PAKE_H */ |