asymmetric_encryption.h (2730B)
1 /* 2 * Test driver for asymmetric encryption. 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_ASYMMETRIC_ENCRYPTION_H 9 #define PSA_CRYPTO_TEST_DRIVERS_ASYMMETRIC_ENCRYPTION_H 10 11 #include "mbedtls/build_info.h" 12 13 #if defined(PSA_CRYPTO_DRIVER_TEST) 14 #include "test_driver_common.h" 15 16 #include <psa/crypto_driver_common.h> 17 #include <psa/crypto.h> 18 19 typedef struct { 20 /* If non-null, on success, copy this to the output. */ 21 void *forced_output; 22 size_t forced_output_length; 23 /* If not PSA_SUCCESS, return this error code instead of processing the 24 * function call. */ 25 psa_status_t forced_status; 26 /* Count the amount of times one of the asymmetric_encryption driver 27 functions is called. */ 28 unsigned long hits; 29 } mbedtls_test_driver_asymmetric_encryption_hooks_t; 30 31 #define MBEDTLS_TEST_DRIVER_ASYMMETRIC_ENCRYPTION_INIT { NULL, 0, PSA_SUCCESS, 0 } 32 33 static inline mbedtls_test_driver_asymmetric_encryption_hooks_t 34 mbedtls_test_driver_asymmetric_encryption_hooks_init(void) 35 { 36 const mbedtls_test_driver_asymmetric_encryption_hooks_t v = 37 MBEDTLS_TEST_DRIVER_ASYMMETRIC_ENCRYPTION_INIT; 38 return v; 39 } 40 41 extern mbedtls_test_driver_asymmetric_encryption_hooks_t 42 mbedtls_test_driver_asymmetric_encryption_hooks; 43 44 psa_status_t mbedtls_test_transparent_asymmetric_encrypt( 45 const psa_key_attributes_t *attributes, const uint8_t *key_buffer, 46 size_t key_buffer_size, psa_algorithm_t alg, const uint8_t *input, 47 size_t input_length, const uint8_t *salt, size_t salt_length, 48 uint8_t *output, size_t output_size, size_t *output_length); 49 50 psa_status_t mbedtls_test_opaque_asymmetric_encrypt( 51 const psa_key_attributes_t *attributes, const uint8_t *key, 52 size_t key_length, psa_algorithm_t alg, const uint8_t *input, 53 size_t input_length, const uint8_t *salt, size_t salt_length, 54 uint8_t *output, size_t output_size, size_t *output_length); 55 56 psa_status_t mbedtls_test_transparent_asymmetric_decrypt( 57 const psa_key_attributes_t *attributes, const uint8_t *key_buffer, 58 size_t key_buffer_size, psa_algorithm_t alg, const uint8_t *input, 59 size_t input_length, const uint8_t *salt, size_t salt_length, 60 uint8_t *output, size_t output_size, size_t *output_length); 61 62 psa_status_t mbedtls_test_opaque_asymmetric_decrypt( 63 const psa_key_attributes_t *attributes, const uint8_t *key, 64 size_t key_length, psa_algorithm_t alg, const uint8_t *input, 65 size_t input_length, const uint8_t *salt, size_t salt_length, 66 uint8_t *output, size_t output_size, size_t *output_length); 67 68 #endif /* PSA_CRYPTO_DRIVER_TEST */ 69 #endif /* PSA_CRYPTO_TEST_DRIVERS_ASYMMETRIC_ENCRYPTION_H */