Skip to content

feat: support plaintext resumption tokens - #338

Open
Frosne wants to merge 15 commits into
mozilla:mainfrom
Frosne:plaintext-tokens
Open

Frosne wants to merge 15 commits into
mozilla:mainfrom
Frosne:plaintext-tokens

Conversation

@Frosne

@Frosne Frosne commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

This patch is adding Client::enable_plaintext_resumption_export, which binds NSS's SSL_EnablePlaintextResumptionExport, and is_plaintext function, which is trying to check if the token is encrypted or not. This is_plaintext() would be replaced by SSLResumptionTokenInfo.plaintextSecret as soon as the patch is accepted

@Frosne

Frosne commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

P.S. let me know if you'd prefer to wait for SSLResumptionTokenInfo.plaintextSecret before merging :)

@codspeed

codspeed Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ 1 benchmark is dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 186 untouched benchmarks


Comparing Frosne:plaintext-tokens (d73c034) with main (f98228f)

Open in CodSpeed

@codecov-commenter

codecov-commenter commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.11321% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 76.34%. Comparing base (e22ba15) to head (d73c034).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
src/agent.rs 98.11% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #338      +/-   ##
==========================================
+ Coverage   75.89%   76.34%   +0.44%     
==========================================
  Files          28       28              
  Lines        3423     3475      +52     
  Branches     3423     3475      +52     
==========================================
+ Hits         2598     2653      +55     
+ Misses        608      605       -3     
  Partials      217      217              
Flag Coverage Δ
freebsd ?
linux 76.30% <98.11%> (+0.44%) ⬆️
macos 76.30% <98.11%> (+0.44%) ⬆️
windows 76.33% <98.11%> (+0.44%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@larseggert

Copy link
Copy Markdown
Collaborator

I would wait for SSLResumptionTokenInfo.plaintextSecret. Can't really use it beforehand.

@Frosne
Frosne marked this pull request as draft November 4, 2026 16:37
Comment thread src/agent.rs Resolved
Comment thread src/agent.rs Resolved
Comment thread src/agent.rs Resolved
Comment thread tests/agent.rs Resolved
Comment thread src/agent.rs Resolved
Comment thread tests/agent.rs Resolved
Comment thread src/agent.rs Resolved
Comment thread src/agent.rs Resolved
Comment thread src/agent.rs Resolved
Comment thread src/agent.rs Resolved
@Frosne

Frosne commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

the bump is done here: #345

@Frosne
Frosne marked this pull request as ready for review November 19, 2026 08:05
@Frosne
Frosne requested a review from larseggert November 19, 2026 08:05
@larseggert

Copy link
Copy Markdown
Collaborator

@Frosne CI is failing pretty hard

@Frosne

Frosne commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

@Frosne CI is failing pretty hard

I blame the minimal nss required version (the plaintext field appeared only in 134), but let me check

Comment thread src/agent.rs
}

#[must_use]
pub const fn new_with_early_data(

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.

Maybe a new constrctor?

Comment thread tests/agent.rs Outdated
};

mod handshake;
#[path = "agent/resumption_process.rs"]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why do you need path here?

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.

I wanted to keep the process helper (resumption_process.rs) separate. But without #[path], mod resumption_process; looks for the file in tests/, not in tests/agent/.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Does use agent::resumption_process::... work? This path thing doesn't appear very idiomatic,

Comment thread src/agent.rs Resolved
Comment thread src/agent.rs Resolved
Comment thread src/agent.rs Resolved
Comment thread src/agent.rs Resolved
Comment thread src/agent.rs Resolved
Comment thread src/agent.rs Resolved
Comment thread src/agent.rs

/// A token with the same kind, expiration time and early data limit, with `token` as its bytes.
#[must_use]
pub const fn clone_with_bytes(&self, token: Vec<u8>) -> Self {

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.

I think this patch mozilla/neqo#4405 will be cleaner with the clone_with_bytes function

Copilot AI left a comment

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.

🟡 Changes recommended

Plaintext tokens can be mislabeled as encrypted and exposed through Debug, and the missing zeroize alloc feature can prevent the new derives from compiling.

3 open issues
What changed in this PR

Adds opt-in plaintext resumption-token export to the NSS client API, supporting reuse across processes while making token confidentiality explicit.

Changes:

  • Exposes plaintext export controls and token-kind metadata.
  • Adds plaintext debug redaction and zeroization of token storage.
  • Adds cross-process tests for plaintext resumption and wrapped-token rejection.
File Description
tests/​agent/​resumption_process.rs Adds a subprocess helper for cross-process resumption tests.
tests/​agent.rs Adds configurable client setup and plaintext versus wrapped-token tests.
src/​ssl.rs Binds NSS’s experimental plaintext export API.
src/​lib.rs Re-exports TokenKind.
src/​agent.rs Adds export controls, token classification, redaction, and zeroization.
Cargo.toml Makes zeroize mandatory rather than tied to blapi.

Review effort: Balanced

Comment thread Cargo.toml Resolved
Comment thread src/agent.rs Outdated
#[must_use]
pub const fn new(token: Vec<u8>, expiration_time: Instant) -> Self {
Self::new_with_early_data(token, expiration_time, 0)
Self::new_with_early_data(TokenKind::Encrypted(token), expiration_time, 0)
Comment thread tests/agent/resumption_process.rs Outdated
.spawn()
.expect("should start child"),
);
let (mut stream, _) = listener.accept().expect("child should connect");
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.

4 participants