blob: 82a9d8c94eea16605335c4c82f12767c8543b611 [file] [log] [blame]
Przemyslaw Stekiel2d18c7e2021-12-22 12:02:03 +01001/*
2 * Test driver for hash 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_ASYM_H
21#define PSA_CRYPTO_TEST_DRIVERS_ASYM_H
22
23#include "mbedtls/build_info.h"
24
25#if defined(PSA_CRYPTO_DRIVER_TEST)
26#include <psa/crypto_driver_common.h>
27#include <psa/crypto.h>
28
29typedef struct {
30 /* If non-null, on success, copy this to the output. */
31 void *forced_output;
32 size_t forced_output_length;
33 /* If not PSA_SUCCESS, return this error code instead of processing the
34 * function call. */
35 psa_status_t forced_status;
36 /* Count the amount of times one of the rsa driver functions is called. */
37 unsigned long hits;
38} mbedtls_test_driver_rsa_hooks_t;
39
40#define MBEDTLS_TEST_DRIVER_RSA_INIT { NULL, 0, PSA_SUCCESS, 0 }
41
42static inline mbedtls_test_driver_rsa_hooks_t
43 mbedtls_test_driver_rsa_hooks_init( void )
44{
45 const mbedtls_test_driver_rsa_hooks_t v = MBEDTLS_TEST_DRIVER_RSA_INIT;
46 return( v );
47}
48
49extern mbedtls_test_driver_rsa_hooks_t mbedtls_test_driver_rsa_hooks;
50
51psa_status_t mbedtls_test_transparent_asymmetric_encrypt(
Przemyslaw Stekiel4576b912022-02-02 11:10:46 +010052 const psa_key_attributes_t *attributes, const uint8_t *key_buffer,
53 size_t key_buffer_size, psa_algorithm_t alg, const uint8_t *input,
54 size_t input_length, const uint8_t *salt, size_t salt_length,
55 uint8_t *output, size_t output_size, size_t *output_length );
Przemyslaw Stekiel2d18c7e2021-12-22 12:02:03 +010056
57psa_status_t mbedtls_test_opaque_asymmetric_encrypt(
Przemyslaw Stekiel4576b912022-02-02 11:10:46 +010058 const psa_key_attributes_t *attributes, const uint8_t *key,
59 size_t key_length, psa_algorithm_t alg, const uint8_t *input,
60 size_t input_length, const uint8_t *salt, size_t salt_length,
61 uint8_t *output, size_t output_size, size_t *output_length );
Przemyslaw Stekiel2d18c7e2021-12-22 12:02:03 +010062
63psa_status_t mbedtls_test_transparent_asymmetric_decrypt(
Przemyslaw Stekiel4576b912022-02-02 11:10:46 +010064 const psa_key_attributes_t *attributes, const uint8_t *key_buffer,
65 size_t key_buffer_size, psa_algorithm_t alg, const uint8_t *input,
66 size_t input_length, const uint8_t *salt, size_t salt_length,
67 uint8_t *output, size_t output_size, size_t *output_length );
Przemyslaw Stekiel2d18c7e2021-12-22 12:02:03 +010068
69psa_status_t mbedtls_test_opaque_asymmetric_decrypt(
Przemyslaw Stekiel4576b912022-02-02 11:10:46 +010070 const psa_key_attributes_t *attributes, const uint8_t *key,
71 size_t key_length, psa_algorithm_t alg, const uint8_t *input,
72 size_t input_length, const uint8_t *salt, size_t salt_length,
73 uint8_t *output, size_t output_size, size_t *output_length );
Przemyslaw Stekiel2d18c7e2021-12-22 12:02:03 +010074
75#endif /* PSA_CRYPTO_DRIVER_TEST */
76#endif /* PSA_CRYPTO_TEST_DRIVERS_ASYM_H */