SignAuditEvidence

Enterprise, audit evidence and signatures

Requires the Enterprise edition — in Delphi, C++Builder and Lazarus code create the library as TPDFlibEnterprise (unit PDFlibEnterprise); the Enterprise DLL and ActiveX builds provide it unchanged; other editions keep the method, which returns an empty string and sets LastErrorCode to 900 (PDFLIB_ERROR_ENTERPRISE_REQUIRED)

Description

Canonicalizes a valid single-file audit evidence object and signs those exact UTF-8 bytes with a detached CMS signature from a PFX identity

Syntax

Delphi

Function TPDFlib.SignAuditEvidence(Const EvidenceJSON, PFXFileName,
  PFXPassword: WideString; DigestAlgorithm: Integer): WideString; Virtual;

ActiveX

Function PDFlib::SignAuditEvidence(EvidenceJSON As String, PFXFileName As String, PFXPassword As String, DigestAlgorithm As Long) As String

DLL

const wchar_t* DLSignAuditEvidence(int InstanceID, const wchar_t* EvidenceJSON, const wchar_t* PFXFileName, const wchar_t* PFXPassword, int DigestAlgorithm);
const char* DLSignAuditEvidenceA(int InstanceID, const char* EvidenceJSON, const char* PFXFileName, const char* PFXPassword, int DigestAlgorithm);

Parameters

EvidenceJSONStructurally valid single-file result of CreateAuditEvidence; batch envelopes and operational error objects are rejected, while policy-rejected or incomplete evidence may still be signed without changing its conclusions
PFXFileNamePath to the PFX/PKCS#12 identity containing the signing key; required, must contain no NUL and is limited to 16 MiB
PFXPasswordPassword for the PFX identity; may be empty for an unprotected identity, accepts at most 4096 UTF-16 code units and must contain no NUL
DigestAlgorithm2 for SHA-256, 3 for SHA-384 or 4 for SHA-512; SHA-1 and automatic selection are not accepted

Return values

Returns an envelope with schemaVersion:1, status:"ok", canonicalization, payloadSha256, canonical evidence and lowercase cmsDERHex. Other editions return an empty string with error 900; operational failures return an error object with error 905.

Deterministic payload profile

pdflib-evidence-json-v1 sorts object keys by UTF-16 ordinal order, retains array order, normalizes finite JSON decimal spellings exactly without binary floating point, escapes strings consistently and encodes the result as UTF-8

This is a named library profile rather than RFC 8785; duplicate keys, malformed Unicode and values beyond its node, depth, numeric and output limits are rejected

Equivalent accepted JSON objects produce the same canonical payload and payload SHA-256; the CMS bytes can vary because signing providers may use random values or signed attributes

Result and limits

A successful envelope contains schemaVersion:1, status:"ok", canonicalization, payloadSha256, canonical evidence and lowercase cmsDERHex; the newly created signature is independently checked before being returned

The operation does not rewrite a PDF or authenticate a standards verdict; source fingerprints, model identity, original accepted/complete values and fullCertification:false remain part of the signed payload

The profile allows 8388608 UTF-16 input units, 16777216 canonical UTF-8 bytes, 50000 nodes, depth 48 and 2097152 CMS bytes; numbers are bounded to 1024 source characters and an absolute decimal exponent of 1024

PFX input is limited to 16 MiB, and the password to 4096 UTF-16 units without NUL; private-key UI is disabled; Windows imports are ephemeral rather than persisted into the user's key store; credentials are used only for this explicit signing operation and are not included in the envelope

Single and Small Business instances return an empty string with error 900; operational failures return an error object with error 905; ActiveX uses IPDFlibrary10, and Dylib exposes the same wide and ANSI names with cdecl

Example

Envelope:= PDF.SignAuditEvidence(Evidence, 'audit-identity.pfx', Password, 2);
Verification:= PDF.VerifyAuditEvidenceEnvelope(Envelope, '{}');

Run the shared workflow CLI example through the Delphi, Lazarus or C++Builder entry for the required edition, including progress and batch cancellation

See also

VerifyAuditEvidenceEnvelope · CreateAuditEvidence · CompareAuditEvidence