mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 09:15:43 +01:00
Use own define for building with test drivers
Trying to compile in the PSA accelerator test driver under MBEDTLS_TEST_HOOKS turned out to be awkward regarding existing builds. We'll put it under a custom (not in config.h) define instead, since it's something that only should happen in test. Signed-off-by: Steven Cooreman <steven.cooreman@silabs.com>
This commit is contained in:
parent
7922396c25
commit
1cd39d5229
@ -28,13 +28,13 @@
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_DRIVERS)
|
||||
|
||||
/* Include test driver definition when running tests */
|
||||
#if defined(MBEDTLS_TEST_HOOKS)
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_DRIVER_TEST)
|
||||
#undef MBEDTLS_PSA_CRYPTO_DRIVER_PRESENT
|
||||
#define MBEDTLS_PSA_CRYPTO_DRIVER_PRESENT
|
||||
#undef MBEDTLS_PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT
|
||||
#define MBEDTLS_PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT
|
||||
#include "drivers/test_driver.h"
|
||||
#endif /* MBEDTLS_TEST_HOOKS */
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_DRIVER_TEST */
|
||||
|
||||
/* Include driver definition file for each registered driver here */
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_DRIVERS */
|
||||
@ -91,7 +91,7 @@ psa_status_t psa_driver_wrapper_sign_hash( psa_key_slot_t *slot,
|
||||
case PSA_KEY_LOCATION_LOCAL_STORAGE:
|
||||
/* Key is stored in the slot in export representation, so
|
||||
* cycle through all known transparent accelerators */
|
||||
#if defined(MBEDTLS_TEST_HOOKS)
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_DRIVER_TEST)
|
||||
status = test_transparent_signature_sign_hash( &attributes,
|
||||
slot->data.key.data,
|
||||
slot->data.key.bytes,
|
||||
@ -104,11 +104,11 @@ psa_status_t psa_driver_wrapper_sign_hash( psa_key_slot_t *slot,
|
||||
/* Declared with fallback == true */
|
||||
if( status != PSA_ERROR_NOT_SUPPORTED )
|
||||
return status;
|
||||
#endif /* MBEDTLS_TEST_HOOKS */
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_DRIVER_TEST */
|
||||
/* Fell through, meaning no accelerator supports this operation */
|
||||
return PSA_ERROR_NOT_SUPPORTED;
|
||||
/* Add cases for opaque driver here */
|
||||
#if defined(MBEDTLS_TEST_HOOKS)
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_DRIVER_TEST)
|
||||
case MBEDTLS_PSA_CRYPTO_TEST_DRIVER_LIFETIME:
|
||||
return( test_opaque_signature_sign_hash( &attributes,
|
||||
slot->data.key.data,
|
||||
@ -119,7 +119,7 @@ psa_status_t psa_driver_wrapper_sign_hash( psa_key_slot_t *slot,
|
||||
signature,
|
||||
signature_size,
|
||||
signature_length ) );
|
||||
#endif /* MBEDTLS_TEST_HOOKS */
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_DRIVER_TEST */
|
||||
default:
|
||||
/* Key is declared with a lifetime not known to us */
|
||||
return status;
|
||||
@ -182,7 +182,7 @@ psa_status_t psa_driver_wrapper_verify_hash( psa_key_slot_t *slot,
|
||||
case PSA_KEY_LOCATION_LOCAL_STORAGE:
|
||||
/* Key is stored in the slot in export representation, so
|
||||
* cycle through all known transparent accelerators */
|
||||
#if defined(MBEDTLS_TEST_HOOKS)
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_DRIVER_TEST)
|
||||
status = test_transparent_signature_verify_hash( &attributes,
|
||||
slot->data.key.data,
|
||||
slot->data.key.bytes,
|
||||
@ -194,11 +194,11 @@ psa_status_t psa_driver_wrapper_verify_hash( psa_key_slot_t *slot,
|
||||
/* Declared with fallback == true */
|
||||
if( status != PSA_ERROR_NOT_SUPPORTED )
|
||||
return status;
|
||||
#endif /* MBEDTLS_TEST_HOOKS */
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_DRIVER_TEST */
|
||||
/* Fell through, meaning no accelerator supports this operation */
|
||||
return PSA_ERROR_NOT_SUPPORTED;
|
||||
/* Add cases for opaque driver here */
|
||||
#if defined(MBEDTLS_TEST_HOOKS)
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_DRIVER_TEST)
|
||||
case MBEDTLS_PSA_CRYPTO_TEST_DRIVER_LIFETIME:
|
||||
return( test_opaque_signature_verify_hash( &attributes,
|
||||
slot->data.key.data,
|
||||
@ -208,7 +208,7 @@ psa_status_t psa_driver_wrapper_verify_hash( psa_key_slot_t *slot,
|
||||
hash_length,
|
||||
signature,
|
||||
signature_length ) );
|
||||
#endif /* MBEDTLS_TEST_HOOKS */
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_DRIVER_TEST */
|
||||
default:
|
||||
/* Key is declared with a lifetime not known to us */
|
||||
return status;
|
||||
@ -330,7 +330,7 @@ psa_status_t psa_driver_wrapper_generate_key( const psa_key_attributes_t *attrib
|
||||
status = PSA_ERROR_NOT_SUPPORTED;
|
||||
break;
|
||||
}
|
||||
#if defined(MBEDTLS_TEST_HOOKS)
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_DRIVER_TEST)
|
||||
status = test_transparent_generate_key( attributes,
|
||||
slot->data.key.data,
|
||||
slot->data.key.bytes,
|
||||
@ -338,19 +338,19 @@ psa_status_t psa_driver_wrapper_generate_key( const psa_key_attributes_t *attrib
|
||||
/* Declared with fallback == true */
|
||||
if( status != PSA_ERROR_NOT_SUPPORTED )
|
||||
break;
|
||||
#endif /* MBEDTLS_TEST_HOOKS */
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_DRIVER_TEST */
|
||||
/* Fell through, meaning no accelerator supports this operation */
|
||||
status = PSA_ERROR_NOT_SUPPORTED;
|
||||
break;
|
||||
/* Add cases for opaque driver here */
|
||||
#if defined(MBEDTLS_TEST_HOOKS)
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_DRIVER_TEST)
|
||||
case MBEDTLS_PSA_CRYPTO_TEST_DRIVER_LIFETIME:
|
||||
status = test_opaque_generate_key( attributes,
|
||||
slot->data.key.data,
|
||||
slot->data.key.bytes,
|
||||
&slot->data.key.bytes );
|
||||
break;
|
||||
#endif /* MBEDTLS_TEST_HOOKS */
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_DRIVER_TEST */
|
||||
default:
|
||||
/* Key is declared with a lifetime not known to us */
|
||||
status = PSA_ERROR_INVALID_ARGUMENT;
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_TEST_HOOKS)
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_DRIVER_TEST)
|
||||
#include <psa/crypto_driver_common.h>
|
||||
|
||||
extern void *test_driver_keygen_forced_output;
|
||||
@ -45,5 +45,5 @@ psa_status_t test_opaque_generate_key(
|
||||
const psa_key_attributes_t *attributes,
|
||||
uint8_t *key, size_t key_size, size_t *key_length );
|
||||
|
||||
#endif /* MBEDTLS_TEST_HOOKS */
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_DRIVER_TEST */
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_TEST_DRIVERS_KEYGEN_H */
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_TEST_HOOKS)
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_DRIVER_TEST)
|
||||
#include <psa/crypto_driver_common.h>
|
||||
|
||||
extern void *test_driver_forced_output;
|
||||
@ -68,5 +68,5 @@ psa_status_t test_opaque_signature_verify_hash(
|
||||
const uint8_t *hash, size_t hash_length,
|
||||
const uint8_t *signature, size_t signature_length );
|
||||
|
||||
#endif /* MBEDTLS_TEST_HOOKS */
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_DRIVER_TEST */
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_TEST_DRIVERS_SIGNATURE_H */
|
||||
|
@ -1659,9 +1659,8 @@ component_test_se_default () {
|
||||
component_test_psa_crypto_drivers () {
|
||||
msg "build: MBEDTLS_PSA_CRYPTO_DRIVERS w/ driver hooks"
|
||||
scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
|
||||
scripts/config.py set MBEDTLS_TEST_HOOKS
|
||||
# Need to include the test driver header path in order to build
|
||||
make CC=gcc CFLAGS="$ASAN_CFLAGS -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
|
||||
# Need to define the correct symbol and include the test driver header path in order to build with the test driver
|
||||
make CC=gcc CFLAGS="$ASAN_CFLAGS -DMBEDTLS_PSA_CRYPTO_DRIVER_TEST -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
|
||||
|
||||
msg "test: MBEDTLS_PSA_CRYPTO_DRIVERS, signature"
|
||||
make test
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_DRIVERS) && defined(MBEDTLS_TEST_HOOKS)
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_DRIVERS) && defined(MBEDTLS_PSA_CRYPTO_DRIVER_TEST)
|
||||
#include "psa/crypto.h"
|
||||
#include "mbedtls/ecp.h"
|
||||
#include "mbedtls/error.h"
|
||||
@ -126,4 +126,4 @@ psa_status_t test_opaque_generate_key(
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_DRIVERS && MBEDTLS_TEST_HOOKS */
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_DRIVERS && MBEDTLS_PSA_CRYPTO_DRIVER_TEST */
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_DRIVERS) && defined(MBEDTLS_TEST_HOOKS)
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_DRIVERS) && defined(MBEDTLS_PSA_CRYPTO_DRIVER_TEST)
|
||||
#include "psa/crypto.h"
|
||||
#include "mbedtls/ecp.h"
|
||||
|
||||
@ -298,4 +298,4 @@ psa_status_t test_opaque_signature_verify_hash(
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_DRIVERS && MBEDTLS_TEST_HOOKS */
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_DRIVERS && MBEDTLS_PSA_CRYPTO_DRIVER_TEST */
|
||||
|
@ -49,7 +49,7 @@ typedef enum
|
||||
/* END_HEADER */
|
||||
|
||||
/* BEGIN_DEPENDENCIES
|
||||
* depends_on:MBEDTLS_PSA_CRYPTO_C:MBEDTLS_PSA_CRYPTO_DRIVERS:MBEDTLS_TEST_HOOKS
|
||||
* depends_on:MBEDTLS_PSA_CRYPTO_C:MBEDTLS_PSA_CRYPTO_DRIVERS:MBEDTLS_PSA_CRYPTO_DRIVER_TEST
|
||||
* END_DEPENDENCIES
|
||||
*/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user