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

check_names misses typo in PSA macro name #6416

Closed
gilles-peskine-arm opened this issue Oct 13, 2022 · 2 comments · Fixed by #6558
Closed

check_names misses typo in PSA macro name #6416

gilles-peskine-arm opened this issue Oct 13, 2022 · 2 comments · Fixed by #6558
Assignees
Labels
component-test Test framework and CI scripts enhancement

Comments

@gilles-peskine-arm
Copy link
Contributor

Add the following code to include/mbedtls/check_config.h:

#if defined(MBEDTLS_LMS_C) && !defined(PSA_WANT_ALG_SHA256)
//#error "MBEDTLS_LMS_C defined, but not misspelled prerequisite"
#endif

(you can't have the actual #error because that causes a build failure)

Expectation: tests/scripts/check_names.py complains that PSA_WANT_ALG_SHA256 is a likely typo (the correct spelling is PSA_WANT_ALG_SHA_256). It would do so if the dependency was on MBEDTLS_SHA_256_C (misspelled for MBEDTLS_SHA256_C).

Actual behavior as of 0fe6631: tests/scripts/check_names.py is happy (as long as make lib works in the full config).

@gilles-peskine-arm gilles-peskine-arm added enhancement component-test Test framework and CI scripts labels Oct 13, 2022
@lpy4105 lpy4105 self-assigned this Nov 4, 2022
@lpy4105
Copy link
Contributor

lpy4105 commented Nov 7, 2022

I'm going to work on this enhancement. I added some experimental code in check_names.py to check the PSA words the same way as the MBED words. I found that unlike MBED words, not all of the PSA_XXX symbols (macros and enumeration) are defined in the headers so there would be false negative errors of 'likely typo' for these references(e.g. PSA_PAKE_SEQ_INVALID). Any suggestions for these symbols?

@gilles-peskine-arm
Copy link
Contributor Author

Possible solution: make check_names.py also look in .c files for definitions of macro/enum names.

Another possible solution, perhaps: does clang-tidy have an applicable check? It can enforce that defined identifiers have a certain prefix, but I haven't found a check that's similar to the typo part of check_names. So maybe in the medium term check_names.py could be simplified to only do the typo check, and the part about enforcing the namespace could be removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component-test Test framework and CI scripts enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants