PLTrimCMSPadding
Signature utilities
Description
Cuts a PDF signature /Contents value back to the CMS blob it actually holds. The entry is padded with trailing zero bytes out to the space reserved for it, so the raw string is longer than the DER message it carries; this function parses the outer TLV and returns the bytes up to the end that the outer SEQUENCE declares.
The result is empty when the input does not start with a well-formed DER SEQUENCE, either because the tag is not a SEQUENCE or the length cannot be decoded. The walk reads structure only and verifies nothing, using the read-only PDFlibCMSRead unit available in every edition.
Syntax
Delphi
Function PLTrimCMSPadding(Const Data: AnsiString): AnsiString;Parameters
| Data | The raw binary /Contents value decoded from its PDF hexadecimal representation, padding included |
|---|
Return values
| AnsiString | The CMS blob trimmed to the length its own outer SEQUENCE declares |
|---|---|
| '' | The bytes do not start with a well-formed SEQUENCE |
Remarks
Feed the trimmed blob to PLExtractCMSCertificates, PLGetCMSSignerCount and the other read-side helpers of the unit; validate the discarded padding separately when a caller needs to prove nothing was appended after the message.
This Pascal unit function has no separate DLL or ActiveX forwarding entry point.
See also
PLCheckSignatureByteRange, PLCheckCMSSignedDataStructure, GetPAdESSignatureCMSBytes