refactor: prevent sending zero lifetime new session ticket #5003
+39
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Release Summary:
Resolved issues:
resolves #2756.
Description of changes:
This PR resolves the concerns is issue #2756, which asks for
If a new session ticket has zero lifetime, then we shouldn't send it. Hence, this PR will prevent sending new session tickets which have zero lifetime.
Add a check for
ticket_lifetime_in_sec
ins2n_tls13_server_nst_write()
function.We send new session ticket with this logic:
s2n-tls/tls/s2n_server_new_session_ticket.c
Lines 176 to 182 in fd41da0
By adding a checking logic for zero session ticket lifetime in
s2n_tls13_server_nst_write()
, thes2n_tls13_server_nst_send()
function can capture the error and stop sending the zero lifetime new session ticket by returningS2N_RESULT_OK
.Add one more tests in
s2n_server_new_session_ticket_test.c
to test sending zero lifetime new session ticket.I intentionally set the
tickets_to_send
variable to one, so that thes2n_tls13_server_nst_send()
function will attempt to send the ticket. I also set the ticket lifetime to zero, so thats2n_generate_ticket_lifetime()
function will make the ticket age to be zero. Then in the test, we check for the following:The test logic is similar to the one already in
s2n_server_new_session_ticket_test.c
.s2n-tls/tests/unit/s2n_server_new_session_ticket_test.c
Lines 984 to 1017 in fd41da0
Call-outs:
Testing:
I have mentioned how I add test in the
Description of changes
section. This PR is tested both locally and in the CI.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.