function WinCryptoAvailable: Boolean;
function WinCmsVerificationAvailable: Boolean;
function VerifyWinDetachedCms(const CmsDer: TBytes; Segment1: Pointer; Segment1Length: Cardinal; Segment2: Pointer; Segment2Length: Cardinal): TWinCmsVerifyResult;
function VerifyWinDetachedCmsEx(const CmsDer: TBytes; Segment1: Pointer; Segment1Length: Cardinal; Segment2: Pointer; Segment2Length: Cardinal; const Options: TWinCmsVerifyOptions): TWinCmsVerifyResult;
function VerifyWinAttachedCmsEx(const CmsDer: TBytes; const Options: TWinCmsVerifyOptions): TWinCmsVerifyResult;
function ResolveWinSigner(const Options: TPadesSignerOptions): TPadesResolvedSigner;
function TestBuildWinCmsTrust(SignerCert: Pointer;
const Options: TWinCmsVerifyOptions; GetChain, VerifyPolicy,
FreeChain: Pointer): TWinCmsVerifyResult; // PDFIUMPAS_CRYPTO_TESTS only
FPdfCryptoWin is the Windows-specific crypto backend consumed by FPdfCrypto. It opens the current-user and local-machine certificate stores via CryptoAPI, locates the certificate matching the requested thumbprint, acquires the associated NCRYPT private key handle, and returns a TPadesResolvedSigner whose ICmsSigner signs through CNG
WinCryptoAvailable performs the lightweight check that the Crypt32 / ncrypt bindings resolve, so callers can decide at start-up whether PAdES signing will be possible on this machine
VerifyWinDetachedCms validates a detached CMS value against two caller-owned byte segments, returns the signer certificate, and evaluates its chain with the cache-only Windows base policy without performing network retrieval
The extended verification functions accept TWinCmsVerifyOptions so callers can enable online certificate retrieval, request revocation checking, set a retrieval timeout and observe verification checkpoints
Signature validity and certificate trust are independent results so an authentic signature from an untrusted or self-signed certificate remains distinguishable from tampered content
| Function | Description |
|---|---|
WinCryptoAvailable | Returns True when the Windows Crypt32 and ncrypt bindings can be resolved at runtime |
WinCmsVerificationAvailable | Returns True when detached CMS verification and certificate chain-policy APIs are available |
VerifyWinDetachedCms | Verifies the CMS signed attributes and signature over two detached content segments and reports current cache-only system trust separately |
VerifyWinDetachedCmsEx | Verifies detached CMS content with explicit online retrieval, revocation, timeout and checkpoint options |
VerifyWinAttachedCmsEx | Verifies an attached CMS value and evaluates its signer certificate using the supplied options |
ResolveWinSigner | Resolves a thumbprint into a signer, certificate DER and chain using the Windows certificate store and CNG private key |
TestBuildWinCmsTrust | Test-conditional hook compiled only under PDFIUMPAS_CRYPTO_TESTS: swaps the CNG chain-policy function pointers for caller-supplied stubs, runs trust building with the signature status preset to valid, then restores the pointers, so crypto unit tests can exercise BuildWinCmsTrust without a real certificate chain |
| Type | Members and purpose |
|---|---|
TWinCmsVerifyStatus | wcvsUnavailable, wcvsValid, wcvsInvalid, wcvsUnsupported or wcvsIndeterminate |
TWinCmsVerifyStage | wcvstCryptographicSignature, wcvstChainBuild, wcvstOnlineRetrieval or wcvstRevocationCheck |
TWinCmsVerifyCheckpoint | Object-method callback receiving each TWinCmsVerifyStage |
TWinCmsVerifyOptions | OnlineRetrieval, CheckRevocation, CollectChainCertificates, UrlRetrievalTimeoutMs, OnCheckpoint and the static Default factory |
TWinCmsVerifyResult | Alias of TPdfCmsVerifyResult, containing SignatureStatus, TrustStatus, RevocationStatus, SignatureError, TrustError, SignerCertificate, ChainCertificates, RevocationReason and RevocationError |
With CheckRevocation enabled, the backend builds a separate revocation chain and fills RevocationStatus, RevocationReason and RevocationError. Revocation failures do not overwrite the signature result or the independently evaluated TrustStatus and TrustError
On a well-formed native chain, confirmed revocation yields wcvsInvalid with pcrrCertificateRevoked. Where revocation is not confirmed, an untrusted chain gives wcvsIndeterminate with pcrrChainUntrusted; incomplete native structures and other unresolved revocation checks remain at wcvsIndeterminate with pcrrUnknown
A valid result requires a trusted chain, no chain errors, at least one certificate that requires revocation checking, and a successful native revocation result for every such certificate. Only a terminal certificate explicitly marked as self-signed, or a trusted CA anchor, is exempt from that coverage requirement; a root-only chain or missing per-certificate evidence stays indeterminate
RevocationError keeps the raw DWORD from CERT_REVOCATION_INFO.dwRevocationResult, or the immediate GetLastError value should the revocation chain call fail. Zero means no native diagnostic is available, including where a chain status establishes revocation without a matching provider code. Aggregate CERT_TRUST_STATUS.dwErrorStatus bits are used for classification and are not copied into this field as an invented native error
Interpret the raw value within its Windows provider or API context; it is not guaranteed to be an HRESULT. Offline, stale or unknown revocation evidence does not identify CRL expiry, malformed CRLs or bad CRL signatures, so this backend does not infer those detailed reasons
With OnlineRetrieval = False, both chain building and revocation checking use cached retrieval only. Enabling online retrieval lets the Windows chain engine fetch the supporting evidence within the configured retrieval timeout
PadesCryptoAvailable = False unless another backend is registeredTWinCmsVerifyOptions.Default preserves cache-only verification; opt into online retrieval and revocation checking only when the application accepts network access and its latencyRevocationReason: TPdfCmsRevocationReason and RevocationError: Cardinal. When revocation is disabled or its pass is never reached, these fields hold pcrrNone and zero; the same values accompany a successful check, so use RevocationStatus for the verdictNativeRevocationError and NativeTimeStampRevocationError