Skip to content

Cover encryption param parsing (crypt)#17

Merged
pgundlach merged 1 commit into
mainfrom
claude/crypt-param-coverage
Jun 23, 2026
Merged

Cover encryption param parsing (crypt)#17
pgundlach merged 1 commit into
mainfrom
claude/crypt-param-coverage

Conversation

@fank

@fank fank commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

encryptParamsFromDict (65.9%) and initEncrypt (78.9%) were only exercised for the V2/R3 RC4 path. This adds coverage of the untested seams, all at the Open() surface.

Tests

  • TestOpenDecryptsV4RC4Stream — a V4/R4 fixture whose StdCF crypt filter uses CFM /V2 (RC4, same empty-password key derivation as V2/R3). Decrypts a stream end-to-end through the /CF + /StmF parsing path that V2 doesn't touch.
  • TestEncryptNonStandardFilterRejected/Filter /FooSecurity must error, not be treated as unencrypted.
  • TestEncryptMalformedNoPanic/Encrypt that is the wrong type, missing /V and /R, has short /O+/U, or short V5 /OE//UE//Perms must all error gracefully (and the V5 case exercises those param assignments).

Refactor

Shared PDF assembly extracted from buildRC4EncryptedStreamPDF into assembleEncryptedPDF, reused by both the V2 and new V4 builders.

No production code changed. Coverage: initEncrypt 78.9% → 89.5%; encryptParamsFromDict 65.9% → 95.1%.

encryptParamsFromDict and initEncrypt were only exercised for the V2/R3
RC4 case. Add coverage at the Open() surface:

- a V4/R4 fixture using a /CF StdCF crypt filter (CFM /V2), decrypting a
  stream end-to-end through the /CF + /StmF parsing path;
- rejection of a non-Standard security handler;
- a malformed-/Encrypt sweep (wrong type, missing /V and /R, short O/U,
  short V5 OE/UE/Perms) that must error, never panic.

Factor the shared PDF assembly out of buildRC4EncryptedStreamPDF so the
V2 and V4 builders reuse it.

initEncrypt 78.9% -> 89.5%; encryptParamsFromDict 65.9% -> 95.1%.
@fank fank marked this pull request as ready for review June 22, 2026 22:06
@fank fank requested a review from pgundlach June 22, 2026 22:06
@pgundlach pgundlach merged commit 17a5c49 into main Jun 23, 2026
1 check passed
@pgundlach pgundlach deleted the claude/crypt-param-coverage branch June 23, 2026 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants