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

Fix module configuration options in mbedtls_config.h #8161

Conversation

gilles-peskine-arm
Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm commented Sep 5, 2023

Fix several issues in the “Module configuration options” section of mbedtls_config.h:

  • Boolean options shouldn't be there. I don't think this has major practical consequences, but it violates our documentation.
  • Numeric options need to have their default value defined in another header file. This broke many TLS 1.3 builds with a custom configuration file. Should we have a non-regression test for that (which would be a custom configuration file that enables MBEDTLS_SSL_PROTO_TLS1_3 and MBEDTLS_SSL_SESSION_TICKETS)?

Priority: I discovered this during the p256-m review and it's a bug in the p256-m integration, so I'm rating this priority-high, but it isn't a release blocker, and I could bend this to priority-medium since the only consequence is some mild user confusion.

PR checklist

Please tick as appropriate and edit the reasons (e.g.: "backport: not needed because this is a new feature")

Boolean options that modify the behavior of a module are supposed to be in
the "feature support" section, not in the "configuration options" support:
that section is documented to contain commented-out definitions with a
value, for which the comment contains the default version. In particular,
merely uncommenting a definition in the "configuration options" section is
not supposed to change anything.

Move the offending boolean options to the proper section.

This causes those options to be enabled by `config.py full` unless
explicitly excluded. For all the offending options, this is undesirable, so
make sure those options are indeed excluded.

Signed-off-by: Gilles Peskine <[email protected]>
In particular, pre-shared keys are supported.

Signed-off-by: Gilles Peskine <[email protected]>
Mbed TLS can be configured by writing a configuration file from scratch,
without copying mbedtls_config.h. As a consequence, all the macro
definitions in mbedtls_config.h must be optional. This was not the case for
some MBEDTLS_SSL_TLS1_3_xxx macros with numerical values related to session
tickets. Fix that.

Signed-off-by: Gilles Peskine <[email protected]>
Fix unused variable when MBEDTLS_SSL_PROTO_TLS1_3 and
MBEDTLS_SSL_SESSION_TICKETS are enabled but not MBEDTLS_DEBUG_C.

Signed-off-by: Gilles Peskine <[email protected]>
This is not required (it's ok to define the default in mbedtls_config and
skip the definition in rsa.h), but comment it out for uniformity with all
the other options in this section.

Signed-off-by: Gilles Peskine <[email protected]>
@gilles-peskine-arm gilles-peskine-arm added bug needs-backports Backports are missing or are pending review and approval. component-crypto Crypto primitives and low-level interfaces needs-ci Needs to pass CI tests component-tls13 priority-high High priority - will be reviewed soon size-xs Estimated task size: extra small (a few hours at most) labels Sep 5, 2023
@gilles-peskine-arm gilles-peskine-arm added needs-review Every commit must be reviewed by at least two team members, needs-reviewer This PR needs someone to pick it up for review and removed needs-ci Needs to pass CI tests labels Sep 6, 2023
daverodgman
daverodgman previously approved these changes Sep 7, 2023
Copy link
Contributor

@daverodgman daverodgman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. If you feel keen, it would be good to fix all the spellings of "mbed TLS"

@daverodgman daverodgman added the single-reviewer This PR qualifies for having only one reviewer label Sep 7, 2023
@gilles-peskine-arm
Copy link
Contributor Author

If you feel keen, it would be good to fix all the spellings of "mbed TLS"

If that bothers you enough to do another review, I'll rebase #8034 once this one is merged.

The documentation was not updated when we started detecting memset_s() and
such.

Signed-off-by: Gilles Peskine <[email protected]>
@gilles-peskine-arm
Copy link
Contributor Author

I amended the last commit to fix a doxygen syntax error.

#endif

#if !defined(MBEDTLS_SSL_TLS1_3_TICKET_NONCE_LENGTH)
#define MBEDTLS_SSL_TLS1_3_TICKET_NONCE_LENGTH 32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The disadvantage of doing it this way is to change the default one now needs to make identical changes in two places

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. But in practice, I don't recall us changing the default for any of thse options in the past 6½ years.

Anyway, if we changed the organization, this pull request wouldn't be the place to do it. It would require some thought about the new design and backward compatibility.

Copy link
Contributor

@tom-cosgrove-arm tom-cosgrove-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tom-cosgrove-arm tom-cosgrove-arm added approved Design and code approved - may be waiting for CI or backports and removed needs-review Every commit must be reviewed by at least two team members, needs-reviewer This PR needs someone to pick it up for review labels Sep 11, 2023
@daverodgman daverodgman added this pull request to the merge queue Sep 11, 2023
Merged via the queue into Mbed-TLS:development with commit 7fda906 Sep 11, 2023
tom-cosgrove-arm added a commit to tom-cosgrove-arm/mbedtls that referenced this pull request Sep 14, 2023
…t in config

Numeric options should be commented out with their default values in the config
file, and a separate header file should set the default value if necessary.
This was done for most other options in Mbed-TLS#8161; do it here for
MBEDTLS_SSL_MAX_EARLY_DATA_SIZE.

Signed-off-by: Tom Cosgrove <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Design and code approved - may be waiting for CI or backports bug component-crypto Crypto primitives and low-level interfaces component-tls13 needs-backports Backports are missing or are pending review and approval. priority-high High priority - will be reviewed soon single-reviewer This PR qualifies for having only one reviewer size-xs Estimated task size: extra small (a few hours at most)
Projects
Development

Successfully merging this pull request may close these issues.

3 participants