Add preprocessor code, for compatibility with older mbedtls version, namely, now the inclusioin of header files in the private/ folder is conditional

Signed-off-by: Anton Matkin <[email protected]>
This commit is contained in:
Anton Matkin
2025-08-21 12:12:14 +02:00
parent cfd4b2cc53
commit 39b328e60b
13 changed files with 74 additions and 0 deletions
+4
View File
@@ -17,7 +17,11 @@
#if defined(MBEDTLS_BIGNUM_C)
#if MBEDTLS_VERSION_MAJOR >= 4
#include <mbedtls/private/bignum.h>
#else
#include <mbedtls/bignum.h>
#endif
#include <bignum_mod.h>
/** Allocate and populate a core MPI from a test case argument.
+4
View File
@@ -16,7 +16,11 @@
#include <psa/crypto_driver_common.h>
#include <psa/crypto.h>
#if MBEDTLS_MAJOR_VERSION >= 4
#include "mbedtls/private/cipher.h"
#else
#include "mbedtls/cipher.h"
#endif
typedef struct {
/* If non-null, on success, copy this to the output. */
+6
View File
@@ -51,7 +51,13 @@
#include <stdint.h>
#if defined(MBEDTLS_BIGNUM_C)
#if MBEDTLS_VERSION_MAJOR >= 4
#include "mbedtls/private/bignum.h"
#else
#include "mbedtls/bignum.h"
#endif
#endif
/** The type of test case arguments that contain binary data. */
+5
View File
@@ -17,7 +17,12 @@
#endif
#include <psa/crypto.h>
#if MBEDTLS_VERSION_MAJOR >= 4
#include <mbedtls/private/ctr_drbg.h>
#else
#include <mbedtls/ctr_drbg.h>
#endif
#if defined(MBEDTLS_PSA_CRYPTO_C)
/** Initialize the PSA Crypto subsystem. */
+5
View File
@@ -18,7 +18,12 @@
#include <stdlib.h>
#include <string.h>
#if MBEDTLS_VERSION_MAJOR >= 4
#include <mbedtls/private/bignum.h>
#else
#include <mbedtls/bignum.h>
#endif
#include <bignum_core.h>
#include <bignum_mod.h>
#include <bignum_mod_raw.h>
@@ -9,7 +9,13 @@
#if defined(PSA_CRYPTO_DRIVER_TEST)
#include "psa/crypto.h"
#if MBEDTLS_VERSION_MAJOR >= 4
#include "mbedtls/private/rsa.h"
#else
#include "mbedtls/rsa.h"
#endif
#include "psa_crypto_rsa.h"
#include "string.h"
#include "test/drivers/asymmetric_encryption.h"
+5
View File
@@ -12,7 +12,12 @@
#include "psa/crypto.h"
#include "psa_crypto_cipher.h"
#include "psa_crypto_core.h"
#if MBEDTLS_VERSION_MAJOR >= 4
#include "mbedtls/private/cipher.h"
#else
#include "mbedtls/cipher.h"
#endif
#include "test/drivers/cipher.h"
@@ -14,7 +14,13 @@
#include "psa_crypto_ecp.h"
#include "psa_crypto_rsa.h"
#include "psa_crypto_ffdh.h"
#if MBEDTLS_VERSION_MAJOR >= 4
#include "mbedtls/private/ecp.h"
#else
#include "mbedtls/ecp.h"
#endif
#include "mbedtls/error.h"
#include "test/drivers/key_management.h"
@@ -15,13 +15,22 @@
#include "psa_crypto_ecp.h"
#include "psa_crypto_hash.h"
#include "psa_crypto_rsa.h"
#if MBEDTLS_VERSION_MAJOR >= 4
#include "mbedtls/private/ecp.h"
#else
#include "mbedtls/ecp.h"
#endif
#include "test/drivers/hash.h"
#include "test/drivers/signature.h"
#include "test/drivers/hash.h"
#if MBEDTLS_VERSION_MAJOR >= 4
#include "mbedtls/private/ecdsa.h"
#else
#include "mbedtls/ecdsa.h"
#endif
#include "test/random.h"
+5
View File
@@ -58,7 +58,12 @@ psa_status_t mbedtls_psa_external_get_random(
#if defined(MBEDTLS_PLATFORM_GET_ENTROPY_ALT) || defined(MBEDTLS_PSA_DRIVER_GET_ENTROPY)
#include <test/random.h>
#if MBEDTLS_VERSION_MAJOR >= 4
#include <mbedtls/private/entropy.h>
#else
#include <mbedtls/entropy.h>
#endif
static int platform_get_entropy_force_failure;
static size_t platform_get_entropy_forced_entropy_content = SIZE_MAX;
+9
View File
@@ -14,7 +14,11 @@
#include <test/psa_crypto_helpers.h>
#if defined(MBEDTLS_CTR_DRBG_C)
#if MBEDTLS_VERSION_MAJOR >= 4
#include <mbedtls/private/ctr_drbg.h>
#else
#include <mbedtls/ctr_drbg.h>
#endif
#endif
#if defined(MBEDTLS_PSA_CRYPTO_C)
@@ -249,7 +253,12 @@ exit:
#if defined(MBEDTLS_PSA_INJECT_ENTROPY)
#if MBEDTLS_VERSION_MAJOR >= 4
#include <mbedtls/private/entropy.h>
#else
#include <mbedtls/entropy.h>
#endif
#include <psa_crypto_its.h>
int mbedtls_test_inject_entropy_seed_read(unsigned char *buf, size_t len)
+6
View File
@@ -25,7 +25,13 @@
#include <pk_internal.h>
#endif
#if defined(MBEDTLS_ECP_C)
#if MBEDTLS_VERSION_MAJOR >= 4
#include <mbedtls/private/ecp.h>
#else
#include <mbedtls/ecp.h>
#endif
#endif
#if defined(MBEDTLS_RSA_C)
#include <rsa_internal.h>
+4
View File
@@ -23,7 +23,11 @@
#include <test/random.h>
#include <string.h>
#if MBEDTLS_VERSION_MAJOR >= 4
#include <mbedtls/private/entropy.h>
#else
#include <mbedtls/entropy.h>
#endif
#include <alignment.h>
int mbedtls_test_rnd_std_rand(void *rng_state,