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

MbedTLS v3.6.0 - Compilation errors and warnings #9156

Closed
LuDuda opened this issue May 21, 2024 · 1 comment
Closed

MbedTLS v3.6.0 - Compilation errors and warnings #9156

LuDuda opened this issue May 21, 2024 · 1 comment

Comments

@LuDuda
Copy link

LuDuda commented May 21, 2024

Summary

I'm working on migrating from the legacy MbedTLS crypto API to the PSA API for the OpenThread project, as requested by @gilles-peskine-arm (openthread/openthread#10253).

I have encountered two compilation issues for version v3.6.0 using the OT build system with the -wpedantic flag.

In file included from third_party/mbedtls/repo/include/psa/crypto.h:4828,
                 from third_party/mbedtls/repo/include/mbedtls/pk.h:32,
                 from third_party/mbedtls/repo/include/mbedtls/ssl_ciphersuites.h:16,
                 from third_party/mbedtls/repo/include/mbedtls/ssl.h:20,
                 [...]
third_party/mbedtls/repo/include/psa/crypto_struct.h:229:13: error: ISO C++ forbids flexible array member ‘data’ [-Wpedantic]
  229 |     uint8_t data[];

and

third_party/mbedtls/repo/library/pk.c: In function ‘copy_from_psa’:
third_party/mbedtls/repo/library/pk.c:871:21: warning: variable ‘alg_type’ set but not used [-Wunused-but-set-variable]
  871 |     psa_algorithm_t alg_type;

For the first issue, I plan to apply a workaround, but I believe it might be better to implement variable-length structures differently (e.g., using *data or data[1] with an adjusted allocation scheme). Therefore, I will keep this GitHub issue open. @gilles-peskine-arm any thoughts here?

I intended to fix the second issue by myself, but I noticed that it has already been resolved in the development branch (#9067) - great!

@gilles-peskine-arm
Copy link
Contributor

For the flexible array member, we're already tracking this in #9020. We're going to make new types and functions that split the variable-length part out of the structure and into a separate parameter. The current type and function will be skipped if defined(__cplusplus) (exact condition TBD).

For the unused-variable warnings in copy_from_psa, we already have some fixes in the development branch (390f276 and dde67bb). I'm not sure we've fixed all cases, but we have fixed the one you encountered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants