Skip to content

[TLS 1.3] Prepare for Session Consolidation#3244

Merged
reneme merged 8 commits intomasterfrom
tls13/prep_session_consolidation
Feb 6, 2023
Merged

[TLS 1.3] Prepare for Session Consolidation#3244
reneme merged 8 commits intomasterfrom
tls13/prep_session_consolidation

Conversation

@reneme
Copy link
Copy Markdown
Collaborator

@reneme reneme commented Feb 1, 2023

This pulls out some utility stuff from #3150 and #3140 hoping to make it a bit more digestable.

  • Explicit protocol downgrade (from 1.3 to 1.2 implementation) if the 1.3-stack finds a 1.2-session to be resumed.
    (this avoids having to query the Session_Manager twice, which is a guarantee we need later on)
  • TLS 1.2 session tickets are aware of the lifetime_hint specified in RFC 5077.
  • TLS::Policy::session_ticket_lifetime() now returns std::chrono::seconds
    along with the necessary internal API adaptions (e.g. New_Session_Ticket_12())
  • TLS::New_Session_Ticket_12/13::ticket_lifetime_hint() now returns std::chrono::seconds
  • Rename Extension Session_Ticket to Session_Ticket_Extension
    (the identifier Session_Ticket will be used for a strong type later)
  • file system helper: copy_file(from, to)
  • Test helper: Test::flatten_result_list(std::vector<std::vector<Test::Result>>) -> std::vector<Test::Result>
  • Test helper: Test::data_file_as_temporary_copy() to create a test-private copy of some test file
    (to allow modification of the file in the test)

Copy link
Copy Markdown
Owner

@randombit randombit left a comment

Choose a reason for hiding this comment

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

TLS changes look fine to my eye. I'm confused by the need to create a temporary file, though.

}

//static
std::string Test::data_file_as_temporary_copy(const std::string &what)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Can you explain a bit why a test would need a file to be created as a literal file on the filesystem and then modify it? I would think that a more natural design would be an API that is provided some input, and given (say) a std::ostream& to which it produces output. (An example here would be ASN1_Pretty_Printer::print_to_stream) Then it is easy to test by given it a std::ostringstream, without having to touch the filesystem.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

#3150 will add a test that takes an SQLite file generated by the Botan 2.x Session_Manager_SQLite and tries to open it with the new implementation. That will trigger a database migration (rudimentary: wipe and rebuild) which writes into the database file. The 'old' file is checked into the test-data directory and every time the test is run, we need to create a temporary copy of that database file to work on.

I found it important to have such a test, despite the simple migration strategy. After all, users will likely wind up opening old 2.x database files in production after migrating to 3.0.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Now, I believe, SQLite has a pluggable storage interface that would allow us to implement such a test in-memory rather than in a temp file. Though, I found the temporary file approach much easier to pull off.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

OK now I understand.

Rather than plugging sqlite's storage it seems a lot easier to create a mock Database subclass. That TBH seems better to me, in that it allows verifying the specific expected sql statements are produced. But quite a bit more work than just copying and then examining the database post-migration. OK to proceed with your approach for now, I'll maybe try this mock approach later on in the year since we could use it for testing the other DB backed code.

@reneme reneme force-pushed the tls13/prep_session_consolidation branch from b4e7930 to 2bdff80 Compare February 2, 2023 07:08
@reneme reneme requested a review from randombit February 3, 2023 08:10
@reneme reneme merged commit 299b502 into master Feb 6, 2023
@randombit randombit deleted the tls13/prep_session_consolidation branch February 6, 2023 20:16
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.

2 participants