Skip to content

Commit

Permalink
try to fix TPdfEncryptionRC4MD5
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud Bouchez committed Feb 4, 2021
1 parent 48cf10a commit f790c5d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion SynPdf.pas
Expand Up @@ -10986,12 +10986,14 @@ procedure TPdfEncryptionRC4MD5.EncodeBuffer(const BufIn; var BufOut; Count: card
fLastObjectNumber := fDoc.fCurrentObjectNumber;
fLastGenerationNumber := fDoc.fCurrentGenerationNumber;
end;
var work: TRC4; // Encrypt() changes the RC4 state -> local copy for reuse
begin
if (fDoc.fCurrentObjectNumber<>fLastObjectNumber) or
(fDoc.fCurrentGenerationNumber<>fLastGenerationNumber) then
// a lot of string encodings have the same context
ComputeNewRC4Key;
fLastRC4Key.Encrypt(BufIn,BufOut,Count); // RC4 allows in-place encryption :)
work := fLastRC4Key;
work.Encrypt(BufIn,BufOut,Count); // RC4 allows in-place encryption :)
end;

{$endif USE_PDFSECURITY}
Expand Down
2 changes: 1 addition & 1 deletion SynopseCommit.inc
@@ -1 +1 @@
'1.18.6225'
'1.18.6228'

0 comments on commit f790c5d

Please sign in to comment.