Repository navigation
Use 32 random bytes as the owner password when none is given - #1816
Closed
andreasrosdal wants to merge 1 commit into
Closed
andreasrosdal wants to merge 1 commit into
andreasrosdal wants to merge 1 commit into
Conversation
A document encrypted with a user password and without an owner password got the MD5 hash of a random document ID as its owner password. It now gets 32 bytes from SecureRandom, the full length of a padded password and of an AES-256 key, and MD5 is no longer used to create it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| BestPractice | 1 medium |
🟢 Metrics 5 complexity · 0 duplication
Metric Results Complexity 5 Duplication 0
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
When a document is encrypted with a user password and no owner password (
nullor empty),PdfEncryption.setupAllKeysmade one up: the MD5 hash of a random document ID (16 bytes). It now uses 32 bytes fromSecureRandom:API changes
None. The new
PdfEncryption.createRandomOwnerPassword()is package-private.Tests
RandomOwnerPasswordTestchecks the password length and that it differs each time. For RC4-40, RC4-128, AES-128 and AES-256 it checks that the user can read the document without owner permissions and that an empty owner password is replaced too. It also checks that an owner password that is given still gives full permissions. The fullopenpdf-coresuite passes andcheckstyle:checkis clean.🤖 Generated with Claude Code