Skip to content

Conversation

@ronald-cron-arm
Copy link
Contributor

@ronald-cron-arm ronald-cron-arm commented Jan 29, 2024

Description

Second PR of two addressing #6340 .

PR checklist

  • changelog not required, will add one for TLS 1.3 early data feature as a whole
  • backport not required, new feature
  • tests provided

@ronald-cron-arm ronald-cron-arm added enhancement needs-ci Needs to pass CI tests needs-preceding-pr Requires another PR to be merged first component-tls13 priority-high High priority - will be reviewed soon labels Jan 29, 2024
@ronald-cron-arm ronald-cron-arm force-pushed the tls13-write-early-data branch 2 times, most recently from 875bb4a to 2384374 Compare January 29, 2024 15:22
@ronald-cron-arm ronald-cron-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 Jan 29, 2024
@ronald-cron-arm ronald-cron-arm added the needs-ci Needs to pass CI tests label Feb 5, 2024
@mpg mpg removed the needs-reviewer This PR needs someone to pick it up for review label Feb 6, 2024
@ronald-cron-arm ronald-cron-arm linked an issue Feb 6, 2024 that may be closed by this pull request
1 task
xkqian and others added 11 commits February 7, 2024 08:06
Signed-off-by: Xiaokang Qian <[email protected]>
Signed-off-by: Ronald Cron <[email protected]>
No need to define specific early data,
the idea is rather to just send the
usual request data as early data
instead of standard application data.

Signed-off-by: Ronald Cron <[email protected]>
Move code to build http request into a
dedicated function.

Signed-off-by: Ronald Cron <[email protected]>
Switch from int to size_t for some
data lengths and counter local
variables.

Signed-off-by: Ronald Cron <[email protected]>
Add buffer overflow check to build_http_request().

Signed-off-by: Ronald Cron <[email protected]>
Signed-off-by: Xiaokang Qian <[email protected]>
Signed-off-by: Ronald Cron <[email protected]>
@ronald-cron-arm
Copy link
Contributor Author

@mpg I have addressed your comments, the Open CI is green, please have another look, thanks.

@mpg
Copy link
Contributor

mpg commented Feb 22, 2024

Btw, out of scope for this PR, but I think the early data APIs are a bit complex (not saying they're bad, I think 0-RTT is just a fairly complex feature of 1.3 so this reflects in the APIs), and a knowledge base article explaining everything a user needs to know (in general, client-side and server-side) would be helpful if we can write one at some point.

@ronald-cron-arm
Copy link
Contributor Author

Btw, out of scope for this PR, but I think the early data APIs are a bit complex (not saying they're bad, I think 0-RTT is just a fairly complex feature of 1.3 so this reflects in the APIs), and a knowledge base article explaining everything a user needs to know (in general, client-side and server-side) would be helpful if we can write one at some point.

We have already something at the end of tls13-support.md. The read part is outdated but the write part not that much it seems. I've planned to update/fix it when addressing the wrap-up issue.

@mpg
Copy link
Contributor

mpg commented Feb 22, 2024

We have already something at the end of tls13-support.md. The read part is outdated but the write part not that much it seems. I've planned to update/fix it when addressing the wrap-up issue.

Great! Though I'll note as a user I would probably not be looking under docs/architecture. Probably worth splitting the document into two parts: one for developers (same location), one for users (probably just under docs?).

Copy link
Contributor

@mpg mpg left a comment

Choose a reason for hiding this comment

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

Thanks for addressing my feedback! Looking pretty good, only minor points left.

Also, it seems to me we can now remove the hack used for testing server before we had client support. Btw, now that we have a tls13_write_early_data test function, perhaps tls13_early_data should be renamed to tls13_read_early_data. Also, why doesn't that one have a NO_INDICATION_SENT scenario like the other two? (I'm OK with considering this whole paragraph out of scope as long as it's tracked somewhere.)

@ronald-cron-arm
Copy link
Contributor Author

ronald-cron-arm commented Feb 22, 2024

Also, it seems to me we can now remove the hack used for testing server before we had client support.

I've removed it in this PR (not used anymore) but I will reintroduced it in max_early_data_size PRs for negative testing purposes.

Btw, now that we have a tls13_write_early_data test function, perhaps tls13_early_data should be renamed to tls13_read_early_data.

Done

Also, why doesn't that one have a NO_INDICATION_SENT scenario like the other two? (I'm OK with considering this whole paragraph out of scope as long as it's tracked somewhere.)

Because not much happens I guess, but better with it thus I've added it.

@ronald-cron-arm
Copy link
Contributor Author

@mpg @waleed-elmelegy-arm this is ready for the next round of reviews, thanks.

Copy link
Contributor

@mpg mpg left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for addressing my feedback and answering my questions!

@ronald-cron-arm
Copy link
Contributor Author

LGTM, thanks for addressing my feedback and answering my questions!

Thanks for the review and the questions. @waleed-elmelegy-arm please have a look, thanks.

@mpg
Copy link
Contributor

mpg commented Feb 26, 2024

Also, it seems to me we can now remove the hack used for testing server before we had client support.

I've removed it in this PR (not used anymore) but I will reintroduced it in max_early_data_size PRs for negative testing purposes.

Perhaps we shouldn't remove it then. #8854 will no longer build (when merged with development) once this is merged.

@ronald-cron-arm
Copy link
Contributor Author

Also, it seems to me we can now remove the hack used for testing server before we had client support.

I've removed it in this PR (not used anymore) but I will reintroduced it in max_early_data_size PRs for negative testing purposes.

Perhaps we shouldn't remove it then. #8854 will no longer build (when merged with development) once this is merged.

I think if I keep it here the CI will fail on this PR because the function will not be used thus I guess we don't have really the choice.

@mpg
Copy link
Contributor

mpg commented Feb 26, 2024

Ah, good point. We'll just need to rebase 8854 when this one gets merged, then.

Copy link
Contributor

@waleed-elmelegy-arm waleed-elmelegy-arm left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, just some comments for better clarity but nothing really wrong.

* The client has not sent the first ClientHello yet, it is unknown if the
* client will send an early data indication extension or not.
*/
MBEDTLS_SSL_EARLY_DATA_STATUS_UNKNOWN,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this gives the idea that this is a state that track the actual early data not the "early data indication extension" and later on when reading the documentation or the code you realise that it's not, so maybe it's clearer to mention it in the name like with adding "EXT" or "IND" or in any other way that indicates it.

* HelloRetryRequest) from the server yet. The transform to protect early data
* has been set and early data can be written now.
*/
MBEDTLS_SSL_EARLY_DATA_STATUS_CAN_WRITE,
Copy link
Contributor

Choose a reason for hiding this comment

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

From the first glance it seems that "MBEDTLS_SSL_EARLY_DATA_STATUS_SENT" is the same as "MBEDTLS_SSL_EARLY_DATA_STATUS_CAN_WRITE" but it's not because of sending changeCipher compatibility so maybe it's better to mention it here in the comments why it's not the case since I was only able to know from the ticket discussion.

*/
MBEDTLS_SSL_EARLY_DATA_STATUS_NOT_SENT,
MBEDTLS_SSL_EARLY_DATA_STATUS_ACCEPTED,
MBEDTLS_SSL_EARLY_DATA_STATUS_REJECTED,
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems to me that those three states are overlapping with the rest of the states for example "MBEDTLS_SSL_EARLY_DATA_STATUS_ACCEPTED" and "MBEDTLS_SSL_EARLY_DATA_STATUS_REJECTED" are both the same state as "MBEDTLS_SSL_EARLY_DATA_STATUS_SERVER_FINISHED_RECEIVED" but we still need to know the information of if the server accepted early data or not so maybe this can be split to maybe "Result" and "State" for example? or something close maybe.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually should we just use different enums for the return value of this function and the internal state? I think that would be clearer.

@ronald-cron-arm
Copy link
Contributor Author

@waleed-elmelegy-arm thanks for your comments. The PR is already quite big and I was thinking that I could address your comments in a follow-up PR. @mpg @waleed-elmelegy-arm would you be fine with that?

@mpg
Copy link
Contributor

mpg commented Feb 29, 2024

Fine by me!

@ronald-cron-arm ronald-cron-arm added this pull request to the merge queue Feb 29, 2024
Merged via the queue into Mbed-TLS:development with commit 9b4e964 Feb 29, 2024
@ronald-cron-arm ronald-cron-arm mentioned this pull request Mar 21, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component-tls13 enhancement needs-review Every commit must be reviewed by at least two team members, priority-high High priority - will be reviewed soon

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

TLS 1.3 client: Add support for early data writing

4 participants