Skip to content

keylog: add a random size argument to Curl_tls_keylog_write() - #22560

Closed
bagder wants to merge 2 commits into
masterfrom
bagder/keylog-random-size
Closed

bagder wants to merge 2 commits into
masterfrom
bagder/keylog-random-size

Conversation

@bagder

@bagder bagder commented Aug 12, 2026

Copy link
Copy Markdown
Member

To allow the function to verify that the buffer is large enough. Avoids possible future internal mishaps.

To allow the function to verify that the buffer is large enough. Avoids
possible future internal mishaps.
@bagder bagder added the TLS label Aug 12, 2026
@bagder
bagder requested a lite review from Copilot August 12, 2026 12:14
@bagder
bagder marked this pull request as ready for review August 12, 2026 12:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates libcurl’s internal TLS keylog writer API to accept an explicit client-random buffer length, allowing the implementation to validate the input size before formatting the NSS-style keylog line.

Changes:

  • Extend Curl_tls_keylog_write() to take a random_size argument and validate it against CLIENT_RANDOM_SIZE.
  • Update TLS backend call sites (OpenSSL, wolfSSL, GnuTLS, rustls) to pass the client-random length/size.
  • Add defensive checks in the keylog implementation to reject undersized client-random buffers.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
lib/vtls/keylog.h Updates the Curl_tls_keylog_write() declaration to include random_size.
lib/vtls/keylog.c Updates the definition and adds a size assertion/guard before formatting the line.
lib/vtls/openssl.c Passes sizeof(client_random) to the updated keylog writer.
lib/vtls/wolfssl.c Passes client-random size/length to the updated keylog writer in TLS 1.2/1.3 paths.
lib/vtls/gtls.c Passes crandom.size to the updated keylog writer (after verifying it is 32).
lib/vtls/rustls.c Passes client_random_len to the updated keylog writer in the rustls keylog callback.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/vtls/rustls.c
Comment thread lib/vtls/wolfssl.c
@bagder bagder closed this in fbfb249 Aug 12, 2026
@bagder
bagder deleted the bagder/keylog-random-size branch August 12, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants