Repository navigation
Fixes to support Firmware TPM swtpm transport server on Windows - #623
Merged
Merged
Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The socket-width, lifecycle, API, and platform-specific changes are consistent and covered by an end-to-end Windows workflow.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes Windows socket-handle compatibility for swtpm transport and adds end-to-end Windows coverage.
Changes:
- Uses pointer-width socket types, correct invalid sentinels, and Winsock APIs.
- Corrects fwTPM server and TLS example socket handling.
- Adds a Windows MSYS2 transport test.
| File | Description |
|---|---|
wolftpm/tpm2.h |
Widens Windows socket storage. |
wolftpm/tpm2_socket.h |
Defines portable invalid-socket handling. |
src/tpm2_swtpm.c |
Adds correct Winsock initialization and I/O. |
src/fwtpm/fwtpm_io.c |
Preserves Windows socket width in server paths. |
examples/tls/tls_server.c |
Initializes sockets with the portable sentinel. |
examples/tls/tls_common.h |
Uses portable socket validity checks. |
examples/tls/tls_client.c |
Initializes sockets with the portable sentinel. |
.github/workflows/win-swtpm-test.yml |
Adds Windows swtpm integration coverage. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
aidangarske
approved these changes
Oct 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The socket transport has not worked on Windows.
wolfTPM_tcpContext.fdis anint, while a WinsockSOCKETis an unsigned pointer-width handle and is not a C runtime file descriptor.tcpCtx.fdisuintptr_ton Windows. Thefd < 0guards, which cannot fire on an unsigned type, now use an invalid-socket sentinel.read(),write()andclose()do not accept aSOCKET. The transport usesrecv,sendandclosesocketthere; UART mode keeps the POSIX calls.SwTpmConnect()calledgetaddrinfo()beforeWSAStartup().setsockopt()was passedvoid*where Winsock declaresconst char*.FWTPM_IO_ServerLoop()held socket handles inint maxFd, and four connection handlers tookint clientFd.SOCKET_INVALIDwas0xFFFFFFFF, which matches no socket on a 64 bit build.Non-Windows builds generate identical code.
Hardware / test status
Linux x86-64: TLS 1.3 handshake against the firmware TPM, ML-KEM-768 key exchange, ML-DSA-65 identity held in the TPM.
Windows x64, MSYS2, mingw-w64 gcc 13.2.0,
-Werroron: same handshake completes; previously the transport could not connect at all.