PLAuditSignatureSource

Signature utilities

Requires the Enterprise edition — declared in the Enterprise-only unit PDFlibEntSignatureStructure, which other editions do not include

Description

Checks that a signature's excluded hexadecimal gap belongs to the selected dictionary's Contents token in a supported signed revision; this low-level helper belongs to the Enterprise-only PDFlibEntSignatureStructure unit

Syntax

function PLDefaultSignatureSourceLimits: TPLSignatureSourceLimits;

function PLAuditSignatureSource(Source: TStream;
  CurrentAnchorOffset: Int64; const Locator: TPLSignatureSourceLocator;
  const ByteRange: TPLSignatureByteRange; const Contents: AnsiString;
  const Limits: TPLSignatureSourceLimits;
  var Budget: TPLSignatureSourceBudget): TPLSignatureSourceReport; overload;

An overload creates a fresh budget; callback overloads accept TPLSignatureRangeRead and an explicit document length instead of a stream

Parameters

SourceA borrowed readable, seekable stream; its position is restored after reads and on return, and it is neither written nor closed
CurrentAnchorOffsetThe current physical offset of a normal owning indirect object, or -1 for a compressed owner whose stable container/member identity is checked instead
LocatorObjectNumber, Generation and a Path array of dictionary-key or array-index steps from that indirect object to the signature dictionary; each step has Kind, Key and Index fields
ByteRange, ContentsThe four exact integer range values and decoded signature bytes, including reservation padding; run the separate byte-range helper before this source audit
LimitsMaxBytes, MaxNodes, MaxDepth and MaxObjectBytes; use PLDefaultSignatureSourceLimits for the documented defaults
BudgetReadBytes, ScannedBytes and Nodes, initialized to zero and reusable across signatures in one document; a fresh budget for each call does not establish an aggregate document limit

Report

sssVerifiedThe declared source ownership and supported revision checks pass; this is not a full PDF or signature-validity verdict
sssInvalidThe excluded gap does not exactly match the selected Contents source token, even if another token contains identical decoded bytes
sssIncompleteThe source identity, encoding, parse, read or work bounds prevent the declared checks from finishing
DetailsContentsOwnerChecked, RevisionChecked, SignedLength, RevisionXRefOffset, ContentsStart, ContentsEnd and Reason describe the established stages and their boundaries

Supported scope and limits

The audit parses bounded xref tables, xref streams, hybrid supplements and their Prev chains, honors free entries, generations and the head trailer's Size, binds each selected revision tail to its xref trailer, and locates a unique Contents entry through a stable indirect anchor and direct dictionary/array path

Within a hybrid revision, table entries take precedence over its XRefStm supplement, followed by older Prev sections; free entries, unknown-null types and compressed entries block fallback to older objects

Supported cross-reference stream encodings are unfiltered data, ASCIIHexDecode, FlateDecode and ASCIIHexDecode followed by FlateDecode, with the supported TIFF and PNG predictor parameters; Flate decoding requires complete input consumption, a clean checksum/end and the exact supported output size rather than accepting a truncated prefix

Encoded and decoded buffers are checked before allocation; decoding and predictor work share ScannedBytes, including reserved failed decode work, so retrying bad compressed streams cannot bypass the aggregate limit

A stable type-2 owner is supported when its ObjStm is unencoded and retains the same uncompressed generation-zero container identity in the current and signed revisions; N, First, Length, member numbers and ordered offsets are bounded and checked before the selected direct locator path is followed

Every container member is parsed within its own exact physical slice, so a preceding literal string, overlapping member or identical hex token outside the selected Contents cannot supply ownership; encoded, external or redefined containers retain incomplete results

Numeric tokens in the supported source headers and reference paths use PDF decimal integer syntax; implementation-language hexadecimal forms do not qualify, and an inherited container must remain within both head revision Size values

Historical signatures remain supported when later revisions retain their anchor identity; the signed revision need not end at the current file length

Default read and scan budgets are separately 64 MiB, node work is 100000, nesting and revision depth are at most 64, and one parsed object is bounded to 16 MiB; configured recursion depth has an additional hard ceiling of 256

Encoded object-stream owners, redefined anchor identities, unsupported filter pipelines, indirect decoding parameters, duplicate relevant keys and indirect references crossed within a direct locator path remain incomplete; callers should start a new anchor when traversing an indirect reference

The Enterprise PDF/A-2/3 audit builds source locators from the rooted field path, shares one source budget across signatures and preserves incomplete results as finding 00130; proven token mismatches use 00128

CMS structure, cryptographic integrity, certificate trust, revocation and trusted time are separate checks; this helper also does not certify all generic PDF syntax or every possible overlapping-object construction