SetPAdESSignatureTimeStampToken

Security and Signatures

Description

Validates a DER-encoded RFC 3161 TimeStampToken and injects it as an id-aa-signatureTimeStampToken unsigned attribute on the selected CMS SignerInfo

The method verifies the token signature, requires the sole critical extended key usage to be timeStamping, checks an encoded TSA name when present, and compares the token message imprint with the configured digest of the signer signatureValue

Existing signature timestamp attributes on the selected signer are replaced, unrelated unsigned attributes are preserved, and the rebuilt attribute set is DER sorted

Syntax

Delphi

Function TPDFlib.SetPAdESSignatureTimeStampToken(STSProcessID: Integer;
  Const TimeStampTokenDER: AnsiString; SignerIndex: Integer= 0): Integer;

Parameters

STSProcessIDValue returned by one of the NewPAdESSignatureTimeStampProcessFrom* functions
TimeStampTokenDERComplete DER-encoded RFC 3161 TimeStampToken returned by the TSA
SignerIndexZero-based CMS signer index, defaulting to the first signer

Returns

0The process identifier is invalid
1The token was validated and injected
11The token, CMS, selected signer, TSA constraints, or message imprint is invalid
OtherThe source PDF or selected signature could not be prepared, as reported by GetPAdESSignatureTimeStampProcessResult

Workflow

  1. Reserve enough signature contents space with SetSignProcessReserveContentsBytes before creating the original signature
  2. Create a timestamp process and select the signature field and digest algorithm
  3. Call GetPAdESSignatureValueHashHex and send that message imprint to the TSA
  4. Pass the returned TimeStampToken to this method
  5. Finish with an EndPAdESSignatureTimeStampProcessTo* method

The library validates and rewrites CMS but does not perform the TSA HTTP request

See also

GetPAdESSignatureValueHashHex, SetPAdESSignatureTimeStampDigestAlgorithm, SetSignProcessReserveContentsBytes, TPDFlibSignatureVerifier