tsaParseResponse
Low-level, network-free RFC-3161 timestamp-request building
BOOL32 __stdcall tsaBuildRequest(uint8_t* HashPtr, uint32_t HashLen, BOOL32 CertReq, uint8_t* NoncePtr, uint32_t NonceLen, uint8_t* OutBuf, uint32_t OutCap, uint32_t* OutLen);
BOOL32 __stdcall tsaParseResponse(uint8_t* RespPtr, uint32_t RespLen, int32_t* Status, const char* GenTimeBuf, uint32_t GenCap, uint8_t* ImprintBuf, uint32_t ImprintCap, uint32_t* ImprintLen, const char* SerialBuf, uint32_t SerialCap);
function tsaBuildRequest(HashPtr: PByte; HashLen: Cardinal; CertReq: LongBool; NoncePtr: PByte; NonceLen: Cardinal; OutBuf: PByte; OutCap: Cardinal; var OutLen: Cardinal): LongBool; stdcall;
function tsaParseResponse(RespPtr: PByte; RespLen: Cardinal; var Status: Integer; GenTimeBuf: PAnsiChar; GenCap: Cardinal; ImprintBuf: PByte; ImprintCap: Cardinal; var ImprintLen: Cardinal; SerialBuf: PAnsiChar; SerialCap: Cardinal): LongBool; stdcall;
Purpose. Low-level, network-free RFC-3161 timestamp-request building and response parsing — the building blocks underlying the higher-level pdfAddDocTimeStamp/tsaRequestTimeStamp (V10 Digital Signatures), exposed separately for callers who want to handle the actual HTTP transport themselves (e.g. through a proxy, or with custom TLS/auth).
Description. tsaBuildRequest hardcodes the request's hash algorithm OID to SHA-256 ('2.16.840.1.101.3.4.2.1') regardless of the actual digest algorithm HashPtr/HashLen represents — the caller is responsible for ensuring the hash they supply is genuinely SHA-256, since this function does not know or validate the digest algorithm itself. Both functions follow this SDK's two-call convention throughout (OutBuf = nil first to discover the required OutCap via OutLen, then a second call with a sized buffer) — tsaBuildRequest's return value with a nil OutBuf is True unconditionally (size-query mode always "succeeds"). tsaParseResponse extracts the response status, the token's generalized time string, message-imprint hash bytes, and serial number, each into independently-capped output buffers (each safely null-terminated within its own *Cap bound where applicable).
Parameters.
| Parameter | Description |
|---|---|
HashPtr, HashLen | *(Build)* The document hash to timestamp — must already be SHA-256; the OID is hardcoded, not derived from HashLen. |
CertReq | *(Build)* Whether to request the TSA's signing certificate in the response. |
NoncePtr, NonceLen | *(Build)* Optional anti-replay nonce. |
OutBuf, OutCap, OutLen | *(Build)* Two-call size-query/fill convention for the DER-encoded request. |
RespPtr, RespLen | *(Parse)* The TSA's raw DER response bytes. |
Status | *(Parse)* Output: the response status code. |
GenTimeBuf/GenCap, ImprintBuf/ImprintCap/ImprintLen, SerialBuf/SerialCap | *(Parse)* Output buffers for the token's generation time, message imprint, and serial number. |
Return value. True on success; False on malformed input or a buffer too small relative to the required output (with *Len still reporting the true required size in that case, per the two-call convention).
See also. pdfAddDocTimeStamp/tsaRequestTimeStamp (V10 Digital Signatures, not covered in this volume).
C# (P/Invoke)
[return: MarshalAs(UnmanagedType.Bool)]
Misc
tsaParseResponse
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.