Skip to content

Commit

Permalink
#260 following, reuse test class
Browse files Browse the repository at this point in the history
  • Loading branch information
galkahana committed Jun 22, 2024
1 parent b991cb7 commit 6171b23
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 64 deletions.
6 changes: 3 additions & 3 deletions PDFWriter/DecryptionHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void DecryptionHelper::Reset() {
Release();
}

unsigned int ComputeLength(PDFObject* inLengthObject) {
unsigned int ComputeByteLength(PDFObject* inLengthObject) {
// The bit length of the file encryption key shall be a multiple of 8 in the range of 40 to 256 bits. This function returns the length in bytes.
ParsedPrimitiveHelper lengthHelper(inLengthObject);
unsigned int value = lengthHelper.IsNumber() ? (unsigned int)lengthHelper.GetAsInteger() : 40;
Expand Down Expand Up @@ -195,7 +195,7 @@ EStatusCode DecryptionHelper::Setup(PDFParser* inParser, const string& inPasswor
mLength = 40 / 8;
}
else {
mLength = ComputeLength(length.GetPtr());
mLength = ComputeByteLength(length.GetPtr());
}

// Setup crypt filters, or a default filter
Expand All @@ -216,7 +216,7 @@ EStatusCode DecryptionHelper::Setup(PDFParser* inParser, const string& inPasswor
if (!!cryptFilter) {
PDFObjectCastPtr<PDFName> cfmName(inParser->QueryDictionaryObject(cryptFilter.GetPtr(), "CFM"));
RefCountPtr<PDFObject> lengthObject(inParser->QueryDictionaryObject(cryptFilter.GetPtr(), "Length"));
unsigned int length = !lengthObject ? mLength : ComputeLength(lengthObject.GetPtr());
unsigned int length = !lengthObject ? mLength : ComputeByteLength(lengthObject.GetPtr());

XCryptionCommon* encryption = new XCryptionCommon();
encryption->Setup(cfmName->GetValue() == "AESV2"); // singe xcryptions are always RC4
Expand Down
1 change: 0 additions & 1 deletion PDFWriterTesting/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ create_test_sourcelist (Tests
PDFObjectParserTest.cpp
PDFParserFuzzSanity.cpp
PDFParserTest.cpp
PDFParserInvalidLengthTest.cpp
PDFWithPassword.cpp
PFBStreamTest.cpp
PNGImageTest.cpp
Expand Down
60 changes: 0 additions & 60 deletions PDFWriterTesting/PDFParserInvalidLengthTest.cpp

This file was deleted.

0 comments on commit 6171b23

Please sign in to comment.