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; |
| 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 } |
| 42 | static inline mbedtls_test_driver_pake_hooks_t |
| 43 | mbedtls_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 | |
| 49 | extern mbedtls_test_driver_pake_hooks_t mbedtls_test_driver_pake_hooks; |
| 50 | |
| 51 | psa_status_t mbedtls_test_transparent_pake_setup( |
| 52 | mbedtls_transparent_test_driver_pake_operation_t *operation, |
Przemek Stekiel | 51eac53 | 2022-12-07 11:04:51 +0100 | [diff] [blame^] | 53 | const psa_crypto_driver_pake_inputs_t *inputs); |
Przemek Stekiel | d3da040 | 2022-11-22 13:53:26 +0100 | [diff] [blame] | 54 | |
| 55 | psa_status_t mbedtls_test_transparent_pake_output( |
| 56 | mbedtls_transparent_test_driver_pake_operation_t *operation, |
| 57 | psa_pake_step_t step, |
| 58 | uint8_t *output, |
| 59 | size_t output_size, |
| 60 | size_t *output_length); |
| 61 | |
| 62 | psa_status_t mbedtls_test_transparent_pake_input( |
| 63 | mbedtls_transparent_test_driver_pake_operation_t *operation, |
| 64 | psa_pake_step_t step, |
| 65 | const uint8_t *input, |
| 66 | size_t input_length); |
| 67 | |
| 68 | psa_status_t mbedtls_test_transparent_pake_get_implicit_key( |
| 69 | mbedtls_transparent_test_driver_pake_operation_t *operation, |
Przemek Stekiel | 0c78180 | 2022-11-29 14:53:13 +0100 | [diff] [blame] | 70 | uint8_t *output, size_t *output_size); |
Przemek Stekiel | d3da040 | 2022-11-22 13:53:26 +0100 | [diff] [blame] | 71 | |
| 72 | psa_status_t mbedtls_test_transparent_pake_abort( |
| 73 | mbedtls_transparent_test_driver_pake_operation_t *operation); |
| 74 | |
| 75 | psa_status_t mbedtls_test_opaque_pake_setup( |
| 76 | mbedtls_opaque_test_driver_pake_operation_t *operation, |
Przemek Stekiel | 51eac53 | 2022-12-07 11:04:51 +0100 | [diff] [blame^] | 77 | const psa_crypto_driver_pake_inputs_t *inputs); |
Przemek Stekiel | d3da040 | 2022-11-22 13:53:26 +0100 | [diff] [blame] | 78 | |
| 79 | psa_status_t mbedtls_test_opaque_set_password_key( |
| 80 | const psa_key_attributes_t *attributes, |
| 81 | mbedtls_opaque_test_driver_pake_operation_t *operation, |
| 82 | uint8_t *key_buffer, |
| 83 | size_t key_size); |
| 84 | |
| 85 | psa_status_t mbedtls_test_opaque_pake_set_user( |
| 86 | mbedtls_opaque_test_driver_pake_operation_t *operation, |
| 87 | const uint8_t *user_id, |
| 88 | size_t user_id_len); |
| 89 | |
| 90 | psa_status_t mbedtls_test_opaque_pake_set_peer( |
| 91 | mbedtls_opaque_test_driver_pake_operation_t *operation, |
| 92 | const uint8_t *peer_id, |
| 93 | size_t peer_id_len); |
| 94 | |
| 95 | psa_status_t mbedtls_test_opaque_pake_set_role( |
| 96 | mbedtls_opaque_test_driver_pake_operation_t *operation, |
| 97 | psa_pake_role_t role); |
| 98 | |
| 99 | psa_status_t mbedtls_test_opaque_pake_output( |
| 100 | mbedtls_opaque_test_driver_pake_operation_t *operation, |
| 101 | psa_pake_step_t step, |
| 102 | uint8_t *output, |
| 103 | size_t output_size, |
| 104 | size_t *output_length); |
| 105 | |
| 106 | psa_status_t mbedtls_test_opaque_pake_input( |
| 107 | mbedtls_opaque_test_driver_pake_operation_t *operation, |
| 108 | psa_pake_step_t step, |
| 109 | const uint8_t *input, |
| 110 | size_t input_length); |
| 111 | |
| 112 | psa_status_t mbedtls_test_opaque_pake_get_implicit_key( |
| 113 | mbedtls_opaque_test_driver_pake_operation_t *operation, |
Przemek Stekiel | 0c78180 | 2022-11-29 14:53:13 +0100 | [diff] [blame] | 114 | uint8_t *output, size_t *output_size); |
Przemek Stekiel | d3da040 | 2022-11-22 13:53:26 +0100 | [diff] [blame] | 115 | |
| 116 | psa_status_t mbedtls_test_opaque_pake_abort( |
| 117 | mbedtls_opaque_test_driver_pake_operation_t *operation); |
| 118 | |
| 119 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 120 | #endif /* PSA_CRYPTO_TEST_DRIVERS_PAKE_H */ |