Mechanism to error out on removed configuration options #269
No reviewers
Labels
No labels
api-break
approved
bug
component-docs
component-platform
component-test
dependencies
deprecation
DO-NOT-MERGE
enhancement
good first issue
help wanted
needs-adoption
needs-backports
needs-ci
needs-design-approval
needs-info
needs-preceding-pr
needs-review
needs-reviewer
needs-work
priority-high
priority-low
priority-medium
priority-scheduled
priority-very-high
resolved-after-1.1
single-reviewer
size-l
size-m
size-optimisation
size-s
size-xs
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-Mbed-TLS/TF-PSA-Crypto!269
Loading…
Reference in a new issue
No description provided.
Delete branch "config-error-on-removed-options-crypto"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Set up a mechanism for erroring out if users try to use removed options in their configuration file. Resolves https://github.com/Mbed-TLS/mbedtls/issues/10147.
Specification in https://github.com/Mbed-TLS/mbedtls-framework/pull/184.
Status: ready.
Needed preceding PR:
PR checklist
I've reviewed the general design and the tests, and they both look good to me.
If the file is auto-generated and checked in, we probably want some check that the checked-in version is up-to-date. But perhaps the situation is just temporary to facilitate exploration & design review?
I expect that this won't change after the 1.0/4.0 releases, since we can't remove configuration options except in major versions. If we decide to expand it (maybe to cover experimental options? or maybe we decide to improve it for some need that we don't see yet?), we can add a check later.
Having explored the topic further, I've decided to move the checks inside the library directory. I didn't want to open the can of worms of generated public headers, but generated internal headers with no dependencies other than
*config.hare no problem. So the files will be generated bymake_generated_files.py, not checked in.I have written a specification at https://github.com/Mbed-TLS/mbedtls-framework/pull/184 . Right now the code doesn't match the specification, I'm updating it. I will rewrite the history significantly.
This is ready for review. It isn't passing the CI yet, but fixing that should take just a few more commits: one here to fix the libtestdriver1 build and a couple in mbedtls to fix the make build when generated files are missing and to fix the XTS test job.
I've pushed a fix for the libtestdriver1 builds here. The other CI failures will require https://github.com/Mbed-TLS/mbedtls/pull/10409 to be merged first.
Looks good overall, some minor comments only
@ -9,0 +18,4 @@* In a normal build, `LIBTESTDRIVER1_TF_PSA_CRYPTO_MARKER` remains* undefined so the conditional is false.*/#define TF_PSA_CRYPTO_MARKER 1is the TF_PSA_CRYPTO_MARKER used anywhere else? Should we undefine it after the
LIBTESTDRIVER1_TF_PSA_CRYPTO_MARKER == TF_PSA_CRYPTO_MARKER@ -9,0 +20,4 @@*/#define TF_PSA_CRYPTO_MARKER 1#if LIBTESTDRIVER1_TF_PSA_CRYPTO_MARKER == TF_PSA_CRYPTO_MARKER#define TF_PSA_CRYPTO_WE_ARE_IN_LIBTESTDRIVER1TF_PSA_CRYPTO_WE_ARE_IN_LIBTESTDRIVER1
@ -9,0 +22,4 @@new_public = (history.options('tfpsacrypto', '1.0') |history.options('mbedtls', '4.0'))internal = history.internal('tfpsacrypto', '1.0')for option in sorted(old_public - new_public):More pythonic but maybe harder to read?
@ -9,0 +20,4 @@*/#define TF_PSA_CRYPTO_MARKER 1#if LIBTESTDRIVER1_TF_PSA_CRYPTO_MARKER == TF_PSA_CRYPTO_MARKER#define TF_PSA_CRYPTO_WE_ARE_IN_LIBTESTDRIVER1“libtestdriver1 build” would be ambiguous: does that mean refer to a build of libtestdriver1, or a build with libtestdriver1? I picked a name that doesn't have this ambiguity.
@ -9,0 +22,4 @@new_public = (history.options('tfpsacrypto', '1.0') |history.options('mbedtls', '4.0'))internal = history.internal('tfpsacrypto', '1.0')for option in sorted(old_public - new_public):I don't know if it's more pythonic, but it's certainly harder to read, and would only get worse if the logic became more complicated.
Rebased, hopefully for the last time, with the framework updated to the merge of https://github.com/Mbed-TLS/mbedtls-framework/pull/164. The previous head is at https://github.com/gilles-peskine-arm/TF-PSA-Crypto/tree/config-error-on-removed-options-crypto-11
@ -9,0 +22,4 @@new_public = (history.options('tfpsacrypto', '1.0') |history.options('mbedtls', '4.0'))internal = history.internal('tfpsacrypto', '1.0')for option in sorted(old_public - new_public):Yeah I don't think we should aim for maximal code density. Actually I was even on the verge of suggesting
but I think compared to the current version it's a matter of opinion. (We don't want to be too verbose either.) Or perhaps
which makes the subtraction stand out a bit more without adding too many lines.
Anyway, I'm happy with the code as it is.
@ -9,0 +20,4 @@*/#define TF_PSA_CRYPTO_MARKER 1#if LIBTESTDRIVER1_TF_PSA_CRYPTO_MARKER == TF_PSA_CRYPTO_MARKER#define TF_PSA_CRYPTO_WE_ARE_IN_LIBTESTDRIVER1+100 we use such ambiguous names way too often. Language is not just an unstructured heap of keywords, we also have syntax and function words to show how the keywords relate to each other. Let's use those in identifiers when necessary.
@ -9,0 +44,4 @@#include "tf_psa_crypto_config_check_before.h"/* The second stage, after including the user config but before doing* any subsequent adjustment, will be included by build_info.h. */#define TF_PSA_CRYPTO_INCLUDE_AFTER_RAW_CONFIG "tf_psa_crypto_config_check_user.h"Regarding the discussion we had elsewhere on naming:
raw_configsounds pretty good to me. (So,tf_psa_crypto_config_check_before_raw_config.handtf_psa_crypto_config_check_after_raw_config.h). Too late, but just a thought.LGTM, thanks!
LGTM