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 ValidateTimeStampToken(const TokenDer: TBytes;
const ExpectedDigest: TSHA256Digest; out Ts: TPadesTimestamp): Boolean;
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;
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 chooses its transport automatically: Windows uses FPdfTsaWin with WinHTTP, native Free Pascal on Unix uses FPdfTsaFpc with libcurl, and Delphi POSIX uses FPdfTsaPosix with System.Net.HttpClient. Check PadesTsaAvailable for availability and PadesTsaBackendName for the selected backend's name
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
| Function | Description |
|---|---|
PadesTsaAvailable | Returns True when a timestamp transport backend is available on the current platform |
PadesTsaBackendName | Returns the display name of the active timestamp backend |
BuildTimeStampReq | Builds a TimeStampReq message from raw hash input, a digest algorithm OID, a caller-chosen nonce, and a certificate-request flag |
BuildTimeStampReqFromDigest | Builds 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 |
ValidateTimeStampToken | Validates a standalone TimeStampToken against an expected SHA-256 digest and returns its parsed timestamp data |
ValidateTimeStampTokenImprint | Validates 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 |
TimeStampTokenImprintOid | Returns 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 |
RequestTimestamp | Hashes the signature value, posts the request to TsaUrl, and returns the verified TPadesTimestamp |
RequestTimestampDigest | Same as RequestTimestamp but accepts a precomputed digest rather than the raw signature value |
| Type | Description |
|---|---|
EPadesTsa | Exception raised for timestamp encoding, transport, or verification failures |
TPadesTimestamp | Record with TokenDer, GenTime, PolicyOid, and Nonce fields for the returned timestamp |
TPadesTimestampProc | Callback signature used to replace digest-based timestamp acquisition |
| Variable | Description |
|---|---|
PadesTimestampOverride | Optional TPadesTimestampProc used instead of the platform HTTP backend |
PadesTsaAvailableOverride | Availability override where 0 uses the backend probe, 1 forces available, and -1 forces unavailable |
PadesTimestampOverride and PadesTsaAvailableOverride vars let a host application substitute its own timestamp transport for testing or for a custom HTTP stackNonce and verify it via ParseTimeStampResp to detect response substitution