Giter Club home page Giter Club logo

Comments (6)

s3bk avatar s3bk commented on August 16, 2024

Hello,

the decryption happens here: https://github.com/pdf-rs/pdf/blob/master/pdf/src/file.rs#L75

from pdf.

s3bk avatar s3bk commented on August 16, 2024

and it is set here: https://github.com/pdf-rs/pdf/blob/master/pdf/src/file.rs#L243

from pdf.

RudolfVonKrugstein avatar RudolfVonKrugstein commented on August 16, 2024

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.

s3bk avatar s3bk commented on August 16, 2024

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.

RudolfVonKrugstein avatar RudolfVonKrugstein commented on August 16, 2024

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.

s3bk avatar s3bk commented on August 16, 2024

ugh. yes.

from pdf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.