verify

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 11 Imported by: 0 modules, 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

Overview

Package verify provides action signature signing and verification.

The control server signs actions with its CA private key (ActionSigner); agents verify those signatures against the matching CA certificate's public key (ActionVerifier).

What is signed

The signature is computed over the DETERMINISTIC protobuf wire bytes of a pm.SignedActionEnvelope (see MarshalEnvelope) — the full executed action: action id, action type, params, desired_state, timeout_seconds, schedule, and target_device_id. The agent verifies the signature over the bytes it received and unmarshals THOSE SAME bytes to execute, so the executed message is byte-for-byte the verified message. There is no separate JSON "canonical" form and no typed-params/canonical-params split (the sdk#82 gap): one representation, signed and transported.

Binding the whole envelope means a compromised gateway or Valkey relay cannot flip desired_state, swap params, change the timeout/schedule, lift the type onto SYNC, or retarget the device under a still-valid signature.

Pre-image

digest = SHA-256( len32(domain) || domain || envelopeBytes )

The length-prefixed domain tag (ActionSignatureDomain) keeps this signing surface disjoint from any other surface that might one day share the CA key — the length prefix makes "domain || bytes" unambiguous so no other domain string can be confused with this one followed by a payload.

Determinism is belt-and-braces: correctness comes from signing and TRANSPORTING the exact bytes, then verifying-and-unmarshalling those same bytes. The server (Go) always signs and the agent (Go) always verifies; the web client never verifies an action signature, so cross-language or cross-version marshalling drift cannot bite.

Supported key algorithms: ECDSA (ecdsa.VerifyASN1 / ecdsa.SignASN1) and RSA (PKCS#1 v1.5 with SHA-256). Other key types — including Ed25519 — are explicitly rejected so a key-type drift between server and agent surfaces as a clear error instead of a silent signature mismatch.

No backward-compatibility shim: the project has no stable release, so the signing format is iterated in place. Server and agent must always be on matching SDK versions for verification to succeed.

Index

Constants

View Source
const (
	// ActionSignatureDomain covers the full SignedActionEnvelope.
	ActionSignatureDomain = "power-manage-action"
	// OSQuerySignatureDomain covers an OSQuery dispatch (table or raw_sql).
	OSQuerySignatureDomain = "power-manage-osquery"
	// LogQuerySignatureDomain covers a LogQuery (journalctl) dispatch.
	LogQuerySignatureDomain = "power-manage-logquery"
	// LuksRevokeSignatureDomain covers a RevokeLuksDeviceKey instruction.
	LuksRevokeSignatureDomain = "power-manage-luks-revoke"
	// InventorySignatureDomain covers a server-originated RequestInventory.
	InventorySignatureDomain = "power-manage-inventory"
	// LpsPublicKeySignatureDomain covers the control server's LPS sealing
	// public key distributed to agents in the sync response (spec 18). The
	// CA signature is what stops a relaying gateway from substituting its
	// own key and reading sealed passwords.
	LpsPublicKeySignatureDomain = "power-manage-lps-pubkey"
)

Signing domains. Every distinct signing surface that might share the CA key declares its own domain string; the length-prefixed mix (see canonicalDigest) keeps the pre-image hashes disjoint so a signature minted for one surface can never be replayed against another. Add a new surface by adding a constant here — never reuse an existing domain for a new message type.

Variables

This section is empty.

Functions

func LogQueryCanonical

func LogQueryCanonical(q *pmv1.LogQuery) ([]byte, error)

LogQueryCanonical returns the signing pre-image bytes for a LogQuery. It binds query_id, unit, since, until, priority, grep, kernel, lines and source — so a compromised gateway cannot retarget the unit or widen the query under a valid signature.

func LpsPublicKeyCanonical added in v0.5.3

func LpsPublicKeyCanonical(m *pmv1.LpsPublicKey) ([]byte, error)

LpsPublicKeyCanonical returns the signing pre-image bytes for the control server's LPS sealing key (spec 18). It binds the public key bytes — so a compromised gateway cannot swap in its own key and read sealed passwords — while clearing the signature field the same way as every other surface.

func MarshalEnvelope

func MarshalEnvelope(env *pmv1.SignedActionEnvelope) ([]byte, error)

MarshalEnvelope returns the deterministic protobuf wire bytes of a SignedActionEnvelope — the exact bytes the CA signs (ActionSigner.Sign), the gateway transports (ActionDispatch.envelope), and the agent verifies then unmarshals to execute. Always use this rather than a plain proto.Marshal so signer and verifier agree on byte layout; deterministic marshalling pins map/field ordering across Go versions as belt-and-braces (the load-bearing guarantee is that the SAME bytes are transported and executed, not re-marshalled).

func OSQueryCanonical

func OSQueryCanonical(q *pmv1.OSQuery) ([]byte, error)

OSQueryCanonical returns the signing pre-image bytes for an OSQuery. It binds query_id, table, columns, where, limit and raw_sql — so a compromised gateway cannot swap the table, inject raw_sql, or retarget the query under a valid signature.

func RequestInventoryCanonical

func RequestInventoryCanonical(m *pmv1.RequestInventory) ([]byte, error)

RequestInventoryCanonical returns the signing pre-image bytes for a server-originated RequestInventory. It binds query_id so a compromised gateway cannot forge an inventory-collection command.

func RevokeLuksDeviceKeyCanonical

func RevokeLuksDeviceKeyCanonical(m *pmv1.RevokeLuksDeviceKey) ([]byte, error)

RevokeLuksDeviceKeyCanonical returns the signing pre-image bytes for a RevokeLuksDeviceKey. It binds action_id, so a compromised gateway cannot forge or replay a slot-7 wipe onto any known action_id.

Types

type ActionSigner

type ActionSigner struct {
	// contains filtered or unexported fields
}

ActionSigner signs action envelopes using the CA private key, so agents can verify actions originated from the control server.

func NewActionSigner

func NewActionSigner(key crypto.Signer) *ActionSigner

NewActionSigner creates a signer from a crypto.Signer (e.g. *ecdsa.PrivateKey).

func (*ActionSigner) Sign

func (s *ActionSigner) Sign(envelopeBytes []byte) ([]byte, error)

Sign produces a signature over the deterministic envelope bytes. The caller MUST transport these exact bytes alongside the signature (see MarshalEnvelope) — the agent verifies and executes the same bytes.

func (*ActionSigner) SignDomain

func (s *ActionSigner) SignDomain(domain string, payload []byte) ([]byte, error)

SignDomain signs the payload bytes under the given signing domain. The control server uses this for non-action surfaces (osquery, log query, LUKS revoke, inventory); the agent verifies the result with VerifyDomain under the same domain. The domain is mixed into the pre-image so the signature is disjoint from every other surface that shares the CA key.

type ActionVerifier

type ActionVerifier struct {
	// contains filtered or unexported fields
}

ActionVerifier verifies action signatures using the CA's public key.

func NewActionVerifier

func NewActionVerifier(caCertPEM []byte) (*ActionVerifier, error)

NewActionVerifier creates a verifier from a PEM-encoded CA certificate.

func (*ActionVerifier) Verify

func (v *ActionVerifier) Verify(envelopeBytes, signature []byte) error

Verify checks signature against the deterministic envelope bytes. The caller MUST pass the exact bytes it received (and, on success, unmarshal those same bytes to execute) — never a re-marshalled copy.

func (*ActionVerifier) VerifyDomain

func (v *ActionVerifier) VerifyDomain(domain string, payload, signature []byte) error

VerifyDomain checks signature against the payload bytes under the given signing domain. Use this for non-action surfaces (osquery, log query, LUKS revoke, inventory) — each passes its own domain constant and the deterministic canonical bytes of its message (see canonical.go). The domain is mixed into the pre-image (canonicalDigest) so a signature minted for one domain can never verify under another.

Fail-closed: an empty signature or empty payload is rejected.

Jump to

Keyboard shortcuts

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