HotXLS documentation

OPC package signature integrity

Version 2.384.141 adds bounded, explicit integrity verification of supported OPC package signatures directly from an immutable ZIP snapshot, including the selected package-part digests

Single-signature integrity verification, verified package edits and verified Workbook loading and saving are part of every edition; multiple-signature operations, trust policy evaluation, issuing and re-signing are Enterprise edition features in the lxSignatureOpcIssuer unit (see signed OPC publication)

Verify supplied package bytes

Use XlsVerifySignatureOpcPackage from lxSignatureOpcIntegrity before loading or modifying the workbook; it reads only the supplied byte array and never fetches external targets, certificates, local files or network resources

uses SysUtils, lxSignatureOpcIntegrity;

procedure CheckPackage(const PackageBytes: TBytes);
var
  Details: TXLSSignatureOpcIntegrityResult;
  Status: TXLSSignatureOpcIntegrityStatus;
begin
  Status:= XlsVerifySignatureOpcPackage(PackageBytes, Details);
  if Status= xsoiIntegrityVerified then
    Writeln('Verified references: ', Details.CheckedReferences)
  else if Status= xsoiUnsigned then
    Writeln('No package signature')
  else
    Writeln('Verification status: ', Ord(Status));
end;

The result parameter uses var so a caller can pass Details.Certificate as the input without clearing those input bytes before verification; every failure or unsigned result clears the certificate, signature-part name, claimed time, Reference count and coverage

StatusMeaning
xsoiIntegrityVerifiedThe supported signature, its package Object and its selected Reference digests passed
xsoiUnsignedNo package signature was discovered, including a retained empty origin with no signatures
xsoiInvalidPackagePackage structure, content types, signature binding or required profile data is invalid
xsoiUnsupportedProfileA ZIP, XML, signature or transform feature falls outside the supported profile
xsoiResourceLimitA byte, entry, XML, algorithm or work limit was reached
xsoiInvalidSignatureThe signature value does not verify against SignedInfo with the supplied certificate public key
xsoiDigestMismatchA selected Reference does not match its authenticated digest
xsoiPartUnavailableA required selected package part is unavailable

Explicit multiple-signature discovery and verification

Multiple OPC signature verification provides bounded structural discovery, an explicit signature-part selector, individual all-signature reports and selected-signature trust through dedicated byte-array APIs

XlsDiscoverSignatureOpcPackage returns unverified inventory data; XlsVerifySelectedSignatureOpcPackage authenticates only the requested attached signature, while XlsVerifyAllSignaturesOpcPackage distinguishes individual failures from an aggregate all-verified result

XlsVerifySelectedSignatureOpcPackageWithTrust applies the existing caller-owned policy only to the selected verified certificate and its authenticated coverage

The original no-selector APIs and existing Workbook loading, issuing, replacement and mutation paths retain their single-signature ownership profiles; the new explicit operations never choose a first signature silently

Preserve-all append adds one explicit signature only after the original signatures remain valid against both staging and final output; existing single-signature replacement and mutation APIs retain their separate authorization contracts

Authorized selected replacement retains the selected physical name and all unselected signatures through actual staged and final verification, with explicit package/name/certificate authority and unchanged-part auditing

Interpret the result

TXLSSignatureOpcIntegrityResult returns SignaturePart, ClaimedSignatureTime, the embedded DER Certificate, CheckedReferences, authenticated Coverage and Trust; the count includes the authenticated package Object Reference and its selected Manifest References

TXLSSignatureTrust currently has only xsstUntrusted, and every result retains that value, including successful integrity checks

Integrity applies to the selected signed content and does not imply coverage of every ZIP entry or every relationship; application policy must separately decide whether the signed selection covers the content it intends to use

The certificate supplies the verification public key without chain trust, validity-date checks, revocation checks, signer authorization or identity assurance; replacing a certificate with another certificate containing the same key is outside this integrity-only identity contract

ClaimedSignatureTime is authenticated signed data supplied by the signer, without a trusted timestamp or an assertion that the clock was correct

Authenticated selected coverage

TXLSSignatureOpcIntegrityResult.Coverage — a TXLSSignatureOpcCoverageArray of TXLSSignatureOpcCoverage records — contains owned descriptors for the selected Manifest References only after the actual certificate's RSA signature and every required digest have verified; each descriptor records ReferenceUri, PartName, ContentType, Transforms, RelationshipSourceIds and RelationshipSourceTypes

A raw part reference covers its bytes, canonicalization covers the canonical XML representation, and a relationship transform covers only the authenticated identifier or type selection; a type selector records that selection criterion rather than inventing a list of explicit identifiers

CheckedReferences also counts the separately authenticated internal package Object Reference, which is not a package-part coverage descriptor; neither the count nor certificate trust proves that every workbook part or relationship was signed

Adding managed coverage changes the public result-record layout, so rebuild dependent binaries; immutable snapshot reports deep-copy both the outer descriptors and their nested arrays

Explicit caller-owned selected-signature trust (Enterprise edition)

XlsVerifySignatureOpcPackageWithTrust(Bytes, Policy, Details) first snapshots bounded caller inputs, runs the complete original OPC verifier and evaluates trust only for the certificate that actually passed that signature; it never accepts a different caller leaf as a substitute

Initialize TXLSSignatureOpcTrustPolicy with XlsDefaultSignatureOpcTrustPolicy, supply DER TrustAnchors and Intermediates as TXLSSignatureCertificates byte arrays, and set an explicit finite VerificationTimeUtc; the default leaves time unset, requires document-signing EKU 1.3.6.1.4.1.311.10.3.12 and selects xsrvRequireCached from TXLSSignatureRevocationPolicy, whose only alternative is xsrvNotChecked

xsotTrustedSelection authorizes only the actual signature's reported selection under that policy; the original verifier and embedded Integrity.Trust still report xsstUntrusted, so existing callers do not acquire implicit trust

TXLSSignatureOpcTrustResult reports IntegrityEvaluated, IntegrityStatus, the current Integrity report, exact PackageSha256, actual CertificateSha256 and accepted TrustAnchorSha256, plus the applied time, EKU, revocation choice and native policy diagnostics

Application authorization must still check that authenticated coverage includes the content it intends to use; unsigned cells or unselected relationships can change while this selected signature remains trusted, and the complete package fingerprint will then differ

StatusMeaning
xsotTrustedSelectionActual package integrity and the explicit policy for its selected signature passed
xsotRejectedCertificate, authorized chain, usage, validity or requested revocation policy rejected the current verified signature
xsotIntegrityNotVerifiedThe underlying integrity result did not verify, so trust was not granted
xsotInvalidPolicy, xsotTrustResourceLimitCaller inputs are invalid or a configured byte, certificate or metadata limit was reached
xsotTrustUnavailable, xsotNativeErrorThe required backend is unavailable or native API execution failed

Trust policy, resources and backend boundaries

The Windows backend uses per-call memory stores and an exclusive caller root store, including an empty root set; accepted primary-chain DER must match the actual verified leaf, caller intermediates and a caller terminal anchor, so ambient local issuers cannot become authorized merely by being present

The accepted native result has one simple chain and no CTL link or returned lower-quality contexts; the call does not request an enumeration of every possible alternate chain and does not claim uniqueness beyond the actual primary chain it inspects

Acceptance requires native API execution, zero base-policy error, zero aggregate chain errors and explicit leaf digital-signature key usage and required EKU; the policy-execution Boolean alone is insufficient

Retrieval uses cache-only URL access with AIA and automatic root updates disabled; xsrvRequireCached also requires cached revocation for the chain excluding its root, and missing status rejects, while explicit xsrvNotChecked provides no revocation assurance

These flags govern this verification request, not all OS activity or ambient local reads; the explicit UTC time controls certificate validity but does not recreate historical revocation or root-store state, and the claimed signature time is not substituted for policy time

Limits are 32 anchors and 32 intermediates, 65536 bytes per DER certificate, 2 MiB total policy certificate data, 64 MiB package input, an accepted chain of at most 64 certificates, and a canonical dotted ASCII EKU OID of at most 128 characters with at most ten digits per component; native EKU output is capped at 32 KiB and 128 OIDs

UTC dates run from 1601 through 9999 with millisecond Windows conversion; exact zero means unset, and non-finite times reject before native execution, including correct handling of negative-date time fractions at the lower boundary

Engine cache and cycle settings are not a hard bound on internal OS work or a wall-clock deadline; the original package/XML/reference/work limits remain in effect

Input package, anchors and intermediates remain caller-owned; bounded owned snapshots permit aliases into the previous result before that result is cleared, and failures never retain stale trusted status or coverage from an earlier package

The backend is currently Windows-only, with focused RAD Studio 37 Win64 qualification and a separate packed-ABI alignment control; other platforms or missing native support return xsotTrustUnavailable after successful integrity verification

No private key, signing operation, certificate-store installation or persistent trust policy is involved in trust evaluation; the explicit issuing API below has its own caller-owned signer contract, while wider profiles, broader revocation assurance and remaining platform acceptance stay separate work

Issue an explicit selected OPC signature (Enterprise edition)

XlsIssueSignatureOpcPackage(Bytes, Certificate, Options, Signer, Output, Details) in lxSignatureOpcIntegrity creates one actual RSA-SHA256 package signature from an unsigned OPC source; successful xsoqIssued publishes bytes only after complete topology, certificate-key and selected-reference verification

Supply public DER certificate bytes and TXLSSignatureOpcIssueOptions with nonempty References and a valid ClaimedSignatureTimeUtc in YYYY-MM-DDThh:mm:ssZ form; this time is signed claimed metadata, not a trusted timestamp or trust-policy time

Each TXLSSignatureOpcIssueReference contains a canonical absolute PartName, Mode, and optional SourceIds/SourceTypes; select xsimRaw, xsimCanonicalXml, or xsimRelationships, with explicit selectors required only for relationship mode

The library derives each typed Reference URI from the actual final content type; it stages content types, the new origin relationship, origin and signature infrastructure before hashing selected parts, including a selected root relationships part

The fixed profile creates /_xmlsignatures/origin.sigs, its relationships part and /_xmlsignatures/sig1.xml, embedding the actual public certificate with fixed safe XML identifiers; Object and SignedInfo canonicalization use the complete envelope namespace context

Sources with existing signatures, signature origins or recognized signature infrastructure reject without replacement; the content-type manifest and recursively selected new signature infrastructure are outside this selection profile

Borrowed signer and verified publication

TXLSSignatureOpcSignDigest is a synchronous method callback receiving TXLSSignatureOpcSignRequest and a var TBytes signature; its request contains independent CanonicalSignedInfo, the 32-byte SHA-256 Digest, certificate/input fingerprints and a deep-copied Selection

Return xsosSigned with the full big-endian RSASSA-PKCS1-v1_5 SHA-256 signature, xsosCancelled, or xsosFailed; RSA-PSS and raw modular exponentiation do not satisfy this callback contract

The callback target and private key remain caller-owned and alive throughout the operation; the library neither imports, exports, persists, frees nor chooses a private-key provider, and invokes the callback once after the valid plan is staged, with no retry

Request-array mutation cannot change the private staged plan; after the callback, actual complete verification must match the requested certificate, signature part, URI, part, content type, every transform and every relationship selector before output publication

TXLSSignatureOpcIssueResult returns Status, SignerCalled, IntegrityStatus, Integrity, InputPackageSha256 and OutputPackageSha256; even successful issuing retains Trust=xsstUntrusted, with selected trust available only through the separate explicit trust API

Failures preserve the previous output byte value and clear verified certificate/coverage and output identity; early refusal clears stale diagnostics, while an actually reached callback remains reported as called for that attempt

Input/output, certificate/output and callback-signature/old-output array-value aliases are supported; the two output variables require separate storage, so Output must not itself be a field inside Details, including Details.Integrity.Certificate

Caller callback writes through external references, private-key side effects, reentrancy outside request values and allocation-failure recovery are outside the byte-array transaction

Issue statusMeaning
xsoqIssuedComplete newly signed package verified and output published
xsoqInvalidSource, xsoqExistingSignatureThe source is invalid, outside the supported unsigned profile or already contains protected signature infrastructure
xsoqInvalidSelection, xsoqInvalidCertificateThe typed selection/time or supplied RSA certificate cannot be used
xsoqIssueResourceLimitAn input, text, inventory, construction or verification resource bound was reached
xsoqSignerCancelled, xsoqSignerFailedThe callback cancelled, failed or raised
xsoqVerificationFailedReturned signature or final package verification does not match the staged plan

Issuing resources and interoperability

Limits are 256 References, 4096 combined selectors, 1048576 cumulative reference/selector/time UTF-16 code units, 65536 certificate bytes, 4096-character Reference URIs, 16 MiB per part/signature and 64 MiB package bytes, plus existing package/verifier inventories

Construction shares an 8 MiB structural/relationship-transform work budget; byte hashing, the verifier's separate work, caller code and cryptographic-provider internals are not a hard wall-clock bound

Focused RAD Studio 37 Win64 qualification uses a caller-owned unnamed ephemeral RSA key without private-key export or system-store installation; other compiler/platform execution remains separate qualification work

The original issuing qualification retained a WindowsBase failure for a direct raw whole-root-relationships Reference; its cause was percent-encoding legal literal + in the content-type query value, and the corrected issuer now passes actual native verification for that complete raw-root selection

The issuer preserves supported literal ASCII query punctuation while retaining XML attribute escaping and necessary percent encoding; whole raw-part coverage and xsimRelationships subset coverage remain distinct, and qualification does not extend to every exotic or non-ASCII content-type parameter

Issuing, verified signature replacement and combined verified-original editing/re-signing retain their explicit byte-array APIs; Stream/File publication adapters and mutable Workbook signed Save methods provide direct destination operations, while multiple or broader profiles remain separate requirements

Replace an authorized verified signature (Enterprise edition)

XlsReplaceVerifiedSignatureOpcPackage(Bytes, NewCertificate, Authorization, Options, Signer, Output, Details) replaces one actually verified signature with a newly issued RSA-SHA256 signature; xsorqReplaced publishes only the final signed package after complete new verification and content audit

TXLSSignatureOpcReplaceAuthorization requires ExpectedPackageSha256, ExpectedSignaturePart and ExpectedCertificateSha256; both hashes contain exactly 64 hexadecimal characters, and the signature location must exactly match the actual old verified result

The operation verifies the old RSA signature and every Reference before comparing those identities or removing infrastructure; these expected values guard the intended source, without authenticating the caller or replacing application access control

Supply the actual new public certificate and complete explicit TXLSSignatureOpcIssueOptions; old coverage is not inherited, since a newly created origin relationship may have a different identifier and requires deliberate new selector choices

Neither old nor new mathematical integrity grants certificate trust; applications can apply the separate explicit trust policy when required, and successful replacement retains xsstUntrusted

Replacement signer identity and transaction

The borrowed synchronous TXLSSignatureOpcReplaceSignDigest receives TXLSSignatureOpcReplaceRequest with actual OriginalPackageSha256, OriginalSignaturePart, OriginalCertificateSha256, independently copied OriginalCoverage and a nested NewSignature request

NewSignature.InputPackageSha256 identifies the actual private unsigned package passed to the issuer; it is distinct from the outer original signed-package identity, and the nested request retains the issuing callback's canonical bytes, digest, selection and signature-return contract

The private key and callback target remain caller-owned; the callback runs exactly once for a valid staged plan, without retries, while source, identity, dependency and new-plan refusal occur before it is called

The library discovers the actual owned origin/signature graph, checks incoming dependencies, privately removes only supported owned infrastructure and verifies that intermediate as unsigned; no synthetic content edit or unsigned output is used to represent successful re-signing

Every ordinary non-infrastructure content part must retain its raw bytes, media type and inventory membership in both the unsigned intermediate and final signed output; root relationships and the content-type manifest are rebuilt for signature bindings and have separate schema/topology validation rather than raw-byte preservation

Current owned-infrastructure handling refuses unsupported incoming references and a signature-owned relationships part; collisions with new fixed infrastructure or unsafe source graphs cannot silently delete unrelated content

TXLSSignatureOpcReplaceResult reports Status, SignerCalled, OriginalIntegrity, OutputIntegrity, original package/signature/certificate identities, UnsignedPackageSha256, OutputPackageSha256 and the actual new Integrity report

Failure preserves prior output bytes and clears verified new certificate/coverage and output identity; current-operation diagnostics may describe a verified private candidate rejected by a later audit, so check the replacement status and published result rather than a diagnostic alone

Input/output, certificate/output and nested-array value aliases use owned snapshots; Output and Details still require separate variable storage, and arbitrary external callback writes, key side effects, reentrancy, allocation recovery and external concurrency remain outside rollback promises

Replacement statusMeaning
xsorqReplacedNew fully verified signature and audited final package published
xsorqInvalidSource, xsorqIdentityMismatchOld complete verification failed or mandatory expected identities do not match
xsorqUnsupportedReplacementThe infrastructure, topology, dependencies or content audit cannot support safe replacement
xsorqInvalidSelection, xsorqInvalidCertificateThe requested new signature plan or public certificate cannot be used
xsorqReplaceResourceLimitA wrapper, reader, verifier or issuer resource bound was reached
xsorqSignerCancelled, xsorqSignerFailed, xsorqVerificationFailedThe signer cancelled/failed or the new signed result did not verify as required

Replacement limits and qualification

Replacement reuses issuing byte/certificate/reference/selector/text limits, with 64-character expected hashes and a signature location of at most 4096 characters; one shared 8 MiB structural-work allowance covers its own discovery, topology, dependency, rewrite and audit operations

Fresh readers retain their normal finite cumulative read budgets, while the old verifier and new issuer keep separate bounded work; hashing, callbacks, providers and elapsed execution time are not a hard deadline

Focused RAD Studio 37 Win64 controls verify actual replacement using a different unnamed ephemeral RSA key and public certificate, without access to the old private key; independent verification checks both actual public keys, complete selected digests, actual certificates and unchanged ordinary payloads

WindowsBase accepts original and replaced packages for the qualified mixed raw/XML/relationship-ID profile with exact part/selector inventories; corrected content-type query spelling also passes the separately qualified complete raw-root selection

This API accepts a verified source for signature replacement; the combined editing API below applies an explicit mutation plan before new issuing, and direct Stream/File publication and Workbook signed Save reuse those verified pipelines; multiple or additional profiles, timestamps and remaining compiler/platform qualification stay open

Edit an authorized verified original and re-sign (Enterprise edition)

XlsMutateAndReplaceVerifiedSignatureOpcPackage(Bytes, NewCertificate, Authorization, Mutations, Options, Signer, Output, Details) verifies the untouched signed original, checks its mandatory expected package/certificate/signature identities, applies the complete typed mutation plan privately, and publishes only a newly signed and fully verified final package

Use the existing TXLSSignatureOpcReplaceAuthorization, TXLSSignatureOpcMutations and complete explicit TXLSSignatureOpcIssueOptions; successful xsomrReplaced does not inherit old coverage or certificate trust

Each ordinary part can appear once in the plan: create requires absence, replace/remove require presence, and removal supplies no bytes; root relationships and content types permit explicit replacement only, while actual old signature infrastructure and fixed new infrastructure paths remain protected

Explicit root/content-type replacements must retain the protected old bindings until safe library removal; their working bytes must exactly equal the caller payload, and every indirect effective media-type change is recorded even when the affected part's raw bytes are unchanged

The original signature proves selected coverage rather than complete ordinary relationship closure; an explicit plan may repair or remove an unrelated dangling ordinary dependency, while leaving the same defect unresolved refuses signing

Mutation receipts and signing identities

TXLSSignatureOpcMutateReplaceRequest contains the verified-original Replacement identity and old coverage, the explicitly edited EditedPackageSha256, ordered Mutations receipts (TXLSSignatureOpcMutationReceipts of TXLSSignatureOpcMutationReceipt) and indirect MediaTypeChanges (TXLSSignatureOpcMediaTypeChanges of TXLSSignatureOpcMediaTypeChange)

The nested Replacement.NewSignature.InputPackageSha256 identifies the actual unsigned edited bytes passed to the issuer; the untouched verified original, edited working container and unsigned signing input have distinct identities, and the edited container is never claimed to retain the old valid signature

Each mutation receipt reports kind — a TXLSSignatureOpcMutationKind of xsomReplace, xsomCreate or xsomRemove — part identity, before/after presence, length, SHA-256 and effective media type; presence distinguishes an absent part from an existing empty part, and the separate media-effect inventory includes indirect manifest mapping changes

The borrowed TXLSSignatureOpcMutateReplaceSignDigest callback retains the issuer's digest/signature contract and runs once after source, authority, mutation, closure and selection checks; nested request arrays and canonical bytes have independent storage

Audits check exact caller changes, unchanged unlisted raw content, exact inventory deltas and effective media types before stripping old infrastructure, after unsigned staging and after actual new issuing; root relationships and content types have explicit raw-byte exceptions during infrastructure reconstruction, without waiving their earlier exact mutation-payload checks

Atomic publication and bounded mutation work

TXLSSignatureOpcMutateReplaceResult reports status, signer use, old/new integrity, all stage identities, ordered mutation receipts, media changes and final verified coverage; check successful publication status before treating diagnostic state as output

Refusal, callback exception/cancellation, wrong signatures and final audit failure preserve prior Output; failure clears verified new coverage/certificate/output identity and early refusal clears stale signer and diagnostic state

Input/output, certificate/output, mutation-payload/output and returned-signature array value aliases use owned snapshots; Output variable storage must be separate from fields of Details, and external callback writes, private-key effects, arbitrary allocation recovery and caller concurrency remain outside rollback guarantees

Limits include 64 MiB packages, 65536 certificate bytes, 256 mutations, 16 MiB per mutation payload, 64 MiB cumulative mutation bytes, 256 new references, 4096 selectors, 4096-character reference/part bounds and one MiB of combined caller UTF-16 text units

Derived media effects have a 4352-entry cap; one shared eight MiB structural-work allowance covers wrapper phases, while the original verifier and actual issuer retain their separate existing budgets; no hard execution deadline is claimed

Mutation and re-signing qualification

Focused RAD Studio 37 Win64 qualification passes 223 controls with an unnamed ephemeral caller-owned RSA key, no private-key export and no system-store changes; the old signed public fixture does not require access to its old private key

Four packages pass independent WindowsBase signature/certificate/selected-inventory checks and independent RSA, canonicalization, actual media bindings and all four references: original, edited/re-signed, repaired/re-signed and complete raw-root selection

Independent reconstruction of the edited and unsigned packages matches both reported stage hashes; controls retain exact explicit payloads, unchanged unlisted bytes, indirect media mappings, different old/new public keys, dependency repair, callback isolation, aliases and failed-publication ownership

Historical native failure and controlled content-type spelling correction remain preserved; Stream/File publication and mutable Workbook signed Save/re-signing are explicit supported operations, while authorized batch ordinary-part mutation and re-signing supports explicit existing-signature transactions; broader dependency/topology work, additional VBA and signature profiles, timestamps and wider certificate infrastructure remain optional follow-up enhancements, with backend trust/platform qualifications documented separately

Released signature lifecycle

The bounded lifecycle includes verified original-package preservation, authorized package edits and invalidation, genuine legacy signed-VBA preservation and content verification, explicit RSA-SHA256 signing and replacement, and transactional signed Workbook Stream/File publication

Integrity, caller-owned certificate trust, source preservation and output publication remain separate decisions; generic Workbook serialization retains its documented package-signature removal behavior

These released paths do not imply universal timestamp, provider, algorithm, VBA-profile or platform coverage; the qualified contracts and interoperability limits remain explicit in the sections below

Supported signature profile

The original no-selector profile discovers a single signature through package origin relationships; each signature selected through the explicit multiple-signature APIs uses the same supported cryptographic profile, requiring one authenticated idPackageObject with its Manifest and SignatureProperties and typed same-package part References with SHA-256, RSA-SHA256 and canonical XML without comments

Supported relationship References apply the OPC RelationshipTransform followed by canonicalization; the bounded relationship transform supports its represented MCE view, while signature XML and discovery relationship XML use the plain supported profile

SignatureTime supports full date and time values in YYYY-MM-DDThh:mm:ssTZD or YYYY-MM-DDThh:mm:ss.sTZD format, using Z or a bounded numeric timezone

The original no-selector profile refuses multiple signatures; the explicit verification and preserve-all append APIs have their own bounded multi-signature admission

Additional application-defined Objects, additional SignedInfo References, other algorithms, other timestamp formats, general XMLDSig extension processing and external Reference resolution retain their explicit unsupported-profile boundaries

Inspect bounded package parts

XlsOpenSignatureOpcPackage from lxSignatureOpcPackage creates a caller-owned TXLSSignatureOpcPackage from a copied immutable input; free the returned object when finished

ReadPart accepts a logical absolute part name and caller byte limit, validates actual output size and CRC, and requires complete DEFLATE termination with exact compressed-byte consumption; Resolve additionally binds a typed Reference URI to the actual package content type

MediaType resolves the package content type, while PartCount and zero-based PartNameAt enumerate logical parts excluding [Content_Types].xml

TXLSSignatureOpcPackageStatus distinguishes xsopOpened, xsopInvalidPackage, xsopUnsupportedProfile, xsopResourceLimit and xsopPartUnavailable; failed reads return no partial bytes

XlsSignatureOpcLogicalName maps ASCII ZIP item names to logical OPC names with strict UTF-8 decoding of non-ASCII percent escapes, preserves escaped ASCII characters, and clears a failed output even when input and output strings alias

Physical profile and resource limits

The ZIP reader accepts conventional contiguous single-disk ZIP32 archives using stored or DEFLATE entries, with strict local/central header agreement and ordinary data descriptors; ZIP64, encryption, interleaved pieces, folder entries, non-regular entries and other compression methods are outside this profile

ASCII case-insensitive part identity rejects duplicate aliases and derived part-name prefix conflicts, and non-ASCII logical characters use OPC percent-encoded UTF-8 physical names; the content-type item must be named exactly [Content_Types].xml

Limits include 64 MiB of compressed input, 4096 entries, a 4 MiB central directory, 16 MiB per declared part, 64 MiB of declared aggregate output, 64 MiB of cumulative actual part reads and separate bounded lookup/profile work, in addition to the XML, Reference, Base64 and RSA limits

Repeated reads consume the same cumulative budget; a caller limit does not increase the built-in limit, and verification does not modify shared ZIP configuration

Retain and copy verified original bytes

Version 2.384.143 adds XlsCaptureVerifiedOpcSnapshot from lxSignatureOpcSnapshot, returning an IXLSSignatureOpcSnapshot only when an owned copy of the supplied bytes passes xsoiIntegrityVerified

uses SysUtils, lxSignatureOpcIntegrity, lxSignatureOpcSnapshot;

procedure RetainOriginal(const PackageBytes: TBytes; const Target: WideString);
var
  Snapshot: IXLSSignatureOpcSnapshot;
begin
  if XlsCaptureVerifiedOpcSnapshot(PackageBytes, Snapshot)= xsoiIntegrityVerified then
    Snapshot.CopyOriginalPackageToFile(Target, 67108864);
end;

Capture accepts at most 64 MiB before copying; unsigned, invalid, unsupported and resource-limited inputs publish no snapshot

PackageSize is the original byte length, and PackageSha256 fingerprints the complete captured package; this fingerprint does not extend the selected signature coverage

IntegrityDetails returns the existing integrity result with independently copied certificate and coverage arrays, including nested transform and relationship-selector arrays, and explicit xsstUntrusted status; later caller mutations cannot change the retained bytes or report

CopyOriginalPackageToStream writes at the caller's current stream position and leaves stream ownership with the caller; it is nontransactional, so output errors or cancellation may leave a copied prefix

CopyOriginalPackageToFile stages the complete original package in a registered sibling file and commits it using the existing file transaction; failures or cancellation before commit preserve the existing target and release the staged file

Both copy methods accept MaximumOutputBytes and a TXLSStreamCancelCheck callback, reject negative or insufficient limits before output, and check cancellation between bounded 64 KiB chunks; file output also checks before commit

EXLSSignatureSnapshotOutput reports invalid output arguments or limits, EXLSSignatureSnapshotCancelled reports cancellation, and destination write or commit errors propagate; successful commit completes the file copy even if cancellation is requested later

The destination must remain exclusively owned by the caller during the operation; the snapshot never lends its private input buffer to a destination stream

This API explicitly copies captured original bytes and has no mutable workbook association; it does not inspect a workbook dirty flag, apply workbook edits or fall back to workbook serialization

Workbook loading and saving

The standalone verifier checks supplied package bytes independently of workbook loading; the explicit workbook entry points below associate an owned verified source with the mutable workbook

Existing conversion reports still describe loaded package signature origins as dropped DigitalSignatures on output, and strict checked saves reject that loss before changing the destination

Verify a legacy VBA project and signature

XlsVerifyVbaLegacyProject from lxSignatureVbaLegacy accepts the supplied project and signature byte arrays and a var TXLSSignatureVbaLegacyResult; it verifies supported Windows CMS mathematics separately from the normalized legacy VBA content binding

The raw-pair API does not discover or authenticate the enclosing package relationship; callers must supply the intended project and its associated signature

xsvlVerified means the supported mathematical signature and authenticated content digest both match; xsvlDigestMismatch, xsvlInvalidProject, xsvlInvalidSignature, xsvlUnsupportedProfile, xsvlResourceLimit and xsvlCryptoUnavailable retain their distinct outcomes

The result exposes CmsVerified, ComputedDigest, AuthenticatedDigest, ModuleCount, NormalizedBytes and Diagnostic; Trust always remains xsvtUntrusted, including successful verification

The bounded legacy profile supports ASCII module identities, declared CP1252 source text, registered references, multiple ordinary modules in their stored order and legacy MD5 content binding; Designer Storage and additional Agile/V3 normalized projections remain unsupported. Internally the bounded compound-storage parser raises EXLSVbaMalformed for structurally invalid containers, EXLSVbaUnsupported for unsupported storage profiles, and EXLSVbaLimit when the stream, aggregate, or directory-entry budgets are exceeded; both public APIs convert these into the xsvl and xsvp status outcomes above

Limits include 8 MiB of project input, 4 MiB of signature input, 256 modules, 4096 compound-storage entries, depth 64 and 16 MiB of normalized content, with separate stream, source, certificate and RSA limits

Native CMS verification is currently Windows-only; other platforms return xsvlCryptoUnavailable without claiming CMS verification or certificate trust

XlsFingerprintLegacyVbaContent returns an owned SHA-256 change-detection fingerprint of the supported normalized content through a var TBytes parameter; xsvpReady, xsvpInvalid, xsvpUnsupported and xsvpLimit distinguish its outcomes without making a signature or trust claim

Both APIs preserve supplied bytes until bounded owned copies are complete, so verification inputs may alias result digest arrays and fingerprint input/output may use the same array variable

Signed VBA editing and output policy

With PreserveUnsupportedParts=True, unchanged raw VBA bytes and parsed projects without pending changes retain the original project and signature parts rather than rewriting the compound-file container

For supported edits, conversion reporting stages an owned preview without applying changes to the live parsed project; an explicit earlier ParsedVBAProject.ApplyChanges remains visible to the save decision

Equivalent stream contents or an unchanged supported legacy normalized projection can preserve the legacy signature despite different allocation layout or changes excluded by the legacy binding

A supported normalized-content change or explicit project removal produces an output-local plan that removes associated signature parts, their relationships and content-type declarations while retaining unrelated relationships and payloads

GetConversionReport reports VBADigitalSignatures as preserved, dropped or unsupported; preservation alone does not assert that a signature was verified

SaveAsChecked with AAllowLossy=False refuses planned signature removal before changing destination file bytes or stream bytes and position; ordinary saving and checked saving with loss enabled apply supported removal plans

Unknown edited normalization profiles, unsafe relationship inventories and unsupported signed-source relocation reject even when loss is allowed, while unavailable verification alone does not create a conversion loss

Declared legacy, Agile, compatibility and V3 signature relationships can be inventoried for safe removal after a supported content change; an edited project with an equal legacy projection and additional Agile/V3 signatures remains unsupported because their extra binding has not been proved equal

PreserveUnsupportedParts=False continues to report declared VBA signatures as dropped, and the existing ODS, XLSB and template conversion policies retain their separate contracts

Pending-source and stream previews have explicit cumulative bounds before cloning or encoding; the retained opaque package graph is not filtered or mutated to construct an output

Automatic workbook signature-policy integration, VBA issuing, Designer Storage and Agile/V3 verification remain pending; explicit package/Workbook signing and re-signing use the publication and signed Save APIs, while selected-signature trust has its separate explicit policy on this page; focused Win64 and C++Builder qualification uses the existing RAD Studio 37.0 installation, and Linux qualifies normalization and raw-project edit policy with explicit CMS unavailability

Verified mutable package edits

XlsEditVerifiedOpcPackage in lxSignatureOpcIntegrity replaces existing ordinary parts in a supported single-signature OPC package and rebuilds the actual ZIP before verifying the signature and selected References again

TXLSSignatureOpcEdit contains a canonical absolute PartName and owned Data bytes; TXLSSignatureOpcEdits supplies a batch of at most 256 distinct replacements, bounded to 16 MiB per part and 64 MiB total payload and package output

TXLSSignatureOpcEditPolicy selects xsoePreserve or xsoeInvalidateChanged: an edit outside the signed selection can retain the exact original signature XML, including an unselected RelationshipTransform member; a byte-equal replacement also preserves the signature

TXLSSignatureOpcEditStatus distinguishes xsoePreserved, xsoeInvalidated, xsoeWouldInvalidate, xsoeInvalidSource, xsoeInvalidEdit, xsoeUnsupportedEdit and xsoeEditResourceLimit

When selected signed content changes, preserve policy refuses output; explicit invalidation removes only safely owned signature infrastructure, its relationship binding and content-type declarations, then requires the final package to verify as unsigned

TXLSSignatureOpcEditResult reports OriginalIntegrity, EditedIntegrity, OutputIntegrity, SignaturePart, ChangedParts and Trust; invalidation retains the intermediate digest mismatch and the final unsigned verdict, while every outcome remains xsstUntrusted

The caller's output bytes remain unchanged on every failure, including source/output and edit-payload/output aliasing; successful output publishes only after the requested lifecycle has passed

RAD Studio 37 on 64-bit targets routes WriteBuffer through its native-count overload; the bounded editor covers both write overloads so requests beyond 64 MiB fail before allocating or modifying the output buffer

Content types, root signature binding and signature infrastructure cannot be replaced directly; unsafe incoming references and unrelated origin relationships block removal rather than deleting unrelated content

This existing-part API does not automatically change workbook SaveAs, create or remove ordinary parts, validate workbook semantics, issue signatures or establish certificate trust

Explicit verified workbook loading and saving

TXLSXWorkbook.OpenVerifiedOpcPackage(Bytes, Details) owns and verifies the supplied source before loading a supported Open XML spreadsheet or template; the overload with IntegrityStatus reports the source cryptographic verdict separately from the integer model-load result

SaveVerifiedOpcPackage(Stream, Policy, Details) and SaveVerifiedOpcPackage(FileName, Policy, Details) serialize actual workbook edits and return the existing TXLSSignatureOpcEditStatus; use xsoePreserve to refuse selected-content changes or xsoeInvalidateChanged to permit explicit signature removal

The workbook retains a private serializer baseline without recalculation or user callbacks, then performs its visible load with callbacks enabled once; edits performed by read callbacks remain edits relative to the verified original

Saving compares actual writer parts with that baseline, retains unchanged original part bytes and verifies the resulting signature again; the output must also reproduce the current writer's complete represented content semantics, including viewer state, volatile metadata and formula caches, so a worksheet cannot silently acquire a missing shared-string or style dependency

Qualified controls include unchanged saving, unselected document-title edits, unselected numeric/shared-string/number-format edits and selected worksheet refusal or explicit invalidation; preserved selected workbook and signature XML remain byte exact

Explicit invalidation checks safe ownership of signature infrastructure and assembles the complete actual writer output with its dependencies; unexpected loss of an original nonsignature part or a reported nonsignature conversion loss prevents publication

Successful stream output starts at the current position, retains any preceding prefix and truncates the old tail at the end of the new package; the stream must support reading, writing, seeking and size changes for a rollback backup of at most 64 MiB

Signature refusal leaves destination bytes, size and position unchanged; a destination supporting restoration after write or resize failure is restored before the exception propagates, and the owned signature binding changes only after successful output commit so a retry remains possible

File output stages a sibling temporary file and commits through the existing file transaction; successful explicit invalidation ends the verified binding and records the unsigned output

Integrity and document-domain rejection occur before replacing the existing model or binding; the explicit verified-load transaction below now restores the old owned state on represented parser, private-baseline, read-callback and cancellation failures

Ordinary Open, SaveAs, SaveAsChecked and their conversion reports retain their existing policy; explicit Workbook signed Save/re-signing is available separately, while broader identity/dependency combinations, additional failure profiles and automatic Save/trust policy remain required extensions

All outcomes retain Trust=xsstUntrusted; mathematical integrity covers the selected signed content and does not establish signer identity, certificate trust or coverage of every package part

Verified workbook load rollback

The explicit OpenVerifiedOpcPackage operation retains the old owned workbook graph and verified source binding until its replacement succeeds; represented parser errors, private baseline-serialization errors, read-callback exceptions and cancellation restore that graph instead of reopening a serialized backup

On those failures, existing worksheet, cell, font and typed PivotTable-cache references remain connected to the old model, old loaded-cell cursors remain usable and the stable workbook view generation is retained; the former signature binding can still support a preserved-save retry

New model roots and visible callbacks use the caller's actual workbook; the private first parse and baseline serialization suppress visible callbacks, and the visible parse invokes read callbacks once per visited cell, so successful callback edits remain edits relative to the verified original

SelectedSheets, QueryProviders and ExternalWorkspace retain their public object identities on both failure and success; failed loads restore selected names and settings, provider configuration, user-function registrations and workspace registration-time aliases and completed loader-cache state

Successful verified loading replaces owned model collections and invalidates old loaded-cell cursors; reacquire worksheets, cells, styles and cursors after success, while retaining the stable configuration facades

The configuration helpers TXLSQueryProviderDispatcher.CloneConfiguration, TXLSWorkbookWorkspace.CloneConfiguration and TXLSUserFunctionRegistry.CloneConfiguration create independent configuration containers with borrowed provider or callback targets; dispatcher and workspace SwapConfiguration exchange owned state while retaining facade identities

Workspace cloning copies registered exact and base-name keys rather than rebuilding aliases from a workbook's current identity; completed negative loader attempts remain completed across repeated clones and can be reset, and workspace exchange refuses active loaders or waiting callers before moving state

The focused Win64 controls include a genuinely signature-valid package with an unsigned malformed UTF-16 worksheet, an actual private-baseline compression failure, callbacks that mutate configuration before raising or cancelling, and restoration of a nonempty native PivotTable model; a subsequent successful load is checked after each failure

The transaction covers workbook-owned state and managed configuration containers; provider objects, callback targets and objects attached to SelectedSheets.Objects remain caller-owned, and arbitrary external callback effects or writes through separately retained old-model references cannot be undone

Selected-sheet restoration uses an independent RTL string-list snapshot with change notifications suppressed; a second allocation failure during rollback and caller-triggered destruction through OwnsObjects are outside the qualified restoration contract

Serialize separately accessible configuration operations with verified loading; concurrent external loaders, refreshes or configuration writes are outside this workbook transaction, and ordinary Open retains its existing behavior

This verified-load increment does not itself establish certificate trust, issue signatures, complete remaining VBA profiles or qualify every compiler and platform; the existing explicit signature selection, save policy and source/destination transaction boundaries remain in effect

Create and remove verified package parts

XlsMutateVerifiedOpcPackage accepts TXLSSignatureOpcMutations containing TXLSSignatureOpcMutation records with Kind, canonical absolute PartName and owned Data; kinds are xsomReplace, xsomCreate and xsomRemove, with empty data required for removal

A mutation batch contains at most 256 distinct identities within the existing 16 MiB per-part and 64 MiB payload/package limits; creation requires an absent identity, and replacement/removal require an existing identity

Submit the required content-type and relationship changes in the same batch as a part addition or removal; the mutation API permits replacement of content types and root relationships while keeping signature infrastructure directly protected

Publication requires every ordinary part to have a type binding, every internal relationship to resolve, every relationship part to have an existing owner, unique valid NCName relationship IDs and no stale type override

Valid non-ASCII relationship IDs are accepted by the XML name validator; external relationships remain external and are not fetched

The final signature and selected References are verified again: unchanged signed content can retain the original signature, selected changes refuse under xsoePreserve, and explicit invalidation removes only safely owned signature infrastructure before requiring a final unsigned package

Removing a selected part can make its original typed Reference unavailable even though the edited package topology is complete; that removal reaches explicit invalidation only from a verified source with an unchanged protected signature chain and a checked candidate graph

XlsEditVerifiedOpcPackage retains its existing replacement-only record and direct content-type/root-relationship restrictions; the mutation record is a separate type so older callers do not acquire an uninitialized operation field

The explicit workbook save planner derives create/remove/replace operations from actual serializer changes, merges original signature binding with current content types and root relationships, and verifies complete represented model semantics before output

Qualified workbook controls include Table creation/removal, worksheet creation/removal and first-sheet reordering, and creation of shared strings with their incoming workbook relationship; unchanged selected workbook or property bytes and original signature XML remain exact in the preservation controls

A package can have a valid signature over its selected content while retaining an unrelated dangling relationship; the mutation path rejects such incomplete output topology instead of treating cryptographic integrity as proof of a complete package

Ordinary save-policy/report integration, more complex identity and object combinations, additional load-failure profiles, additional VBA profiles, automatic Save/trust policy and remaining supported-platform qualification stay separate work; use explicit signed Save/re-signing to publish the current mutable Workbook with a caller-owned signer