MatthiasValvekens / pyHanko

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

Support ECDH for file encryption in public-key mode in an Acrobat-compatible way #271

Closed MatthiasValvekens closed 1 year ago

MatthiasValvekens commented 1 year ago

Description of the changes

While the PDF standard is silent on this issue, Acrobat implements the dhSinglePass-stdDH-sha*kdf ephemeral-static ECDH family of schemes from RFC 5753, allowing documents to be encrypted for ECC key recipients. This PR implements that feature in pyHanko.

Caveats

Support for this mode of encryption in PDF readers & libraries is spotty at best, but that's not a huge deal, since presumably someone who's willing to advertise an ECC public key as a target for PDF encryption has the means to decrypt it.

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 project coverage change: +0.01 :tada:

Comparison is base (e4e5cdd) 98.14% compared to head (f4a7365) 98.15%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #271 +/- ## ========================================== + Coverage 98.14% 98.15% +0.01% ========================================== Files 104 104 Lines 14569 14670 +101 ========================================== + Hits 14299 14400 +101 Misses 270 270 ``` | Flag | Coverage Δ | | |---|---|---| | unittests | `98.15% <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/271?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/271?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matthias+Valvekens#diff-cHloYW5rby9wZGZfdXRpbHMvY3J5cHQvcHVia2V5LnB5) | `99.78% <100.00%> (+0.05%)` | :arrow_up: |

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