Repository navigation
Conversation
virzak
commented
May 8, 2023
virzak
force-pushed
the
CsWin32
branch
5 times, most recently
from
February 7, 2025 17:45
771ffd4 to
ae57a25
Compare
Author
|
Rebased |
virzak
force-pushed
the
CsWin32
branch
2 times, most recently
from
September 11, 2026 22:14
7bebc71 to
488e3bb
Compare
Generate the crypt32 and mssign32 P/Invokes with CsWin32 instead of declaring them by hand. Interop/crypt32.cs is removed. mssign32.cs keeps only SIGNER_SIGN_EX3_PARAMS, APPX_SIP_CLIENT_DATA and the managed sign callback delegate, which the Win32 metadata lacks. - Call the raw SignerSignEx3 extern and pin the ASCII timestamp OID once, so the same pointer reaches both the call and the Appx SIP parameters. SIGNER_SIGN_EX3_PARAMS must stay blittable: a managed field changes its in-memory layout and breaks every Appx/MSIX signature. - Use the generated V2 SIGNER_DIGEST_SIGN_INFO with cbSize = sizeof and dwDigestSignChoice = SIGNER_DIGEST_SIGN, which is also correct on x86. - Keep an HCERTSTORE in MemoryCertificateStore and suppress CA1416 there, since the library is Windows-only. - Add MSIX signing tests so the Appx SIP path has coverage. Generated with Claude Code
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.
Replaces most of the hand-written P/Invoke declarations in
AzureSign.Corewith CsWin32-generated ones (NativeMethods.txt).Interop/crypt32.csis gone, andInterop/mssign32.csshrinks to the pieces the Win32 metadata still lacks:SIGNER_SIGN_EX3_PARAMS,APPX_SIP_CLIENT_DATAand the managed sign callback delegate. None of those structures is declared in the Windows SDK headers either (see microsoft/win32metadata#2307).Notable details
SignerSignEx3is called through CsWin32's raw extern, so the ASCII timestamp OID is pinned once and the same pointer goes to both the call and the Appx SIP parameters.SIGNER_SIGN_EX3_PARAMSstays blittable, which the Appx SIP path depends on.SIGNER_DIGEST_SIGN_INFOuses the generated (V2) layout withcbSize = sizeof(...)anddwDigestSignChoice = SIGNER_DIGEST_SIGN, replacing the hand-written V1 struct.MemoryCertificateStoreholds anHCERTSTORE. CA1416 is suppressed in that file because CsWin32 marks the crypt32 store APIs Windows-only, and this library is Windows-only.Testing
signtarget.msix, RSA and ECDSA, with and without an RFC 3161 timestamp) cover the Appx SIP path, which previously had no tests.dotnet testpasses on x64 (56/56). CI only covers x64 and ARM64, so I also ran the core tests as x86 (dotnet test -a x86, 53/53).main.Generated with Claude Code