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, |
| 53 | const psa_pake_cipher_suite_t *cipher_suite); |
| 54 | |
| 55 | psa_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 | |
| 61 | psa_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 | |
| 66 | psa_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 | |
| 71 | psa_status_t mbedtls_test_transparent_pake_set_role( |
| 72 | mbedtls_transparent_test_driver_pake_operation_t *operation, |
| 73 | psa_pake_role_t role); |
| 74 | |
| 75 | psa_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 | |
| 82 | psa_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 | |
| 88 | psa_status_t mbedtls_test_transparent_pake_get_implicit_key( |
| 89 | mbedtls_transparent_test_driver_pake_operation_t *operation, |
Przemek Stekiel | 0c78180 | 2022-11-29 14:53:13 +0100 | [diff] [blame^] | 90 | uint8_t *output, size_t *output_size); |
Przemek Stekiel | d3da040 | 2022-11-22 13:53:26 +0100 | [diff] [blame] | 91 | |
| 92 | psa_status_t mbedtls_test_transparent_pake_abort( |
| 93 | mbedtls_transparent_test_driver_pake_operation_t *operation); |
| 94 | |
| 95 | psa_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 | |
| 99 | psa_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 | |
| 105 | psa_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 | |
| 110 | psa_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 | |
| 115 | psa_status_t mbedtls_test_opaque_pake_set_role( |
| 116 | mbedtls_opaque_test_driver_pake_operation_t *operation, |
| 117 | psa_pake_role_t role); |
| 118 | |
| 119 | psa_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 | |
| 126 | psa_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 | |
| 132 | psa_status_t mbedtls_test_opaque_pake_get_implicit_key( |
| 133 | mbedtls_opaque_test_driver_pake_operation_t *operation, |
Przemek Stekiel | 0c78180 | 2022-11-29 14:53:13 +0100 | [diff] [blame^] | 134 | uint8_t *output, size_t *output_size); |
Przemek Stekiel | d3da040 | 2022-11-22 13:53:26 +0100 | [diff] [blame] | 135 | |
| 136 | psa_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 */ |