Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabling MBEDTLS_FS_IO for FreeRTOS application on coretex-m7 results in missing headers #7403

Open
JLReitz opened this issue Apr 5, 2023 · 2 comments
Labels
bug component-psa PSA keystore/dispatch layer (storage, drivers, …)

Comments

@JLReitz
Copy link

JLReitz commented Apr 5, 2023

Summary

I started setting my MbedTLS configurations according to the paragraph mentioning bare-metal at the bottom of the overview section in the porting guide. After commenting out MBEDTLS_FS_IO from my mbedtls_config.h, I got the following build error from include/mbedtls/check_config.h.

#if defined(MBEDTLS_PSA_ITS_FILE_C) && \
    !defined(MBEDTLS_FS_IO)
#error "MBEDTLS_PSA_ITS_FILE_C defined, but not all prerequisites"
#endif

If I also comment out MBEDTLS_PSA_ITS_FILE_C, I receive an error that psa/error.h can not be found. The offending include directive is from psa_crypto_storage.c, copied below:

#if defined(MBEDTLS_PSA_ITS_FILE_C)
#include "psa_crypto_its.h"
#else /* Native ITS implementation */
#include "psa/error.h"
#include "psa/internal_trusted_storage.h"
#endif

There are no files named error.h or internal_trusted_storage.h under the include/psa directory.

System information

Mbed TLS version (number or commit id): 3.4.0 (1873d3b)
Operating system and version: FreeRTOS 10.4.4
Configuration (if not default, please attach mbedtls_config.h): attached
Compiler and options (if you used a pre-built binary, please indicate how you obtained it):
gcc-arm-none-eabi 10-2020-q4-major
-x assembler-with-cpp -mthumb -mno-thumb-interwork -mfloat-abi=hard -fno-rtti -fno-exceptions -specs=nosys.specs -specs=nano.specs -nostartfiles -lc -lm -lgcc -fdata-sections -ffunction-sections
Additional environment information:

Expected behavior

Per the porting guide, it should be possible to disable MBEDTLS_FS_IO without further implications to the other submodules and overall build.

Actual behavior

Disabling MBEDTLS_FS_IO breaks the build.

Steps to reproduce

Apply provided mbedtls_config.h to build while using gcc-arm-none-eabi and the included options.

Additional information

mbedtls_config.h.zip

@daverodgman
Copy link
Contributor

I think this is happening because you're requiring ITS (via MBEDTLS_PSA_CRYPTO_STORAGE_C), but disabling our implementation of ITS and not providing an alternative implementation. Disabling MBEDTLS_PSA_CRYPTO_STORAGE_C resolves this, assuming you don't need this feature.

I'm not sure this is a bug, although arguably the documentation for the options could be improved. @gilles-peskine-arm WDYT?

@daverodgman daverodgman added bug component-psa PSA keystore/dispatch layer (storage, drivers, …) labels Apr 5, 2023
@gilles-peskine-arm
Copy link
Contributor

gilles-peskine-arm commented Apr 8, 2023

Indeed this is working as intended. Persistent keys (MBEDTLS_PSA_CRYPTO_STORAGE_C) require a storage implementation which can either be a standard PSA storage implementation or the implementation that we provide over stdio (MBEDTLS_PSA_ITS_FILE_C). This is documented in mbedtls_config.h.

We should document this in the porting guide, which hasn't been updated since before PSA.

There's no entry in check_config.h because if MBEDTLS_PSA_CRYPTO_STORAGE_C is enabled but MBEDTLS_PSA_ITS_FILE_C is disabled, it might still be ok if "psa/internal_trusted_storage.h" is available, and we can't portably check that with a preprocessor directive. The only improvement I can think of is that we could use __has_include on supported compilers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug component-psa PSA keystore/dispatch layer (storage, drivers, …)
Projects
None yet
Development

No branches or pull requests

3 participants