diff --git a/PDFWriter/DecryptionHelper.cpp b/PDFWriter/DecryptionHelper.cpp index c3c1554a..290af1be 100644 --- a/PDFWriter/DecryptionHelper.cpp +++ b/PDFWriter/DecryptionHelper.cpp @@ -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; @@ -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 @@ -216,7 +216,7 @@ EStatusCode DecryptionHelper::Setup(PDFParser* inParser, const string& inPasswor if (!!cryptFilter) { PDFObjectCastPtr cfmName(inParser->QueryDictionaryObject(cryptFilter.GetPtr(), "CFM")); RefCountPtr 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 diff --git a/PDFWriterTesting/CMakeLists.txt b/PDFWriterTesting/CMakeLists.txt index 3be15b12..e46e283b 100644 --- a/PDFWriterTesting/CMakeLists.txt +++ b/PDFWriterTesting/CMakeLists.txt @@ -54,7 +54,6 @@ create_test_sourcelist (Tests PDFObjectParserTest.cpp PDFParserFuzzSanity.cpp PDFParserTest.cpp - PDFParserInvalidLengthTest.cpp PDFWithPassword.cpp PFBStreamTest.cpp PNGImageTest.cpp diff --git a/PDFWriterTesting/Materials/InvalidEncryptionLength.pdf b/PDFWriterTesting/Materials/fuzzing/InvalidEncryptionLength.pdf similarity index 100% rename from PDFWriterTesting/Materials/InvalidEncryptionLength.pdf rename to PDFWriterTesting/Materials/fuzzing/InvalidEncryptionLength.pdf diff --git a/PDFWriterTesting/PDFParserInvalidLengthTest.cpp b/PDFWriterTesting/PDFParserInvalidLengthTest.cpp deleted file mode 100644 index e8a22127..00000000 --- a/PDFWriterTesting/PDFParserInvalidLengthTest.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - Source File : PDFParserTest.cpp - - - Copyright 2011 Gal Kahana PDFWriter - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - -*/ -#include "PDFParser.h" -#include "InputFile.h" -#include "PDFStreamInput.h" -#include "IByteWriterWithPosition.h" - -#include -#include - -#include "testing/TestIO.h" - -using namespace std; -using namespace PDFHummus; - -int PDFParserInvalidLengthTest(int argc, char* argv[]) -{ - EStatusCode status = PDFHummus::eSuccess; - InputFile pdfFile; - PDFParser parser; - - do - { - status = pdfFile.OpenFile(BuildRelativeInputPath(argv, "InvalidEncryptionLength.pdf")); - if(status != PDFHummus::eSuccess) - { - cout<<"unable to open file for reading. should be in TestMaterials/XObjectContent.pdf\n"; - break; - } - - status = parser.StartPDFParsing(pdfFile.GetInputStream()); - if(status != PDFHummus::eSuccess) - { - cout<<"unable to parse input file"; - break; - } - }while(false); - - return status; -} - -