Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenSSL::Cipher::CipherError: bad decrypt #534

Open
krystof-k opened this issue Feb 20, 2024 · 2 comments
Open

OpenSSL::Cipher::CipherError: bad decrypt #534

krystof-k opened this issue Feb 20, 2024 · 2 comments

Comments

@krystof-k
Copy link

I have the following PDF, which is not encrypted, only locked for edits.

bad_decrypt.pdf

When trying to read it, it raises OpenSSL::Cipher::CipherError: bad decrypt error:

PDF::Reader.new("./bad_decrypt.pdf").pages
/app/vendor/bundle/ruby/3.1.0/gems/pdf-reader-2.12.0/lib/pdf/reader/aes_v2_security_handler.rb:37:in `final': bad decrypt (OpenSSL::Cipher::CipherError)

Is there a way how to skip the decrypt and try to read it without decrypting?

@yob
Copy link
Owner

yob commented Feb 21, 2024

I believe PDFs that are "locked for edit" are actually encrypted, although with a very weak scheme.

Looking at the raw file confirmed it is encrypted, but evince is able to decrypt and display it so this is definitely a bug in pdf-reader. Unfortunately there's no way skip the decryption.

@krystof-k
Copy link
Author

I see, I have no deep insight into the PDFs structure itself. Any idea how to investigate? I'd be happy to help but don't know where to start.

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

No branches or pull requests

2 participants