MatthiasValvekens / pyHanko

pyHanko: sign and stamp PDF files
MIT License
483 stars 71 forks source link

Support RSAES-OAEP for file encryption #269

Closed MatthiasValvekens closed 1 year ago

MatthiasValvekens commented 1 year ago

Description of the changes

This algorithm choice isn't widely supported in the field in viewers, and the public-key security handler for file encryption in PDF is not widely used in general either, but this change was straightforward to implement, so I added it.

Caveats

This is in a grey area of the PDF spec (=> it's silent on this topic), and Acrobat only supports PKCS#1 v1.5 padding. It does support other algorithms that are not explicitly in the spec, though (in particular using ECDHE to do non-interactive key agreement for file encryption).

Checklist

Please go over this checklist to increase the chances of your PR being worked on in a timely manner. Deviations are allowed with proper justification (see previous section).

For new features (delete if not applicable)

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (f8b2c25) 98.14% compared to head (7c2ae26) 98.14%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #269 +/- ## ======================================= Coverage 98.14% 98.14% ======================================= Files 104 104 Lines 14544 14569 +25 ======================================= + Hits 14274 14299 +25 Misses 270 270 ``` | Flag | Coverage Δ | | |---|---|---| | unittests | `98.14% <100.00%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matthias+Valvekens#carryforward-flags-in-the-pull-request-comment) to find out more. | [Impacted Files](https://app.codecov.io/gh/MatthiasValvekens/pyHanko/pull/269?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matthias+Valvekens) | Coverage Δ | | |---|---|---| | [pyhanko/pdf\_utils/crypt/pubkey.py](https://app.codecov.io/gh/MatthiasValvekens/pyHanko/pull/269?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matthias+Valvekens#diff-cHloYW5rby9wZGZfdXRpbHMvY3J5cHQvcHVia2V5LnB5) | `99.72% <100.00%> (+0.01%)` | :arrow_up: | | [pyhanko/pdf\_utils/embed.py](https://app.codecov.io/gh/MatthiasValvekens/pyHanko/pull/269?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matthias+Valvekens#diff-cHloYW5rby9wZGZfdXRpbHMvZW1iZWQucHk=) | `100.00% <100.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.