Help us shape the future of Go! Take the 2026 Go Developer Survey

windowsign

package
v3.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 26 Imported by: 0

README

Portable Windows signatures

SignPE and SignMSIX sign with exported RSA identities on any Go host. They use the shared codesignature package for authenticated PFX decoding, SHA-256 CMS signatures and verified RFC 3161 timestamps. No modules were added and no third-party signing implementation was copied or adapted.

PE signing follows Microsoft's PE format and Authenticode PE specification: the checksum, certificate directory entry and certificate table are excluded from the image digest. An aligned certificate table at the end of a previously signed image is replaced; unsupported nonterminal tables fail explicitly.

MSIX signing uses the APPX SIP digest identifiers declared by Microsoft's SDK: AXPC authenticates local file records, AXCD the central directory and unsigned ZIP footer, AXCT content types, AXBM the block map, and optional AXCI the code integrity catalog. Owned SignTool-generated fixtures independently established these ranges and the PKCX/CMS encoding. The signature entry's ZIP creator version must be 45, matching the ZIP64 footer, for native verification to accept it. Existing local file records are copied literally, preserving local extra fields that may differ from central-directory metadata. Only content types and the signature footprint are changed. Payload hashes, block counts, compressed block boundaries, local-header sizes and publisher/certificate RDNs are checked first. The original code-integrity catalog, if present, is preserved and authenticated.

Input is copied into a private immutable snapshot before validation/signing and closed before publication. This supports in-place replacement on Windows and prevents input changes during a timestamp request from invalidating the output. Failures remove temporary files and preserve the prior output.

Supported formats are PE32/PE32+ and individual MSIX/APPX packages smaller than 4 GiB. MSI, MSIX bundles, ZIP comments and packages with 65535 or more entries are rejected. ZIP64 local/central metadata and end-of-directory records produced by native package tools are supported when individual sizes and offsets fit in 32 bits. Signature certificates currently require RSA 2048–8192 and SHA-256. Certificate-store, hardware/cloud-provider and unsupported PFX profiles remain platform signing-tool workflows; this package does not emulate those providers.

Validation uses retained standard-library tests for signing, re-signing, transactions, immutable input, publisher parsing, package corruption, metadata and fake timestamps. External native checks use Windows SDK SignTool plus WinVerifyTrust with an in-memory exclusive root containing only an owned test certificate. Valid PE/MSIX signatures pass; tampered counterparts fail with TRUST_E_BAD_DIGEST. This test trust does not establish production publisher trust.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SignMSIX

func SignMSIX(ctx context.Context, input, output string, identity Identity, options Options) error

SignMSIX signs an individual MSIX/APPX package, replacing an existing signature. Bundles and ZIP entries requiring 64-bit sizes are not supported. Payload compression and the block map are preserved.

func SignPE

func SignPE(ctx context.Context, input, output string, identity Identity, options Options) error

SignPE replaces an existing terminal certificate table after validating the image layout. It preserves the source until the complete output is ready.

Types

type Identity

type Identity = codesignature.Identity

func DecodePFX

func DecodePFX(data []byte, password string) (Identity, error)

type Options

type Options = codesignature.Options

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL