Comments (6)
Hello,
the decryption happens here: https://github.com/pdf-rs/pdf/blob/master/pdf/src/file.rs#L75
from pdf.
and it is set here: https://github.com/pdf-rs/pdf/blob/master/pdf/src/file.rs#L243
from pdf.
Ok, as far as I understand the following is happening:
In _parse_with_lexer_ctx
objects are found and decrypted. For examples for Strings here.
But for streams, the data is not really read, only the range withing the file where the stream is located is strored (that happens in parse_stream_object
which is called here and defined here.
Then, in Storage::decode
the data at the range stored for the stream is taken from the file and decoded in decode
. But it is not decrypted there. Decryption at that point is also not easy, because the Context with the key is not available (as far as I can see).
Is my analysis correct?
If so, I wonder how to fix that.
- Option A: Instead of only storing the range for the stream, store the decrypted stream.
- Option B: Make the key available at the point where the stream is decoded (in FlateDecode for example).
- Option C: I am totally wrong (not unlikely).
@s3bk What do you think, how should this be done? I am willing to try to implement this but I would like your opinion so I am not running in the wrong direction.
from pdf.
From my understanding there is only one key per file, which is why decrypting happens in storage.
Why is it not decrypted?
https://github.com/pdf-rs/pdf/blob/master/pdf/src/object/stream.rs#L84 should call
https://github.com/pdf-rs/pdf/blob/master/pdf/src/file.rs#L129 which calls
https://github.com/pdf-rs/pdf/blob/master/pdf/src/file.rs#L70
and decrypts it.
from pdf.
Mmmh, should decrypt
work "in place"? Maybe https://github.com/pdf-rs/pdf/blob/master/pdf/src/file.rs#L75 should be
data = Vec::from(t!(decoder.decrypt(id, &mut data)));
from pdf.
ugh. yes.
from pdf.
Related Issues (20)
- --example option gets content,metadata,names,read, but cannot get 'text' HOT 8
- Is it true that "At the moment, you can only read PDF files."? HOT 4
- how to extract text from pdf files? HOT 1
- Error UnspecifiedXRefEntry on reading pdf with only two images HOT 1
- Cannot open file: Neither Kids nor Names present in NameTree node HOT 3
- None value for PNG filters HOT 3
- Add support for reading the file from memory in 0.8 HOT 1
- thread 'main' panicked at 'Unknown part primitive in dictionary: Number(1.0)' HOT 1
- thread 'main' panicked at 'Unknown element: Number(4050.0)', HOT 2
- thread 'main' panicked at 'range end index 16 out of range for slice of length 8', crypt.rs:211:43
- thread 'main' panicked at 'range end index 17 out of range for slice of length 16', crypt.rs:290
- thread 'main' panicked at 'range end index 4085 out of range for slice of length 4078', file.rs:165
- index out of ranges and assertion failures HOT 9
- Error (unimplemented) trying to run the example with any of the files HOT 2
- New file generation HOT 4
- Test for length of encryption key does not work for my PDF HOT 2
- Reading contents of a PDF HOT 8
- Failing to read PDF due to creation_date HOT 1
- Failure to read PDF with image HOT 1
- Failure to read PDF with Color Space
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pdf.