PLCheckCMSSignedDataStructure

Signature utilities

Description

Performs a bounded DER and SignedData structure audit for one signer with a matching embedded X.509 certificate; the read-only PDFlibCMSRead unit is available in every edition, and the Enterprise PDF/A-2/3 validator uses this helper for its declared CMS structure checks

Syntax

function PLCheckCMSSignedDataStructure(const CMSBytes: AnsiString;
  out Incomplete: Boolean): Boolean;

Parameters

CMSBytesOne complete binary DER ContentInfo containing SignedData, without PDF hexadecimal encoding or reservation padding; use PLTrimCMSPadding separately and validate discarded padding when processing a PDF signature

Return values

Result = TrueThe declared structure checks pass and Incomplete is false; this is not a cryptographic signature or certificate-trust verdict
Result = False, Incomplete = FalseA checked structural constraint fails
Result = False, Incomplete = TrueAn unsupported encoding choice or explicit work limit prevents a complete structure decision; preserve this outcome separately from invalid and passed

Checked structure

The audit checks complete field boundaries, basic DER length and primitive encoding, applicable SET ordering, SignedData and SignerInfo field types and order, one signer, its matching embedded certificate, the certificate's basic X.509 field framework and required content-type/message-digest signed-attribute structure

Issuer-and-serial and subject-key-identifier signer identities, detached and encapsulated data, and the CMS envelope of RFC 3161 timestamp tokens have qualified positive inputs; the timestamp payload itself is not validated by this helper

Limits and unverified regions

The input bound is 16 MiB, constructed nesting depth is at most 32 and the per-call work bound is 100000 node visits; reads for schema checks and SET ordering share that work counter

CRL/revocation choices, attribute or other certificate choices, high-numbered ASN.1 tags and legacy PKCS#7 version 1 non-data ContentInfo encodings remain incomplete; the legacy ANY content model is not assumed to be the CMS OCTET STRING model

The signature algorithm OID in TBSCertificate must equal the outer Certificate signatureAlgorithm OID, including for an otherwise unfamiliar algorithm; differing OIDs are proven invalid, while absent versus NULL and other parameter-value semantics remain outside this check

Algorithm parameters, certificate extensions and arbitrary attribute-value semantics, certificate validity times, signature digest verification, trust paths, revocation and trusted signing time remain outside the declared structure checks; a syntactically valid unknown algorithm identifier is not rejected merely because its name is unfamiliar

Existing certificate extraction and signer-count functions retain their permissive read-side contracts; successful extraction alone is not equivalent to this audit

This Pascal unit function has no separate DLL or ActiveX forwarding entry point

References

RFC 2315 section 9 and RFC 5652 section 5