ststeiger / PdfSharpCore

Port of the PdfSharp library to .NET Core - largely removed GDI+ (only missing GetFontData - which can be replaced with freetype2)
Other
1.07k stars 238 forks source link

Enhance encryption capabilities #274

Closed packdat closed 2 years ago

packdat commented 2 years ago

This PR adds support for reading PDF-documents protected by encryption-algorithms that were introduced in PDF version 1.6 and 1.7. (i.e. AES-encryption with a key-length of up to 256 bit) It does not alter the behavior of saving a PDF. While implementing this, i encountered several issues that were also addressed on the way:

I also added test-cases and Test-documents (protected by different encryption-algorithms)

codecov-commenter commented 2 years ago

Codecov Report

Merging #274 (6033e93) into master (2828a90) will increase coverage by 3.94%. The diff coverage is 89.04%.

@@            Coverage Diff             @@
##           master     #274      +/-   ##
==========================================
+ Coverage   26.62%   30.57%   +3.94%     
==========================================
  Files         238      242       +4     
  Lines       23336    23909     +573     
  Branches     2809     2881      +72     
==========================================
+ Hits         6214     7310    +1096     
+ Misses      16629    16062     -567     
- Partials      493      537      +44     
Impacted Files Coverage Δ
PdfSharpCore/Pdf.Security/PdfSecurityHandler.cs 100.00% <ø> (ø)
PdfSharpCore/Pdf.Security/RC4Encryptor.cs 82.90% <82.90%> (ø)
PdfSharpCore/Pdf.IO/Parser.cs 63.03% <85.71%> (+24.83%) :arrow_up:
PdfSharpCore/Pdf.Security/EncryptorBase.cs 87.03% <87.03%> (ø)
PdfSharpCore/Pdf.Security/EncryptorFactory.cs 91.66% <91.66%> (ø)
...arpCore/Pdf.Security/PdfStandardSecurityHandler.cs 86.51% <92.00%> (-1.36%) :arrow_down:
PdfSharpCore/Pdf.Security/AESEncryptor.cs 92.53% <92.53%> (ø)
PdfSharpCore/Pdf/PdfString.cs 40.38% <92.85%> (+8.51%) :arrow_up:
PdfSharpCore/Pdf.IO/Lexer.cs 79.05% <94.28%> (+12.06%) :arrow_up:
PdfSharpCore/Pdf.Advanced/PdfObjectStream.cs 80.00% <100.00%> (+80.00%) :arrow_up:
... and 33 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2828a90...6033e93. Read the comment docs.