blob: 57de81ab1f233290b762b094db5b8cc81ab43063 [file] [log] [blame]
Aditya Deshpande17845b82022-10-13 17:21:01 +01001/*
2 * Test driver for key agreement functions.
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_KEY_AGREEMENT_H
21#define PSA_CRYPTO_TEST_DRIVERS_KEY_AGREEMENT_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 non-null, on success, copy this to the output. */
30 void *forced_output;
31 size_t forced_output_length;
32 /* If not PSA_SUCCESS, return this error code instead of processing the
33 * function call. */
34 psa_status_t forced_status;
35 /* Count the amount of times one of the signature driver functions is called. */
36 unsigned long hits;
37} mbedtls_test_driver_key_agreement_hooks_t;
38
39#define MBEDTLS_TEST_DRIVER_KEY_AGREEMENT_INIT { NULL, 0, PSA_SUCCESS, 0 }
40static inline mbedtls_test_driver_key_agreement_hooks_t
41 mbedtls_test_driver_key_agreement_hooks_init( void )
42{
43 const mbedtls_test_driver_key_agreement_hooks_t
44 v = MBEDTLS_TEST_DRIVER_KEY_AGREEMENT_INIT;
45 return( v );
46}
47
48psa_status_t mbedtls_test_transparent_key_agreement(
49 const psa_key_attributes_t *attributes,
50 const uint8_t *key_buffer,
51 size_t key_buffer_size,
52 psa_algorithm_t alg,
53 const uint8_t *peer_key,
54 size_t peer_key_length,
55 uint8_t *shared_secret,
56 size_t shared_secret_size,
57 size_t *shared_secret_length );
58
59psa_status_t mbedtls_test_opaque_key_agreement(
60 const psa_key_attributes_t *attributes,
61 const uint8_t *key_buffer,
62 size_t key_buffer_size,
63 psa_algorithm_t alg,
64 const uint8_t *peer_key,
65 size_t peer_key_length,
66 uint8_t *shared_secret,
67 size_t shared_secret_size,
68 size_t *shared_secret_length );
69
70#endif /*PSA_CRYPTO_DRIVER_TEST */
71#endif /* PSA_CRYPTO_TEST_DRIVERS_KEY_AGREEMENT_H */