HotXLS documentation

Multiple OPC signature operations

The explicit byte-array APIs in lxSignatureOpcIssuer inspect a bounded set of attached package signatures, verify a caller-selected signature, or return an individual result for every discovered signature

Enterprise edition: Multiple-signature discovery and verification, trust evaluation, appending and replacing signatures ship only with HotXLS Enterprise, in the lxSignatureOpcIssuer unit of the HotXLSEnterprise package (HotXLSLazEnterprise.lpk for Lazarus); Delphi and Lazarus applications add lxSignatureOpcIssuer to a uses clause and statically linked C++Builder applications call XlsEnableXlsxSigning() once. These functions moved from lxSignatureOpcIntegrity to lxSignatureOpcIssuer with unchanged signatures

Discover an unverified inventory

XlsDiscoverSignatureOpcPackage(Bytes, Inventory) returns TXLSSignatureOpcDiscoveryStatus; xsodDiscovered means the origin and signature-part relationships form a supported structural inventory

Inventory.OriginPart and Inventory.SignatureParts are unauthenticated discovery data: discovery does not verify signature XML, identify a verified signer, establish authenticated content coverage or evaluate certificate trust

Names follow the origin relationship order, which unsigned relationship edits can change; use an explicit part name when the application needs a particular signature rather than assigning meaning to an array position

Verify an explicit signature part

XlsVerifySelectedSignatureOpcPackage(Bytes, SignaturePart, Details) requires an explicit attached signature-part name and verifies that signature's RSA-SHA256 value and selected package References

On xsoiIntegrityVerified, Details.SignaturePart, Certificate, CheckedReferences and Coverage belong to the actual verified signature; the integrity result remains xsstUntrusted

Within a discovered signed package, a valid but unattached name returns xsoiSignatureNotFound; an empty or malformed selector fails and never requests the first signature implicitly

Canonical case-insensitive package identity resolves to the actual stored part name reported on success; selection is bounded to 4096 UTF-16 code units before making its private copy

A malformed or invalid unselected signature can remain in the structural inventory while a different, explicitly selected signature verifies; successful selection establishes only that signature and its reported coverage

Verify every signature with individual results

XlsVerifyAllSignaturesOpcPackage(Bytes, Reports) returns xsoiIntegrityVerified only when every admitted signature verifies; otherwise its aggregate result is the first failure in inventory order

Each TXLSSignatureOpcVerification retains its structurally discovered SignaturePart, individual Status and verified Integrity result when successful

A failed individual result has empty authenticated identity, certificate and coverage; its structural report name still identifies which attempted signature failed, and checking continues for the other signatures within the shared resource bounds

Structural discovery or outer allocation failure clears the report array instead of publishing a partial inventory; callers must inspect both the aggregate status and each returned report

Keep requested and aggregate results separate

The caller supplies the requested part name; this example logs structural names separately from individual verification results and never selects the first inventory entry automatically

uses
  System.SysUtils, System.Classes, lxSignatureOpcIntegrity;

procedure LogPackageSignatureResults(const PackageBytes: TBytes;
  const RequestedPart: WideString; Log: TStrings);
var
  Inventory: TXLSSignatureOpcInventory;
  Discovery: TXLSSignatureOpcDiscoveryStatus;
  Selected: TXLSSignatureOpcIntegrityResult;
  Reports: TXLSSignatureOpcVerifications;
  SelectedStatus, AggregateStatus: TXLSSignatureOpcIntegrityStatus;
  I: Integer;
begin
  Discovery := XlsDiscoverSignatureOpcPackage(PackageBytes, Inventory);
  Log.Add('Discovery status: ' + IntToStr(Ord(Discovery)));
  if Discovery <> xsodDiscovered then
    Exit;
  for I := 0 to High(Inventory.SignatureParts) do
    Log.Add('Unverified inventory: ' + String(Inventory.SignatureParts[I]));

  SelectedStatus := XlsVerifySelectedSignatureOpcPackage(
    PackageBytes, RequestedPart, Selected);
  Log.Add('Requested verification: ' + IntToStr(Ord(SelectedStatus)));
  if SelectedStatus = xsoiIntegrityVerified then
    Log.Add('Verified selected part: ' + String(Selected.SignaturePart));

  AggregateStatus := XlsVerifyAllSignaturesOpcPackage(PackageBytes, Reports);
  Log.Add('Aggregate verification: ' + IntToStr(Ord(AggregateStatus)));
  for I := 0 to High(Reports) do
    Log.Add(String(Reports[I].SignaturePart) + ': ' +
      IntToStr(Ord(Reports[I].Status)));
end;

Apply trust to the verified selection

XlsVerifySelectedSignatureOpcPackageWithTrust(Bytes, SignaturePart, Policy, Details) composes explicit selected verification with the existing caller-owned trust policy

The supplied anchors, intermediates, UTC verification time, EKU and revocation policy apply to the certificate that actually passed the selected signature; no caller-supplied alternate leaf can substitute for that identity

xsotTrustedSelection describes that verified selection and its authenticated coverage, without declaring that every signature, every workbook part or the entire package is trusted

The certificate-chain backend retains its existing Windows qualification and explicit unavailable status on unsupported targets; this increment does not add aggregate certificate trust or change the process certificate stores

Structural ownership and shared limits

The explicit APIs admit at most one signature origin and 32 signature parts; every internal signature relationship must resolve to the corresponding content type, and attached targets and physical signature parts must form a one-to-one set

Duplicate targets, orphan signature parts, missing targets and invalid ownership reject rather than being silently omitted from the inventory

All-signature verification shares one opened package, its aggregate read budget and 8388608 structural work units across the complete inventory, rather than reopening the package with a fresh budget for each signature

The existing 64 MiB package input and aggregate-read limits, 16 MiB per-part limit and XML, Reference and cryptographic profile bounds remain in effect; resource refusal is an explicit result, and a later signature need not verify once a shared budget is exhausted

Input byte arrays remain caller owned; selector text is copied before clearing an aliased result field, and authenticated details are published only after the selected signature and References verify

Append while preserving every verified signature

XlsAppendVerifiedSignatureOpcPackage(Bytes, Certificate, Options, Signer, Output, Details) adds one caller-signed signature to a package with one through 31 already valid signatures, retaining the original origin and every old signature

The operation verifies all existing signatures before staging, checks them again against the actual placeholder infrastructure, and verifies the completed output before publication; old signature XML, ordinary part bytes and existing media bindings remain unchanged

Options is the existing TXLSSignatureOpcIssueOptions with explicit raw, canonical XML or relationship-transform selections and a valid UTC claimed signing time; selections may also name parts of the verified original-signature inventory, enabling counter-signatures over existing signatures, consecutive counter-signature chains and mixed signature/content selections, while each appended signature records only its direct selections and unverified signature parts remain invalid selections; the supplied certificate and caller-owned RSA-SHA256 signer retain the existing issuing contract

TXLSSignatureOpcAppendSignDigest receives a TXLSSignatureOpcAppendRequest containing OriginalPackageSha256, StagedPackageSha256, the allocated SignaturePart, deep-copied verified OriginalSignatures and the new NewSignature request

NewSignature.InputPackageSha256 identifies the exact placeholder-stage package whose selection produced the requested digest; it is distinct from the original package hash and final output hash

The callback reports the existing TXLSSignatureOpcSignerStatus; its returned bytes must be the RSA signature over the supplied SHA-256 digest with the supplied certificate's key, and no private key or certificate-store ownership transfers to the library

TXLSSignatureOpcAppendResult contains Status, SignerCalled, exact InputPackageSha256, StagedPackageSha256 and OutputPackageSha256, the new SignaturePart, verified OriginalSignatures and FinalSignatures, and the new signature's Integrity result

Successful append returns xsapAppended from TXLSSignatureOpcAppendStatus; xsapUnsignedSource leaves initial signing to the existing unsigned issuer, and an already full 32-signature source returns xsapResourceLimit before calling the signer

Adding a signature relationship or content-type binding can invalidate an old signature that authenticates shared infrastructure; the actual staged verification returns xsapWouldInvalidate before calling the signer for the qualified interference profile

Other failures report xsapInvalidSource, xsapInvalidSelection, xsapInvalidCertificate, xsapSignerCancelled, xsapSignerFailed or xsapVerificationFailed as applicable; every failure retains the previous output and clears authenticated result identity and coverage, while preserving the current status and whether the signer was called

Shared array values and input/output aliases are supported; the storage of the Output variable itself must not overlap the Details record

The transaction retains the 64 MiB input/output limit, 16 MiB per-part limit and one 8388608-unit editor/verifier work budget; at most seven bounded package opens admit at most 448 MiB of aggregate reads across phases, while nested parser, Reference and crypto bounds retain their original invocation semantics

Each signature phase shares its package read budget across all signatures; an admitted 31-signature source performs at most 94 signature verifications across the three phases

This byte-array operation supports repeated append and preserves all admitted signatures; it does not add certificate trust, whole-workbook coverage, multi-signature Workbook load/save, selected replacement or mutation/re-signing

Replace one explicitly authorized signature

XlsReplaceSelectedSignatureOpcPackage(Bytes, NewCertificate, Authorization, Options, Signer, Output, Details) replaces one selected signature while preserving every unselected signature and the existing physical package topology

The existing TXLSSignatureOpcReplaceAuthorization binds ExpectedPackageSha256, explicit ExpectedSignaturePart and ExpectedCertificateSha256 to the actual verified original selection; no empty selector or implicit first-signature fallback is admitted

Canonical ASCII case aliases resolve to the actual stored physical name, which the completed output retains; a missing selector in an otherwise verified signed source returns xspsSignatureNotFound, while mismatched package/certificate authority returns xspsIdentityMismatch

All original signatures verify before replacement authority is used; every unselected signature verifies against the actual placeholder stage before the signer is invoked, and every final signature verifies before publication

The selected physical name, origin edges, relationship identifiers and content-type bytes remain unchanged; every part except the selected signature XML is byte-compared with the original, retaining unselected certificates, authenticated selections and ordinary content

Options: TXLSSignatureOpcIssueOptions explicitly selects the new raw, canonical XML or relationship-transform coverage; the replaced signature may authenticate a different requested selection, while all unselected signatures must remain valid

TXLSSignatureOpcSelectedReplaceSignDigest receives a TXLSSignatureOpcSelectedReplaceRequest with OriginalPackageSha256, OriginalSignaturePart, OriginalCertificateSha256, exact StagedPackageSha256, deep-copied verified OriginalSignatures and the isolated NewSignature request

NewSignature.InputPackageSha256 identifies the actual placeholder-stage bytes used to derive the requested digest, and the existing caller-owned RSA-SHA256 callback contract supplies the new signature without transferring private-key ownership

TXLSSignatureOpcSelectedReplaceResult reports Status, SignerCalled, exact InputPackageSha256, StagedPackageSha256 and OutputPackageSha256, the retained SignaturePart, original OriginalCertificateSha256, verified OriginalSignatures and FinalSignatures, and the newly verified selected Integrity

TXLSSignatureOpcSelectedReplaceStatus returns xspsReplaced only after final cryptographic verification and the unchanged-part audit; xspsUnsignedSource leaves unsigned input to its separate issuing path

When an unselected signature authenticates the selected signature XML, placeholder replacement causes xspsWouldInvalidate before the signer is called; an actual countersignature control distinguishes replacing the depended-on signature from successfully replacing its dependent signature

Other refusals include xspsInvalidSource, xspsInvalidSelection, xspsInvalidCertificate, xspsResourceLimit, xspsSignerCancelled, xspsSignerFailed and xspsVerificationFailed; failed operations retain the previous output and clear authenticated result identity/coverage while retaining status and whether the signer was invoked

A valid 32-signature package can be replaced without increasing its signature count; one 8388608-unit main verifier/editor budget spans at most seven bounded package opens, admitting at most 448 MiB of aggregate reads across phases and at most 95 signature verifications

Each phase shares its package read budget across signatures; the 64 MiB input/output, 16 MiB per-part and existing nested parser, Reference and crypto bounds remain effective

Shared array values and source/output aliases are supported, but the storage of the Output variable itself must not overlap Details; callback report arrays and nested selections have isolated storage

Replacement grants no certificate trust or whole-workbook coverage and does not widen ordinary Workbook multi-signature load/save or mutation/re-signing admission

Edit ordinary content and replace one signature

XlsEditAndReplaceSelectedSignatureOpcPackage(Bytes, NewCertificate, Authorization, Options, Edits, Signer, Output, Details) combines explicit existing-part edits with replacement of one caller-authorized original signature

The existing TXLSSignatureOpcEdits carries one to 256 physical part names and replacement byte arrays; every edited part must exist and be authenticated by the requested new signature coverage

The operation rejects signature XML, origin infrastructure, relationship parts, content-type edits, absent parts and duplicate ASCII case aliases; it preserves the existing physical names, part count, relationships and media types

All original signatures verify before the exact original package hash, explicit selected signature name and actual original certificate hash authorize any change

Every unselected signature must still verify against the actual edited placeholder package before Signer is called; changes that invalidate another signature return xspsWouldInvalidate without invoking the signer

The existing TXLSSignatureOpcSelectedReplaceRequest binds verified original signatures and exact original identity to the real edited StagedPackageSha256 and new signing digest; callback reports and nested selections have isolated storage

Final publication requires all signatures to verify, the selected certificate and requested coverage to match, and every part except the selected signature XML to equal either its exact authorized edit bytes or its unchanged original bytes

Edits accepts at most 16 MiB per part and 64 MiB aggregate copied payload, with at most 4096 characters per name; existing 64 MiB input/output and parser/reference/crypto limits remain in force

The shared 8388608-unit work budget charges new name comparisons by character length; fixed phases retain the selected-replacement ceilings of seven bounded package opens, 448 MiB admitted reads and 95 signature verifications

Combined work and output-package limits may refuse before an individual item maximum is reached; allocation-before-copy preflight rejects an oversized plan even when several caller entries share the same array value

Invalid edits or coverage return xspsInvalidSelection, excessive plans return xspsResourceLimit, and original authority, signing and verification retain the existing selected-replacement statuses; failure preserves the previous output and clears authenticated result identity and coverage

Input/output and edit-data/output aliases are supported through private copies; the storage of the Output variable itself must not overlap Details

The earlier XlsReplaceSelectedSignatureOpcPackage keeps its no-content-edit contract; this new operation does not coordinate re-signing several invalidated signatures, create or remove parts, repair relationship graphs, widen Workbook lifecycle admission or establish certificate trust

Authorized batch content-edit replacement

XlsEditAndReplaceSelectedSignaturesOpcPackage replaces 1 through 32 explicitly authorized existing signatures in one transaction, with optional edits to at most 256 existing ordinary parts; an empty edit list supports certificate and coverage renewal

Each TXLSSignatureOpcReplacementPlan supplies original package, physical signature-part and certificate identity, a replacement certificate, explicit options and the existing selected-replacement signing callback

All original signatures and selected authorities verify before staging; every unselected signature must verify against the common stage, and all replacement manifests and the union of edited-part coverage are validated before the first callback

Callbacks receive the same common stage hash with independent original reports, selected coverage, canonical SignedInfo and digest buffers; plans, certificates, edits and nested relationship selectors are copied before callbacks

All replacements verify before the exact part inventory, order, media bindings and authorized or unchanged payload bytes are audited and one output is published

Cancellation, provider failure and verification failure preserve the caller's previous output and clear authenticated result fields while reporting actual SignerCalls; input, certificate and edit-data array value aliases are supported, while Output variable storage must not overlap Details

Signature, origin, relationship and content-type infrastructure cannot be edited as ordinary parts, and replacement references cannot bind staged signature placeholders

The operation retains the 64 MiB package, 16 MiB part, 64 KiB certificate and 64 MiB aggregate edit-byte limits; each plan admits at most 256 references, the batch at most 4,096 relationship selectors and 1 MiB of bounded names and selector text

One shared 8 × 1,024 × 1,024 operation-work budget applies to the complete transaction; this is not a total-memory or per-byte hashing guarantee

Part additions and removals, graph repair, dependency-ordered signature chains, broader Workbook and VBA integration, timestamps, provider extensions and certificate trust remain separate requirements

Compatibility and remaining lifecycle work

The original no-selector XlsVerifySignatureOpcPackage and XlsVerifySignatureOpcPackageWithTrust retain their single-signature profile; a multiple-signature package does not cause either API to choose a signature implicitly

Explicit package-byte verification, preserve-all append and authorized selected replacement complement the original APIs; ordinary verified Workbook loading, unsigned issuing, replacement, mutation and re-signing retain their existing ownership profiles

Broader signature dependency chains, part additions/removals and relationship repair, and broader Workbook lifecycle integration, additional VBA profiles, timestamps, certificate/key-provider extensions and remaining trust/platform qualification remain open requirements