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 ¶
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 ¶
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 ¶
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
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.