PDFium Delphi Component Docs

FPdfTsa unit

Unit: FPdfTsa
RFC 3161 timestamp authority client for the PAdES B-T and B-LTA profiles, with request building, response parsing, and direct timestamp request helpers

Syntax

TPadesTimestamp = record
  TokenDer: TBytes;
  GenTime: TDateTime;
  PolicyOid: AnsiString;
  Nonce: Int64;
end;

function PadesTsaAvailable: Boolean;
function PadesTsaBackendName: string;
function BuildTimeStampReq(const HashInput: TBytes; DigestOid: AnsiString;
  Nonce: Int64; CertReq: Boolean): TBytes;
function BuildTimeStampReqFromDigest(const Digest: TSHA256Digest;
  DigestOid: AnsiString; Nonce: Int64; CertReq: Boolean): TBytes;
function ParseTimeStampResp(const RespDer: TBytes; ExpectedNonce: Int64;
  out Ts: TPadesTimestamp): Boolean; overload;
function ParseTimeStampResp(const RespDer: TBytes; ExpectedNonce: Int64;
  const ExpectedDigest: TSHA256Digest; out Ts: TPadesTimestamp): Boolean; overload;
function ValidateTimeStampToken(const TokenDer: TBytes;
  const ExpectedDigest: TSHA256Digest; out Ts: TPadesTimestamp): Boolean;
function ValidateTimeStampTokenImprint(const TokenDer: TBytes;
  const DigestOid: AnsiString; const ExpectedDigest: TBytes;
  out Ts: TPadesTimestamp): Boolean;
function TimeStampTokenImprintOid(const TokenDer: TBytes): AnsiString;
function RequestTimestamp(const TsaUrl: string;
  const SignatureValueOctets: TBytes; Nonce: Int64): TPadesTimestamp;
function RequestTimestampDigest(const TsaUrl: string;
  const Digest: TSHA256Digest; Nonce: Int64): TPadesTimestamp;
TPadesTimestampProc = function(const TsaUrl: string;
  const Digest: TSHA256Digest; Nonce: Int64): TPadesTimestamp;
var PadesTimestampOverride: TPadesTimestampProc;
var PadesTsaAvailableOverride: Integer;

Description

FPdfTsa implements the client side of RFC 3161 for PAdES long-term signatures. It encodes TimeStampReq messages, decodes TimeStampResp messages, and offers convenience wrappers that perform the full HTTP exchange against a timestamp authority (TSA) URL

The platform transport is selected automatically: Windows uses FPdfTsaWin through WinHTTP, native Free Pascal on Unix uses FPdfTsaFpc through libcurl, and Delphi POSIX uses FPdfTsaPosix through System.Net.HttpClient. PadesTsaAvailable reports whether the selected backend is available and PadesTsaBackendName names it

Two convenience functions, RequestTimestamp and RequestTimestampDigest, hash the signature value (or accept a precomputed digest), build the request, post it, and parse the response in one call, performing nonce and digest verification

Functions

FunctionDescription
PadesTsaAvailableReturns True when a timestamp transport backend is available on the current platform
PadesTsaBackendNameReturns the display name of the active timestamp backend
BuildTimeStampReqBuilds a TimeStampReq message from raw hash input, a digest algorithm OID, a caller-chosen nonce, and a certificate-request flag
BuildTimeStampReqFromDigestBuilds a TimeStampReq message from an already-computed SHA-256 digest, skipping the internal hashing step
ParseTimeStampResp (2 overloads)Parses a TimeStampResp and verifies the nonce; the second overload additionally verifies that the timestamped digest matches ExpectedDigest
ValidateTimeStampTokenValidates a standalone TimeStampToken against an expected SHA-256 digest and returns its parsed timestamp data
ValidateTimeStampTokenImprintValidates a standalone TimeStampToken whose messageImprint uses another hash, such as SHA-384, SHA-512 or SHA3; DigestOid must equal the token’s imprint algorithm and ExpectedDigest its value
TimeStampTokenImprintOidReturns the messageImprint hash algorithm OID of a TimeStampToken, or an empty string when the token cannot be parsed, so the covered bytes can be hashed the same way before validation
RequestTimestampHashes the signature value, posts the request to TsaUrl, and returns the verified TPadesTimestamp
RequestTimestampDigestSame as RequestTimestamp but accepts a precomputed digest instead of the raw signature value

Types

TypeDescription
EPadesTsaException raised for timestamp encoding, transport, or verification failures
TPadesTimestampRecord with TokenDer, GenTime, PolicyOid, and Nonce fields for the returned timestamp
TPadesTimestampProcCallback signature used to replace digest-based timestamp acquisition

Override Variables

VariableDescription
PadesTimestampOverrideOptional TPadesTimestampProc used instead of the platform HTTP backend
PadesTsaAvailableOverrideAvailability override where 0 uses the backend probe, 1 forces available, and -1 forces unavailable

Remarks

See Also

FPdfCms, FPdfCrypto, FPdfTsaWin, FPdfSha256