## What this changes
Fixes#6754.
A revision appended after signing could change what a signed page shows while `classify_changes` reported only permitted changes. The update carried a new body for the page's content stream that no cross-reference section lists, plus an entry, named from the trailer, that points at no object. cos kept reading the signed content object (its entry had not changed), and read the new number as null, which `classify` drops. The renderer instead rebuilds its object index from the file's `N G obj` headers when an entry leads to no object (`vendor/hayro-syntax/src/xref.rs`, `repair` / `fallback_xref_map_inner`), and there the last header for a number wins, so the page drew the unlisted body.
`crates/sign/src/pdf/changes.rs` now refuses both halves, each on its own:
- **An entry that does not locate its own object.** Every object whose place changed since signing must have an entry that `xref_entry_is_exact` accepts, whatever the object reads as. Before, this was checked only when the content equalled the signed object's. Reported as `other changes`.
- **A body the reader does not read.** `unlisted_bodies` scans the bytes after the signed revision for `N G obj` headers. For each number and generation, the last header there must be where the current entry for that number points. Otherwise the renderer's rebuilt index may draw it. Reported as `page content` when the number had a signed page role, else `other changes`. This holds whatever triggers the rebuild, including a damaged entry the signed file already had. The scan is linear and bounded: past 2^20 distinct headers the appended bytes are not judged and the change is refused.
The scan finds more headers than the renderer's (it does not skip dictionaries or check that an object follows), so it errs towards refusing. A writer that lists what it writes is unaffected.
## How you verified it
- `cargo fmt --check -p pdfcraft-sign`
- `cargo clippy -p pdfcraft-sign --all-targets -- -D warnings`
- `cargo test -p pdfcraft-sign --test it`: 144 passed, 2 ignored.
- `cargo test -p pdfcraft-sign --lib`: 116 passed, 1 ignored. `shared_annotation_arrays_are_judged_in_bounded_time` (30,000 rewritten pages, 20 s budget) took 11.6 s and 14.4 s with the fix and 13.2 s with `changes.rs` at `main`, on the same machine under similar load: the scan and the extra entry check cost nothing measurable there.
New test `an_unlisted_object_body_or_an_entry_that_points_at_no_object_is_not_permitted` in `crates/sign/tests/it/pdf.rs`, for a P=1 certification and an approval signature:
- the issue's shape (unlisted content body, plus an entry for `/Info 60 0 R` that points at the section's own `xref` keyword) is Invalid, `page content`;
- the entry alone is Invalid, `other changes`;
- the unlisted body beside an honestly listed object is Invalid, `page content`;
- an honest revision that lists what it adds stays Valid.
**Seen failing before the fix:** with `changes.rs` at `main`, the test fails on its first case with `Allowed([])` and status Valid.
## Never-crash
- [x] No new `unwrap`/`expect`/`panic!`/`unreachable!`/`todo!` outside tests
- [x] No indexing or slicing with input-derived positions (`get` throughout); offsets use checked or saturating arithmetic; the header map is capped
- [x] No `unsafe`
- [x] Not a crash fix
## Provenance
- [x] No assets, fonts or copied code
- [x] Behaviour from ISO 32000-2 §7.5 and §12.8.2.2, and from observing the vendored renderer's repair path
## Anything a reviewer should look at first
- **What is still not modelled.** The renderer's repair scan also files the members of any `/Type /ObjStm` stream it meets (last one wins, unless a plain header exists for the number), attributes a headerless object-stream dictionary to the last header it saw, and keeps the last trailer-like dictionary whose `/Root` has `/Pages`. An appended object stream holding a forged member for an object the signed file kept only in an object stream, or a trailing `<< /Root … >>`, could still diverge once something else makes the renderer rebuild. This PR closes the issue's trigger (an entry that leads nowhere) and the unlisted plain body. The general fix, as the issue says, is to judge changes with the renderer's own object resolution. I have not covered those here, to keep this to the issue; they need their own issue.
- **Kind for a misplaced entry.** It stays `other changes`, as the existing `a_cross_reference_entry_that_misses_its_object_is_not_an_unchanged_object` expects, even for a signed page's content object: what the renderer draws there is unknown, not known to be new content.
## What this changes
Fixes#6757.
Validation read only DocMDP references. A signature field's `/Lock` (ISO 32000-2 §12.7.5.5) and the FieldMDP references in its value (§12.8.2.4) were ignored. So changing a locked field after an approval signature read as a permitted form fill, and the signature stayed **Valid**.
After this change:
- `crates/sign/src/pdf/locks.rs` (new) reads both from the **signed revision**: `All`, `Include` and `Exclude`. A listed name also covers the fields below it, so `address` covers `address.city` but not `addressee`. Both sources count, because signers write one or the other or both.
- The locked fields are compared between the signed revision and the document as it is now. That covers each field's dictionary and every dictionary above it (an inherited `/V` is its value too), plus its widgets. Tree links (`/Kids`, `/Parent`, `/P`) are left out of the comparison, and a page is compared by reference only, because adding an annotation rewrites it.
- A locked field that changed, disappeared, or gained a second field under its name adds the new change kind `kind::LOCKED_FIELD` ("locked field") to a **Disallowed** modification. The signature is then Invalid, whatever `classify_changes` called the change.
- A lock that is present but can't be read (an unknown `/Action`, a FieldMDP reference with no parameters, a non-dictionary `/Lock`), or a form too large to compare within the listing's caps, leaves the signature **Unknown**, never Valid. The detail is the existing "The signature could not be checked ({})." wording.
- New fields added under a locked field, and the form's `/NeedAppearances` (plus `/DA`, `/DR` and `/Q` when a locked field has no appearance of its own), count as changes to it. The signature's own field is compared when its lock covers it.
- `classify_changes` and `changes.rs` are unchanged. The check is wired in `finish_validation` (`validate.rs`).
- `parity`: `sign.field-mdp` moves from `planned` to `partial`, with what's still missing.
Related: #4809 makes *filling* refuse locked fields in PdfCraft's own form UI. The `sign` crate can't depend on `forms`, so this PR doesn't share its `signature_locks`. The lock reading follows the same rules (action, prefix matching, both sources) independently, and the two can be merged into one reader later. The two PRs touch different files.
## How you verified it
Run locally (Windows), scoped to `pdfcraft-sign`:
- [x] `cargo fmt --check -p pdfcraft-sign`
- [x] `cargo clippy -p pdfcraft-sign --all-targets -- -D warnings`: clean
- [x] `cargo test -p pdfcraft-sign --no-fail-fast`: integration 154 passed. Lib 120 passed, 1 failed: `shared_annotation_arrays_are_judged_in_bounded_time` (20 s limit) took 25 to 34 s. That test calls `classify_changes` directly, which this PR doesn't touch, and it fails the same way on unmodified `origin/main` on this machine (42 s), which was heavily loaded. CI should settle it.
- [x] `cargo xtask parity`: ok
- [x] Rerun on 78a860fda (head, includes a38542ab1 and the catalog fix from review): `cargo fmt --check -p pdfcraft-sign`, `cargo clippy -p pdfcraft-sign --all-targets -- -D warnings` (clean), `cargo test -p pdfcraft-sign` (lib 122 passed, including the timing test this time; integration 154 passed).
- [ ] `cargo xtask layers` / `assets`: not run (no crate boundary or asset touched)
**Tests.** `crates/sign/tests/it/field_locks.rs` signs a form with an approval signature whose field carries a `/Lock`, then appends an update:
- `changing_a_field_the_signature_locks_invalidates_it`: `Include [amount]`. Changing `amount`'s `/V`, its `/V` and `/AP`, or only its appearance stream makes the signature Invalid with `locked field`. Changing the unlocked `note` stays Valid (form fill).
- `exclude_locks_every_field_it_does_not_name`, `all_locks_every_field`, `a_locked_parent_locks_its_kids`, `removing_or_shadowing_a_locked_field_changes_it`.
- From review (fd11fcb6c), each seen failing on the first commit: `a_reference_cycle_in_a_locked_field_ends` (overflowed the stack), `an_all_lock_covers_the_signatures_own_widget`, `a_new_field_below_a_locked_one_changes_it`, `the_form_defaults_a_locked_field_is_drawn_with_are_locked_too` and `an_unreadable_lock_leaves_a_later_fill_unknown`.
- Control: `without_a_lock_the_same_change_is_a_form_fill`.
- Unit tests in `locks.rs`: a FieldMDP reference in the signature value locks fields, names cover kids only and match exactly as written, an unreadable lock (bad `/Fields` or `/Reference`, too many locks) is "unchecked" rather than "no lock".
I watched them fail: before the fix, 5 of the 6 integration tests failed (all reported Valid, as the issue describes) and the control passed. With the `locked_fields` call reverted once, the same 5 went red again.
## Never-crash
- [x] No new `unwrap`/`expect`/`panic!`/`unreachable!`/`todo!` outside tests
- [x] No input-derived indexing. The field walk keeps a seen-set and uses the listing's caps (`MAX_FIELDS`, `MAX_ENTRIES`, `MAX_NAME_BYTES`, `MAX_FIELD_NAME_BYTES`) plus a depth limit of 64. The comparison is bounded to 2^18 visited objects, every reference followed counts toward the depth limit, and reference pairs are memoised, so cycles end. Lock matching is one set lookup per node per lock, with at most 16 locks. Hitting any cap gives Unknown, not Valid.
- [x] No `unsafe`
## Provenance
- [x] No assets
- [x] Behaviour from ISO 32000-2 (§12.7.5.5, §12.8.2.4) and the issue's trace
## Parity and reach
- [x] `sign.field-mdp` → `partial`. Notes say what's missing: writing a lock when signing, refusing to fill a locked field (#4809), and the `/Lock /P` permissions.
- [x] Reachable headlessly: `sign_list` reports the verdict and the modification kinds.
## Anything a reviewer should look at first
- **`All` locks other signature fields too.** Signing a second, still-empty signature field after a signature with `Action /All` counts as a change to a locked field, so the first signature becomes Invalid. That is how I read §12.7.5.5, where the lock names fields and a signature field is one. If you'd rather exempt signing an empty signature field, it's a one-line filter in `locked_fields`.
- **The comparison is strict.** Any change to a locked field's dictionaries or widgets counts, including a re-encoded but identical appearance stream. I chose to err toward Invalid on these.
- **New change kind.** `kind::LOCKED_FIELD` is in `kind::ALL`, so interfaces will look up a new word ("locked field"). It shows in English until craft-i18n translates it.
* fix(sign): judge a shared signature value once per listing; dedupe DSS evidence by object number
* address review: shared signature values are judged by output index without copying the dictionary; a dead evidence reference does not hide a live one
* address review: repeated evidence references are skipped before they are resolved
* address review: each full evidence reference is tried once
- `has_signatures` treats a /Contents of only zero bytes as unsigned and finds
signature dictionaries in one pass over the file (field /V values, plus
/ByteRange dictionaries and document timestamps) instead of two.
- Before the first signature, a field's own appearance counts as drawing text
only if it or a form XObject it paints shows text; a background-only XObject
no longer keeps an appearance that would leave the field blank. The look
inside opens at most 16 streams; past that it counts as text, as before.
- Tests: zero-filled placeholders (hex and literal), document timestamps, a
widget without /AP, background-only and text-drawing XObject appearances
with an unencodable character.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Once the flag is gone, viewers show each field's stored appearance, so a
filled field whose /AP /N draws no text (a /Tx BMC EMC placeholder or a
stale look) went blank. Session::sign and sign_with_timestamp now sign the
copy with_field_appearances draws, as the document is displayed, when the
signature is the first. A field whose own appearance draws text keeps it
where PdfCraft's drawing would show a character as `?`.
The earlier-signature check is now pdfcraft_sign::has_signatures, shared by
the engine and the signer, and it also finds signed fields without a /T.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* M9: redraw named-layer signature status layers
- /N drawing one Form that holds n1 and n3: n1, n3 and n4 redrawn for the state
- copies made once per original and state; originals never edited
- Lucide icons; captions in Helvetica, embedded Inter, or craft-fonts outlines
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: draw signature states in the display copy, exports and print
- marks follow the bytes shown; a changed verdict redraws after a metadata edit
- background opens pick up the trust and captions current at commit
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: status captions in the interface language
- the three captions in all 22 catalogues
- Signatures panel colours from sign::status_rgb
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: signature badge in the widget's corner
- a quarter of the shorter side, 48pt cap; outline only under 32pt
- dropped for a drawn valid state; bottom-right where the appearance draws one
- sign_list reports verdict_shown; parity and roadmap
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: keep Arabic signature captions in logical order
Pass raw RTL catalogue text to the signature appearance shaper so UAX #9 is applied exactly once. This keeps the rendered word order and exported /ActualText consistent.
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M2: read /ActualText over painted paths and pictures
- A replacement that marks no glyph reads where it paints, cut to what is visible and along the way it is drawn.
- A span the page content leaves open ends before the annotations.
- OCR and scan field detection still count such a page as having no text of its own.
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M8: redaction strips /ActualText around paint it clips
- A path or shading written again under a clip counts as changed, so a partly redacted word drawn as outlines leaves no name in the file.
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: recognise only layer forms that draw n1 and n3
- Settle on the one form holding both first, then read its content once per call.
- Skip an /N that is its own layer form; copies keep the layer's /OC.
- A verdict counts as drawn when any visible widget shows it.
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: keep the signature badge and redraw wherever a state changes
- The badge stays for every state; its mark sits bottom-right as the widget lies on the page.
- An edit that changes a verdict redraws every page; captions apply before startup files open.
- Print, the CLI's render and the repair log follow the display copy.
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: restore the attribution usage the rebase dropped
- Usage lines for the three icons, Inter and the craft-fonts input; ATTRIBUTION.md rebuilt from them.
- Roadmap and localization notes for this round.
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: pin signature field names on a nested form
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: bound the signature field walk
- kids share their parent's name and type instead of each copying them
- a widget stays listed under every field that claims it, as one shared copy
- a field written in place in a shared /Kids array is walked once
- caps of 20,000 fields, 100,000 entries and 4096-byte names; no states drawn past them
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: keep a document signed when the field walk stops early
- list_cached adds a signed row of unknown validity for the fields the walk didn't read
- Save As and actions then append, and Optimize, Sanitize and full rewrites are refused, as for any signed file
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M8: removing hidden content no longer strips the names of shadings
- With no regions to clip, a shading is left alone instead of wrapped and marked clipped
- clean_replacements skips scopes already marked, so deep nesting stays linear
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M2: read a picture's /ActualText over the whole picture
- draw_image's transform maps pixels, not a unit square, so the text sat on one pixel in the corner; the test now draws a 2x2 picture
- Painted grows in place instead of being copied through an Option
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: cap the bytes of names the signature field walk keeps
- A kid's name repeats its parent's, so one long name over 20,000 kids came to 80 MB; the walk now stops at 4 MiB of names and counts the rest as unread
- Cover the widget written into a shared /Kids array and the field cap among kids, which no test caught
- sig_fields is private again, and the cap docs say what happens past each cap
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: skip status-layer work that changes nothing; fix tests that could not fail
- show_status_layers and has_status_layers return before reading the form when nothing is signed, so an unsigned form no longer walks every field on each edit
- revalidate and draw_captions leave documents with no drawn state alone, and no longer copy the signature list to update it
- Scan form detection reads the page's text once; comment and badge tips share one hover rule
- Tests: drop a table row that repeated another, stop taking an expectation from the code under test, stop comparing an Arc with itself, give bare asserts messages
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: test the signature field name cap at the engine boundary
- A 4,096-byte name is read and blocks a full rewrite; at 4,097 bytes the list holds the unread-fields row and a full rewrite is still refused
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: test signature states beside fields the viewer draws
- One display copy holds both a field's drawn appearance and the signature's state.
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: draw Thai and Devanagari status captions in their own script
- script_of names Thai and Devanagari, so a craft-fonts face meant for either draws the caption as outlines; without one it stays English.
- Localization, parity and the craft-fonts usage line list the new scripts.
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M2: paint left out by an exclusion mixes its /ActualText replacement
- A replacement placed by outlines or pictures, some of them excluded, fails filtered extraction as one with excluded glyphs does.
- Glyphs still place a replacement that has them.
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: a long-named field that can't hold a signature leaves the walk whole
- A leaf of another type passed over for its name is no signature field and has none below it, so an unsigned form stays unsigned.
- A signature field, or any field with kids, still counts as unread.
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: status captions use document faces only
- Each script takes the face PdfCraft writes it into documents with, so Chinese stays English although the pinned craft-fonts' interface-only Chinese face is meant for Hani.
- The craft-fonts usage line names Devanagari: the pinned revision has a face for it, and Hindi captions are drawn in it.
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: refuse a new signature field the field walk can't read back
- Signing adds a field only when the walk reads the whole form with it: past a cap the signature would be listed as unread fields, and its name could repeat an unread field's.
- A field the walk already reads is signed as before.
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: refuse a new signature field with a blank name
- The walk lists no field without a name, so signing now also requires the walk to list the new field: one named only with spaces or NULs would be a signature nothing shows.
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: an unnamed signed field or an unreadable form counts as unread
- A signed field with no usable /T, or an /AcroForm or /Fields of the wrong type, cuts the field walk short: the document keeps its unread-fields row and stays signed.
- Signing refuses a blank new field name before it adds the field, so the refusal still says why.
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: no display copy when no signature state is drawn
- display_bytes_for makes a copy only when it added an appearance or drew a state, as the app does.
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: the verdict mark stays on the page
- A widget past the crop box takes its mark in the part on the page, or none when too little of it is there.
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: typed values stay drawn while a signature redraws every page
- A form edit that changes a signature's state puts its values back in unbaked after the pages are invalidated.
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: the action, Save As and shading tests check their effects
- The signed action and Save As tests reopen the output for the title and the comment; the shading test checks its clip.
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: values typed earlier stay drawn while a signature redraws every page
- A form edit that changes a signature's state keeps every value still waiting on its page, not only its own.
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: comment and content edits keep typed values drawn too
- An edit to one page's comments or content that changes a signature's state moves no page, so the values still waiting on their pages stay pending, as after a form edit.
- The pending-value test runs a field deletion and a comment after a fill, under a certification that allows the fill; its messages say what it checks.
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: the language-change test skips without catalogs
- Like the other language tests, it returns early when the build has no craft-i18n catalogs.
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
* M9: signed fields behind kids without a name count
- A kid with no /T but kids of its own is walked as a field node, so a signed field under it is listed by its full name.
- An unnamed kid claiming a signature its field doesn't have cuts the walk short, so the document stays signed and keeps its unread-fields row.
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
---------
Signed-off-by: Chiranjeevi U <244287281+chiranjeevi-max@users.noreply.github.com>
Only a non-empty signature value counts when deciding whether the first real
signature may drop /NeedAppearances.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
ISO 32000-2 §7.3.3: wherever a real number is expected, an integer may
be used instead. PdfCraft's own writer writes a whole real as an
integer, so a form fill that rewrites a signed widget turned
/Rect [20.0 20.0 120.0 40.0] into [20 20 120 40] and was refused as a
page content change. same_object now compares an integer and a real by
value (exactly, in i128), for the widget /Rect and every other signed
comparison, such as a page /MediaBox rewritten when a comment is added.
Also states the reordered page's verdict as None explicitly, in a test
of its own next to the one from #5962.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
A string object is its bytes; literal and hexadecimal are two ways to
write them (ISO 32000-2 §7.3.4.1-7.3.4.3). The modification check
compared objects with the derived equality, which also compares how a
string was written, so a later save that rewrote the catalog's /Lang
from (en-US) to <656E2D5553> made an untouched signature read as a
document structure change.
same_object now compares strings by their bytes, and every comparison
in changes.rs goes through it: the unchanged-object skip, the catalog,
its /AcroForm and /Perms, developer extensions, signed widgets, page
resource containers, the security store and the timestamps check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
Conflict in crates/sign/src/pdf/changes.rs: main moved the signed-page
check into ChangedObjectClassifier::page_change_kind. The method now
uses same_but_annots, as the free function it replaced did on this
branch; the branch's tests reach it through a test helper of the same
name, and both test sets are kept.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
* trust certificate key type when CNG algorithm group is unreadable
When the algorithm group can't be read from the key store due to a provider bug, the certificate should not be rejected: its SubjectPublicKeyInfo already states the key type, and a real mismatch will surface at signing time instead of at enumeration.
Change matches_key to fall back to Ok(()) when key.algorithm_group() returns an error, trusting the certificate's key type; extract the group comparison into key_group_matches(group: Option<&AlgorithmGroup>, want: StoreKey) so the fallback and mismatch cases can be unit tested without a live CNG key.
Test: key_group_matches_trusts_when_group_unreadable failed before the change and passes after.
* Sign: back to LF line endings, shorter test comment
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: eliets2 <287273517+eliets2@users.noreply.github.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Rebased #5173 onto 9afa1266. Its later-signature predicate is superseded by
#6364's object-based check, so only the /Perms rule lands: under DocMDP P=1 a
/Perms that differs from the signed catalog's, by content, is a structure
change however it was rewritten.
Co-Authored-By: LetoCoder26 <leto@lvanwesten.eu>
Rebased #5187 onto 9afa1266. Landing the signed-role rule only: an existing
object that gains form or annotation keys is judged by what it was when
signed, and a signed annotation turned into another kind is no comment.
The two P1 regressions the original PR carried are not landed: the signature
decision still reads the new /FT (a signed widget relabelled as a text field
is not signing), and the dropped-/Fields check runs before the form-key
comparison (already carried by #6358's lost_entries).
Co-Authored-By: LetoCoder26 <leto@lvanwesten.eu>
Rebased onto 102cae3b/9afa1266 for landing (#6358). The signed page tree's
nodes, a /Kids array of its own, the catalog by object number and an indirect
AcroForm keep the roles they had when signed; a field dropped from the form is
no permitted change at any level; a signed widget's /Rect or /F is page content.
Co-Authored-By: Martin Ball <martin.ball@ucscaregroup.co.uk>
DocMDP P=1 allowed any change classified as a signature. A signature added
after signing now breaks the certification unless it is a document timestamp
drawing nothing (no positive-area /Rect, or Hidden/NoView). The added objects
are judged directly, so a widget with no /T or one only in a page's /Annots is
covered. The document security store and a genuine timestamp still pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
An annotation list is compared by the entries that resolve in each revision,
and an unchanged list is no change. Expanding annotation lists is bounded per
classification. A damaged slot rewritten with fewer accepted generations is the
same slot when nothing signed refers to a generation it gave up.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Judge each object changed after signing by the role it held in the signed
revision, keyed by object number, and compare a slot's accepted generations
across revisions. Adds `Document::accepted_generations` to cos.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With hayro-syntax patch 36 and its cos counterpart, a stream with no
endstream left in the file is the bytes its /Length gives, so the fixture's
`<< /Length 0 >>` stream without endstream now reads as an empty stream.
The test needs an object that cannot be read: a stream with no /Length
either still is one.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn