authenticode

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 21 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotPE = errors.New("not a PE image")

ErrNotPE is what Sign returns for a file that is no PE image.

Functions

func Sign

func Sign(data []byte, key *Key, stamp Stamper) ([]byte, error)

Sign signs a PE image with key and, with a stamper, a timestamp, and returns the image with its signature. An image signed before is signed again in place of its old signature.

func SignMSIX

func SignMSIX(data []byte, key *Key, stamp Stamper) ([]byte, error)

SignMSIX returns an MSIX package signed by key, replacing an existing signature. It preserves payload bytes and block-map bytes, registers the signature's content type and carries the APPX SIP digest in CMS. Windows still requires a trusted signing identity to install it.

func Signed

func Signed(data []byte) bool

Signed reports whether a PE image carries a signature.

Types

type Key

type Key struct {
	Private *rsa.PrivateKey
	Cert    *x509.Certificate
	// Chain holds the certificates above Cert that the signature carries,
	// so that Windows need not fetch them.
	Chain []*x509.Certificate
}

Key is the identity a Windows file is signed with.

type Stamper

type Stamper interface {
	Token(digest []byte) ([]byte, error)
}

Stamper asks a timestamp server to sign the digest of a signature's value. RFC 3161's TimeStampReq asks, and the token of its TimeStampResp answer is the signature's unsigned attribute.

type Timestamp

type Timestamp struct {
	// URL is the server's address, such as http://timestamp.digicert.com.
	URL string
	// Client makes the request; http.DefaultClient without one.
	Client *http.Client
}

Timestamp is a timestamp server, RFC 3161's: it signs the digest of a signature's value with the current time, so that Windows trusts the signature past the certificate's expiration.

func (*Timestamp) Token

func (t *Timestamp) Token(digest []byte) ([]byte, error)

Token asks the server to sign digest and returns its token, the TimeStampResp's TimeStampToken.

Jump to

Keyboard shortcuts

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