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 the TLS 1.3 obfuscated_ticket_age caclulation #377

Open
wants to merge 1 commit into
base: tls13-prototype
Choose a base branch
from

Conversation

lhuang04
Copy link
Collaborator

@lhuang04 lhuang04 commented Nov 8, 2021

Summary:
Courtesy to Bill Warshaw. Fix the calcuation of obfuscated_ticket_age, it is milliseconds.

Test Plan:

tests/ssl-opt.sh

Reviewers:

Subscribers:

Tasks:

Tags:

Notes:

  • Pull requests cannot be accepted until the PR follows the contributing guidelines. In particular, each commit must have at least one Signed-off-by: line from the committer to certify that the contribution is made under the terms of the Developer Certificate of Origin.
  • This is just a template, so feel free to use/remove the unnecessary things

Description

A few sentences describing the overall goals of the pull request's commits.

Status

READY/IN DEVELOPMENT/HOLD

Requires Backporting

When there is a bug fix, it should be backported to all maintained and supported branches.
Changes do not have to be backported if:

  • This PR is a new feature\enhancement
  • This PR contains changes in the API. If this is true, and there is a need for the fix to be backported, the fix should be handled differently in the legacy branch

Yes | NO
Which branch?

Migrations

If there is any API change, what's the incentive and logic for it.

YES | NO

Additional comments

Any additional information that could be of interest

Todos

  • Tests
  • Documentation
  • Changelog updated
  • Backported

Steps to test or reproduce

Outline the steps to test or reproduce the PR here.

Summary:
Fix the calcuation of (obfuscated_ticket_age)[https://datatracker.ietf.org/doc/html/rfc8446#section-4.2.11.1], it is milliseconds.

Test Plan:
```
tests/ssl-opt.sh
```

Reviewers:

Subscribers:

Tasks:

Tags:
@@ -939,7 +939,7 @@ int mbedtls_ssl_write_pre_shared_key_ext( mbedtls_ssl_context *ssl,
}

obfuscated_ticket_age =
(uint32_t)( now - ssl->session_negotiate->ticket_received ) +
(uint32_t)( ( now - ssl->session_negotiate->ticket_received ) * 1000 ) +
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems a fix is needed at line 934 as well as now - ssl->session_negotiate->ticket_received (age in seconds) seems to be compared to the number of milliseconds in one week.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed. The intention is to keep the fix simple.

Regarding the L934, the fix is not straightforward. If we just return MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED, the request will fail. But a better approach is to fall back to full handshake (as if there is no session ticket). What do you think on this approach?

Copy link
Owner

Choose a reason for hiding this comment

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

Falling back to the full handshake is certainly better than having the exchange fail

Copy link
Owner

Choose a reason for hiding this comment

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

I agree with Ron that this change needs to be aligned with the calculation in line 934

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

Successfully merging this pull request may close these issues.

3 participants