1 /*
2 * Test driver for key agreement functions.
3 */
4 /* Copyright The Mbed TLS Contributors
5 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
6 */
7
8 #ifndef PSA_CRYPTO_TEST_DRIVERS_KEY_AGREEMENT_H
9 #define PSA_CRYPTO_TEST_DRIVERS_KEY_AGREEMENT_H
10
11 #include "mbedtls/build_info.h"
12
13 #if defined(PSA_CRYPTO_DRIVER_TEST)
14 #include <psa/crypto_driver_common.h>
15
16 typedef struct {
17 /* If non-null, on success, copy this to the output. */
18 void *forced_output;
19 size_t forced_output_length;
20 /* If not PSA_SUCCESS, return this error code instead of processing the
21 * function call. */
22 psa_status_t forced_status;
23 /* Count the amount of times one of the signature driver functions is called. */
24 unsigned long hits;
25 } mbedtls_test_driver_key_agreement_hooks_t;
26
27 #define MBEDTLS_TEST_DRIVER_KEY_AGREEMENT_INIT { NULL, 0, PSA_SUCCESS, 0 }
28 static inline mbedtls_test_driver_key_agreement_hooks_t
mbedtls_test_driver_key_agreement_hooks_init(void)29 mbedtls_test_driver_key_agreement_hooks_init(void)
30 {
31 const mbedtls_test_driver_key_agreement_hooks_t
32 v = MBEDTLS_TEST_DRIVER_KEY_AGREEMENT_INIT;
33 return v;
34 }
35
36 extern mbedtls_test_driver_key_agreement_hooks_t
37 mbedtls_test_driver_key_agreement_hooks;
38
39 psa_status_t mbedtls_test_transparent_key_agreement(
40 const psa_key_attributes_t *attributes,
41 const uint8_t *key_buffer,
42 size_t key_buffer_size,
43 psa_algorithm_t alg,
44 const uint8_t *peer_key,
45 size_t peer_key_length,
46 uint8_t *shared_secret,
47 size_t shared_secret_size,
48 size_t *shared_secret_length);
49
50 psa_status_t mbedtls_test_opaque_key_agreement(
51 const psa_key_attributes_t *attributes,
52 const uint8_t *key_buffer,
53 size_t key_buffer_size,
54 psa_algorithm_t alg,
55 const uint8_t *peer_key,
56 size_t peer_key_length,
57 uint8_t *shared_secret,
58 size_t shared_secret_size,
59 size_t *shared_secret_length);
60
61 #endif /*PSA_CRYPTO_DRIVER_TEST */
62 #endif /* PSA_CRYPTO_TEST_DRIVERS_KEY_AGREEMENT_H */
63