pades

package
v1.122.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package pades seals a PDF with a PAdES baseline signature at level B-LTA: a CAdES signature with a signature timestamp, the validation data in a document security store, and a document timestamp over all of it.

Each step is an incremental update, so every byte of the document as given stays a prefix of the sealed file.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyMismatch         = errors.New("the sealing certificate is not for the signer's key")
	ErrReservationTooSmall = errors.New("signature contents larger than reserved")
	// ErrCertificateNotValid is a sealing certificate whose validity does not hold now: expired, or not valid yet. A seal
	// made with it fails validation whatever else holds, so none is made.
	ErrCertificateNotValid = errors.New("the sealing certificate is not valid now")
)

Errors in the sealer's own setup; they are not the document's fault, so none is classed as client input.

View Source
var ErrInvalidRectangle = errors.New("invalid field rectangle")

ErrInvalidRectangle is a field rectangle that is not a box on a page.

Functions

func ByteRangeContent

func ByteRangeContent(data []byte, byteRange [4]int) ([]byte, error)

ByteRangeContent returns what a signature with this byte range covers in the revision it signed, which ends where the range does.

func QualifiedForSeals

func QualifiedForSeals(certificate *x509.Certificate) bool

QualifiedForSeals reports whether the certificate states, in its QC statements, that it is an EU qualified certificate for electronic seals.

Types

type Rectangle added in v1.116.0

type Rectangle struct {
	Left   float64
	Bottom float64
	Right  float64
	Top    float64
}

Rectangle is a box on a page, in points from its lower-left corner.

type Sealer

type Sealer struct {
	Signer crypto.Signer
	// Certificates is the sealing certificate first, then its issuers.
	Certificates []*x509.Certificate
	Timestamper  tsa.Timestamper
	Collector    *validation_data.Collector
	// SealRectangle places the seal's field on the last page, over what the page prints for it, so a reader opens its check of the seal there; nil leaves the field off the page.
	SealRectangle *Rectangle
	Now           func() time.Time
}

Sealer seals documents with one key and its certificate chain.

func (*Sealer) Seal

func (s *Sealer) Seal(ctx context.Context, data []byte) ([]byte, error)

Seal returns the document with a B-LTA seal appended as three incremental updates. It refuses, before anything is signed or timestamped, a signer the sealing certificate is not for (ErrKeyMismatch) and a certificate not valid at the sealer's now (ErrCertificateNotValid).

Jump to

Keyboard shortcuts

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