Repository navigation
Description
Why
ISO 19005-2:2011, 6.1.13 lists ten "shall not contain" limits. One is any string longer than 32767 bytes. The sentence has no qualifier and no exemption for a signature /Contents (NEN reading 2026-12-02, RNR 161167). ISO 32000-1 Table C.1, which the clause's informative NOTE 1 points at, limits only "string (in content stream)" (held copy, text p. 650); 19005-2's normative sentence drops that qualifier, so every string in the file counts. A string's bytes are its value bytes, so a hex string of 2n digits is n bytes (ISO 32000-1, 7.3.4.3).
Measured
Probe against origin/main 2d587c2 (Release, net10.0): a Layout Document with one paragraph, signed with PdfSignatureSettings that set only the certificate, Level, TimestampClient and (from B-LT) RevocationClient. The probe decodes every /Contents <...> hex string in the output and prints its byte length.
Level, EstimatedSignatureSizeBytes |
decoded /Contents bytes |
|---|---|
| B-B, default 8192 | 8192 |
| B-T, default 8192 | 32768 |
| B-LT, default 8192 | 32768 |
| B-LTA, default 8192 | 32768 (signature), 32768 (document timestamp) |
| B-LTA, 16000 | 16000, 32768 |
| B-T, 32767 | 32767 |
| B-T, 40000 | 40000 |
The probe is not in the tree; it covers one certificate and the in-process test TSA, so it measures the reserve, not the size of a real token. The reserve is what is written, because the patcher zero-pads the placeholder to its full length (SignaturePlaceholderPatcher.cs:110-116).
Where the numbers come from:
PdfCmsSigner.cs:31setsTimestampedDefaultReserve = 32768, andEffectiveReserve(:40-43) returns it when a timestamp client is set and the size is the default 8192. B-T, B-LT and B-LTA all take this path.ArchiveTimestampBuilder.cs:52and:105defaultestimatedTokenSizeBytes = 32768.SigningExtensions.cs:390and:425call it without the argument, so the B-LTA document timestamp is always 32768 bytes and the caller cannot change it.- An explicit size is accepted up to
MaxContentsPlaceholderBytes= 536,870,894 (PdfSignatureHelper.cs:52, checked atPdfDocument.cs:1577). Nothing looks at the document's conformance claim. The 40000 row shows an explicit size above the limit reaching the file. - The placeholder writes two zeros per byte (
PdfSignatureHelper.cs:43-44).
What the validator and the docs say today
NumericLimitsRule.cs:133-139skips the length check for a signature dictionary's /Contents. Its comment says the size "is governed by the CMS structure rather than the PDF string limit" and that veraPDF 1.30.2 accepts it. The rule's own remarks at:19-20already say the exemption is one "no clause grants".PdfPreflightTests.cs:1087(Validate_SigContentsOversized_NoStringFinding) pins the exemption with a 32768-byte /Contents.PadesLevel.cs:11-15says signing a conformance document at B-LT and B-LTA "preserves its conformance".Signed_PdfA2b_BLTA_veraPdf_reportsCompliantand its 2u and 2a siblings (PdfValidatorOracleTests.cs:822-852) sign with the defaults and pass, so veraPDF does not report the string. Those tests prove veraPDF accepts the file, not that the file meets 6.1.13.PdfSignatureSettings.cs:114-118documents the size as "default is 8192" and says nothing about the 32768 swap or about PDF/A.
Scope of the reading: only ISO 19005-2 was read. 19005-1 and -3 were not, so this issue is about the PDF/A-2 claims.
Proposal
When the document under signature claims PDF/A-2:
- The timestamped default reserve and the archive-timestamp default become 32767.
- An explicit
EstimatedSignatureSizeBytesabove 32767 is refused, naming 6.1.13 and the limit. A token that does not fit 32767 bytes already throws fromPatchContents(SignaturePlaceholderPatcher.cs:104-108); extend that message to name the limit under a PDF/A claim, since it now tells the caller to raise a parameter they cannot raise. NumericLimitsRulestops exempting /Contents, and the exemption comment goes.
Without a PDF/A claim nothing changes.
A signature that cannot fit 32767 bytes cannot be PDF/A-2, because /Contents is the one string that holds it, so refusing is the only choice once the reserve cannot shrink further.
Compatibility: a 32768-byte /Contents was invalid under the claim, so R3 of the v2.4 compat rules allows the refusal (a new refusal is allowed where 2.3.3 wrote an invalid file). The default change alters the bytes of every timestamped PDF/A signature, by 1 byte of reserve, which is the same R3 reasoning.
Acceptance
- A PDF/A-2 document signed at B-T, B-LT and B-LTA on the defaults has no string over 32767 decoded bytes, asserted by decoding every /Contents in the output.
- Reserve 32767 saves; reserve 32768 under a PDF/A-2 claim is refused with a message naming 6.1.13; both asserted. The same pair for the archive timestamp path.
NumericLimitsRulereports a 32768-byte signature /Contents and passes a 32767-byte one;Validate_SigContentsOversized_NoStringFindingis rewritten to the new rule.- A non-PDF/A document keeps the 32768 default and the same bytes as before.
- XML docs corrected:
PdfSignatureSettings.EstimatedSignatureSizeBytes(the swap, the PDF/A limit, which call throws and the exception type),PadesLevelremarks,NumericLimitsRuleremarks. CHANGELOG entry. - The three veraPDF
Signed_*_BLTAoracle tests still pass.
Related: #418.
Activity