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

add unit test for decyption of future keys #4095

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

jmayclin
Copy link
Contributor

Description of changes:

This PR adds a unit test that confirms a session ticket can be decrypted even if it's encryption key has not yet reached it's intro time. This is useful in distributed systems scenarios where clock skew prevents precise synchronization of key usage. By adding a STEK to the s2n-tls config far before it's introTime, endpoints can neatly deal with the clock skew issue.

Testing:

There is no new behavior being added, just a unit test to confirm current behavior, and prevent any changes to the current behavior.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Comment on lines 338 to +339

/* Client sends non-empty ST extension. Server does an abbreviated handshake without issuing NST. */
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you give this test a better name? This comment should describe the scenario you're trying to test. So something like "Server can decrypt session ticket with key before the key's introduction time, but will not issue new ticket".

I'm also wondering if this test is overkill. Maybe we don't need a full self-talk test. If you don't care about the actual handshake (like how the client and server exchange tickets / issue new tickets), and you're only interested in whether the ticket can be decrypted, you could probably just test s2n_decrypt_session_ticket directly (in s2n_resume_test.c)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do on the naming.

And I can move the test to s2n_decrypt_session_ticket, but I don't know that it ends up being simpler.

For those tests the server is issuing the tickets, so I either need two separate configs with different key configurations (and therefore need two different connections) or I need to do some time-reversal black-magic clock-mockery to test my "decrypt before encryption time". Out of those options, I think I prefer the multiple config approach. Thoughts?

EXPECT_SUCCESS(s2n_config_free(resuming_config));
}

/* Server can decrypt session ticket with key before the key's introduction time */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like this option better, but it feels weird to be swapping out the config for a connection?

@github-actions
Copy link

This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Copy link

github-actions bot commented Dec 4, 2023

This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants