Skip to content

test(integration): add record padding test#5451

Merged
jmayclin merged 8 commits intoaws:mainfrom
jmayclin:2025-07-29-add-record-test
Aug 8, 2025
Merged

test(integration): add record padding test#5451
jmayclin merged 8 commits intoaws:mainfrom
jmayclin:2025-07-29-add-record-test

Conversation

@jmayclin
Copy link
Copy Markdown
Contributor

@jmayclin jmayclin commented Jul 31, 2025

Description of changes:

Goal: Add a record padding integration test using the new framework

Why: We will want to replace the python test eventually, and I also want at least one test in place as I work on adding all of the build machinery for the different libcryptos.

How: The integration test uses the new tls-harness to do an in-memory handshake.

Testing:

It's a new test! I am assuming that the OpenSSL API works as advertised. If we wanted to go further I could look at a decrypted trace.

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

@jmayclin jmayclin requested review from goatgoose and lrstewart July 31, 2025 23:29
@github-actions github-actions bot added the s2n-core team label Jul 31, 2025
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This test is so small and simple!!

* add default certificate
* add record size assertions
@jmayclin jmayclin requested review from goatgoose and lrstewart August 6, 2025 19:27
Comment on lines +51 to +53
pub fn client_record_sizes(&self) -> Vec<u16> {
Self::record_sizes(self.client_tx_transcript.as_ref().borrow().as_slice()).unwrap()
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm curious why this shouldn't be a function on ViewIO? It seems like it could be better to say pair.client_view.record_sizes() / pair.server_view.record_sizes() rather than need to expose client/server versions for each transcript function. Unless this is difficult/undesirable for some reason?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There is no unified way to access ViewIO, because each TLS implementation stores it slightly differently.

// openssl
pair.client.connection.get_ref().record_sizes()

// s2n
pair.client.connection.io.record_sizes()

// rustls
pair.client.connection.io.record_sizes()

I think it also feels weird to reach through the connection to ask questions about the IO layer. The IO layer is "owned" by the TestPair, so that is where IO questions should be asked.

Comment on lines +112 to +119
if self.recording.load(Ordering::Relaxed) {
if let Ok(written) = write_result {
self.send_transcript
.borrow_mut()
.write_all(&buf[0..written])
.unwrap();
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: this works, but we're basically writing twice, once to the local data buffer and once to this transcript. It seems unnecessary, and like a "single source of truth" problem. If I remember right, in the unit tests our "local data buffer" is a stuffer that we don't wipe. Reading moves the read pointer, but all the data is still there if we need to review what happened. Can we make LocalDataBuffer optionally behave the same?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Can we make LocalDataBuffer optionally behave the same?

Yes, but I don't think we should. Specifically this would throw off any memory benchmarking numbers (I still want to merge #5329 ) and would prevent any kinds of large data transfer tests from using it.

* assert on tls 1.3 negotiation
* factor padding assertion into a helper
@jmayclin jmayclin requested a review from lrstewart August 7, 2025 17:12
@jmayclin jmayclin enabled auto-merge August 7, 2025 23:59
@jmayclin jmayclin added this pull request to the merge queue Aug 8, 2025
Merged via the queue into aws:main with commit 6dcbffe Aug 8, 2025
49 checks passed
@jmayclin jmayclin deleted the 2025-07-29-add-record-test branch August 8, 2025 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants