blob: a7c5873f2670a5fc2a1875adc55b770e0f28fca3 [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(
52 const psa_key_attributes_t *attributes,
53 const uint8_t *key_buffer,
54 size_t key_buffer_size,
55 psa_algorithm_t alg,
56 const uint8_t *input,
57 size_t input_length,
58 const uint8_t *salt,
59 size_t salt_length,
60 uint8_t *output,
61 size_t output_size,
62 size_t *output_length );
63
64psa_status_t mbedtls_test_opaque_asymmetric_encrypt(
65 const psa_key_attributes_t *attributes,
66 const uint8_t *key,
67 size_t key_length,
68 psa_algorithm_t alg,
69 const uint8_t *input,
70 size_t input_length,
71 const uint8_t *salt,
72 size_t salt_length,
73 uint8_t *output,
74 size_t output_size,
75 size_t *output_length);
76
77psa_status_t mbedtls_test_transparent_asymmetric_decrypt(
78 const psa_key_attributes_t *attributes,
79 const uint8_t *key_buffer,
80 size_t key_buffer_size,
81 psa_algorithm_t alg,
82 const uint8_t *input,
83 size_t input_length,
84 const uint8_t *salt,
85 size_t salt_length,
86 uint8_t *output,
87 size_t output_size,
88 size_t *output_length );
89
90psa_status_t mbedtls_test_opaque_asymmetric_decrypt(
91 const psa_key_attributes_t *attributes,
92 const uint8_t *key,
93 size_t key_length,
94 psa_algorithm_t alg,
95 const uint8_t *input,
96 size_t input_length,
97 const uint8_t *salt,
98 size_t salt_length,
99 uint8_t *output,
100 size_t output_size,
101 size_t *output_length);
102
103#endif /* PSA_CRYPTO_DRIVER_TEST */
104#endif /* PSA_CRYPTO_TEST_DRIVERS_ASYM_H */