verify

package
v0.1.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 22 Imported by: ? 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 checks an Inkless evidence package or sealed PDF offline. It makes no network calls. Each check is reported separately; see docs/verification.md.

Index

Examples

Constants

View Source
const (
	// CheckPackage covers the manifest and the package's file set.
	CheckPackage = "package"
	// CheckEvidence covers the event hash chain and the evidence signature.
	CheckEvidence = "evidence"
	// CheckDocument covers the integrity of the original and final PDFs.
	CheckDocument = "document"
	// CheckSeal covers the PDF's cryptographic seal and its certificate.
	CheckSeal = "seal"
	// CheckAttribution covers the recorded consent and challenge per signer.
	CheckAttribution = "attribution"
	// CheckTimestamp covers the RFC 3161 timestamp over the evidence
	// signature.
	CheckTimestamp = "timestamp"
)

Names of the checks in a Report.

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check struct {
	// Name is one of the Check* constants.
	Name   string `json:"name"`
	Status Status `json:"status"`
	// Reason explains Status in one line.
	Reason string `json:"reason"`
	// Details holds per-item findings, such as one line per signer.
	Details []string `json:"details,omitempty"`
}

Check is the result of one verification step.

type Options

type Options struct {
	// KeyListRoot is the pinned RFC 7638 thumbprint (base64url) of the
	// key-list root key.
	KeyListRoot string
	// KeyLists are additional signed key lists, such as a newer keys.json
	// that marks a key compromised. The newest valid list wins.
	KeyLists [][]byte
	// SealRoots are the trust anchors for the PDF seal certificate.
	SealRoots *x509.CertPool
	// TSARoots are the trust anchors for timestamp authority certificates.
	TSARoots *x509.CertPool
	// Limits bounds package extraction; the zero value selects
	// evidence.DefaultLimits.
	Limits evidence.Limits
}

Options carries the verifier's trust configuration. A missing anchor makes the checks that need it Indeterminate rather than Passed. Options are read-only during verification.

type Report

type Report struct {
	// Input is "package" or "pdf".
	Input string `json:"input"`
	// Result is Failed if any check failed, otherwise Indeterminate if any
	// check was indeterminate, otherwise Passed.
	Result Status  `json:"result"`
	Checks []Check `json:"checks"`
}

Report is the result of verifying one input.

func PDF

func PDF(pdf []byte, opts Options) *Report

PDF verifies a sealed PDF on its own. Without the evidence package, attribution and the evidence timestamp are indeterminate. The seal key is bound to a key list only if opts.KeyLists supplies one; otherwise the seal reason says the binding was not checked, and a seal key marked compromised would go unnoticed. It never panics on malformed input.

func Package

func Package(zipData []byte, opts Options) *Report

Package verifies an evidence.zip. It never panics on malformed input; an unreadable package yields a Failed package check and Indeterminate rest.

Example

ExamplePackage verifies the evidence package of a completed signing request against a pinned key-list root and the seal and timestamp trust anchors. Without those anchors the affected checks would be indeterminate.

package main

import (
	"crypto/x509"
	"fmt"
	"log"
	"os"
	"strings"

	"github.com/edgar4/inkless/verify"
)

func pool(path string) *x509.CertPool {
	pem, err := os.ReadFile(path)
	if err != nil {
		log.Fatal(err)
	}
	p := x509.NewCertPool()
	if !p.AppendCertsFromPEM(pem) {
		log.Fatalf("%s: no certificates", path)
	}
	return p
}

// ExamplePackage verifies the evidence package of a completed signing request
// against a pinned key-list root and the seal and timestamp trust anchors.
// Without those anchors the affected checks would be indeterminate.
func main() {
	zip, err := os.ReadFile("../testdata/fixture/evidence.zip")
	if err != nil {
		log.Fatal(err)
	}
	root, err := os.ReadFile("../testdata/fixture/root.txt")
	if err != nil {
		log.Fatal(err)
	}
	report := verify.Package(zip, verify.Options{
		KeyListRoot: strings.TrimSpace(string(root)),
		SealRoots:   pool("../testdata/fixture/seal-ca.pem"),
		TSARoots:    pool("../testdata/fixture/tsa-ca.pem"),
	})
	fmt.Println("result:", report.Result)
	for _, c := range report.Checks {
		fmt.Printf("%s: %s\n", c.Name, c.Status)
	}
}
Output:
result: passed
package: passed
evidence: passed
document: passed
seal: passed
attribution: passed
timestamp: passed

func (*Report) Failed

func (r *Report) Failed() bool

Failed reports whether the overall result is Failed.

func (*Report) Get

func (r *Report) Get(name string) Check

Get returns the check with the given name, or the zero Check if there is none.

func (*Report) WriteText

func (r *Report) WriteText(w io.Writer) error

WriteText writes a human-readable report to w.

type Status

type Status string

Status is the outcome of a check or of a whole report.

const (
	// Passed means the check succeeded.
	Passed Status = "passed"
	// Failed means the check found a defect or tampering.
	Failed Status = "failed"
	// Indeterminate means the check could neither pass nor fail.
	Indeterminate Status = "indeterminate"
)

Check outcomes. A check is Indeterminate when it could not be decided with the configured trust anchors and inputs, for example because no root is pinned or the evidence package is absent.

Jump to

Keyboard shortcuts

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