2021-12-22 11:02:03 +00:00
|
|
|
/*
|
2022-03-07 09:14:07 +00:00
|
|
|
* Test driver for asymmetric encryption.
|
2021-12-22 11:02:03 +00:00
|
|
|
*/
|
|
|
|
/* Copyright The Mbed TLS Contributors
|
2023-11-02 19:47:20 +00:00
|
|
|
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
2021-12-22 11:02:03 +00:00
|
|
|
*/
|
|
|
|
|
2022-03-07 09:14:07 +00:00
|
|
|
#ifndef PSA_CRYPTO_TEST_DRIVERS_ASYMMETRIC_ENCRYPTION_H
|
|
|
|
#define PSA_CRYPTO_TEST_DRIVERS_ASYMMETRIC_ENCRYPTION_H
|
2021-12-22 11:02:03 +00:00
|
|
|
|
|
|
|
#include "mbedtls/build_info.h"
|
|
|
|
|
|
|
|
#if defined(PSA_CRYPTO_DRIVER_TEST)
|
|
|
|
#include <psa/crypto_driver_common.h>
|
|
|
|
#include <psa/crypto.h>
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
/* If non-null, on success, copy this to the output. */
|
|
|
|
void *forced_output;
|
|
|
|
size_t forced_output_length;
|
|
|
|
/* If not PSA_SUCCESS, return this error code instead of processing the
|
|
|
|
* function call. */
|
|
|
|
psa_status_t forced_status;
|
2022-03-08 09:48:35 +00:00
|
|
|
/* Count the amount of times one of the asymmetric_encryption driver
|
2022-03-07 09:14:07 +00:00
|
|
|
functions is called. */
|
2021-12-22 11:02:03 +00:00
|
|
|
unsigned long hits;
|
2022-03-07 09:14:07 +00:00
|
|
|
} mbedtls_test_driver_asymmetric_encryption_hooks_t;
|
2021-12-22 11:02:03 +00:00
|
|
|
|
2022-03-07 09:14:07 +00:00
|
|
|
#define MBEDTLS_TEST_DRIVER_ASYMMETRIC_ENCRYPTION_INIT { NULL, 0, PSA_SUCCESS, 0 }
|
2021-12-22 11:02:03 +00:00
|
|
|
|
2022-03-07 09:14:07 +00:00
|
|
|
static inline mbedtls_test_driver_asymmetric_encryption_hooks_t
|
2023-01-11 13:50:10 +00:00
|
|
|
mbedtls_test_driver_asymmetric_encryption_hooks_init(void)
|
2021-12-22 11:02:03 +00:00
|
|
|
{
|
2022-03-07 09:14:07 +00:00
|
|
|
const mbedtls_test_driver_asymmetric_encryption_hooks_t v =
|
|
|
|
MBEDTLS_TEST_DRIVER_ASYMMETRIC_ENCRYPTION_INIT;
|
2023-01-11 13:50:10 +00:00
|
|
|
return v;
|
2021-12-22 11:02:03 +00:00
|
|
|
}
|
|
|
|
|
2022-03-08 09:48:35 +00:00
|
|
|
extern mbedtls_test_driver_asymmetric_encryption_hooks_t
|
2022-03-07 09:14:07 +00:00
|
|
|
mbedtls_test_driver_asymmetric_encryption_hooks;
|
2021-12-22 11:02:03 +00:00
|
|
|
|
|
|
|
psa_status_t mbedtls_test_transparent_asymmetric_encrypt(
|
2022-02-02 10:10:46 +00:00
|
|
|
const psa_key_attributes_t *attributes, const uint8_t *key_buffer,
|
|
|
|
size_t key_buffer_size, psa_algorithm_t alg, const uint8_t *input,
|
|
|
|
size_t input_length, const uint8_t *salt, size_t salt_length,
|
2023-01-11 13:50:10 +00:00
|
|
|
uint8_t *output, size_t output_size, size_t *output_length);
|
2021-12-22 11:02:03 +00:00
|
|
|
|
|
|
|
psa_status_t mbedtls_test_opaque_asymmetric_encrypt(
|
2022-02-02 10:10:46 +00:00
|
|
|
const psa_key_attributes_t *attributes, const uint8_t *key,
|
|
|
|
size_t key_length, psa_algorithm_t alg, const uint8_t *input,
|
|
|
|
size_t input_length, const uint8_t *salt, size_t salt_length,
|
2023-01-11 13:50:10 +00:00
|
|
|
uint8_t *output, size_t output_size, size_t *output_length);
|
2021-12-22 11:02:03 +00:00
|
|
|
|
|
|
|
psa_status_t mbedtls_test_transparent_asymmetric_decrypt(
|
2022-02-02 10:10:46 +00:00
|
|
|
const psa_key_attributes_t *attributes, const uint8_t *key_buffer,
|
|
|
|
size_t key_buffer_size, psa_algorithm_t alg, const uint8_t *input,
|
|
|
|
size_t input_length, const uint8_t *salt, size_t salt_length,
|
2023-01-11 13:50:10 +00:00
|
|
|
uint8_t *output, size_t output_size, size_t *output_length);
|
2021-12-22 11:02:03 +00:00
|
|
|
|
|
|
|
psa_status_t mbedtls_test_opaque_asymmetric_decrypt(
|
2022-02-02 10:10:46 +00:00
|
|
|
const psa_key_attributes_t *attributes, const uint8_t *key,
|
|
|
|
size_t key_length, psa_algorithm_t alg, const uint8_t *input,
|
|
|
|
size_t input_length, const uint8_t *salt, size_t salt_length,
|
2023-01-11 13:50:10 +00:00
|
|
|
uint8_t *output, size_t output_size, size_t *output_length);
|
2021-12-22 11:02:03 +00:00
|
|
|
|
|
|
|
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
2022-03-07 09:14:07 +00:00
|
|
|
#endif /* PSA_CRYPTO_TEST_DRIVERS_ASYMMETRIC_ENCRYPTION_H */
|