@@ -4210,7 +4210,7 @@ def ReadFileHeaderDataWithContent(fp, listonly=False, uncompress=True, skipcheck
42104210 pass
42114211 fp.seek(len(delimiter), 1)
42124212 jsonfcs = GetFileChecksum(fprejsoncontent, fjsonchecksumtype, True, formatspecs)
4213- if(jsonfcs != fjsonchecksum and not skipchecksum):
4213+ if(not hmac.compare_digest( fjsonchecksum, jsonfcs) and not skipchecksum):
42144214 VerbosePrintOut("File JSON Data Checksum Error with file " +
42154215 fname + " at offset " + str(fheaderstart))
42164216 VerbosePrintOut("'" + fjsonchecksum + "' != " + "'" + jsonfcs + "'")
@@ -4239,7 +4239,7 @@ def ReadFileHeaderDataWithContent(fp, listonly=False, uncompress=True, skipcheck
42394239 newfccs = GetFileChecksum(
42404240 fcontents, HeaderOut[-3].lower(), False, formatspecs)
42414241 fcontents.seek(0, 0)
4242- if(fccs != newfccs and not skipchecksum and not listonly):
4242+ if(not hmac.compare_digest( fccs, newfccs) and not skipchecksum and not listonly):
42434243 VerbosePrintOut("File Content Checksum Error with file " +
42444244 fname + " at offset " + str(fcontentstart))
42454245 VerbosePrintOut("'" + fccs + "' != " + "'" + newfccs + "'")
@@ -4411,7 +4411,7 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
44114411 fp.seek(len(delimiter), 1)
44124412 fjend = fp.tell() - 1
44134413 jsonfcs = GetFileChecksum(fprejsoncontent, fjsonchecksumtype, True, formatspecs)
4414- if(jsonfcs != fjsonchecksum and not skipchecksum):
4414+ if(not hmac.compare_digest( fjsonchecksum, jsonfcs) and not skipchecksum):
44154415 VerbosePrintOut("File JSON Data Checksum Error with file " +
44164416 fname + " at offset " + str(fheaderstart))
44174417 VerbosePrintOut("'" + fjsonchecksum + "' != " + "'" + jsonfcs + "'")
@@ -4445,7 +4445,7 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
44454445 newfccs = GetFileChecksum(
44464446 fcontents, HeaderOut[-3].lower(), False, formatspecs)
44474447 fcontents.seek(0, 0)
4448- if(fccs != newfccs and not skipchecksum and not listonly):
4448+ if(not hmac.compare_digest( fccs, newfccs) and not skipchecksum and not listonly):
44494449 VerbosePrintOut("File Content Checksum Error with file " +
44504450 fname + " at offset " + str(fcontentstart))
44514451 VerbosePrintOut("'" + fccs + "' != " + "'" + newfccs + "'")
@@ -4623,7 +4623,7 @@ def ReadFileHeaderDataWithContentToList(fp, listonly=False, contentasfile=False,
46234623 pass
46244624 fp.seek(len(delimiter), 1)
46254625 jsonfcs = GetFileChecksum(fprejsoncontent, fjsonchecksumtype, True, formatspecs)
4626- if(jsonfcs != fjsonchecksum and not skipchecksum):
4626+ if(not hmac.compare_digest( fjsonchecksum, jsonfcs) and not skipchecksum):
46274627 VerbosePrintOut("File JSON Data Checksum Error with file " +
46284628 fname + " at offset " + str(fheaderstart))
46294629 VerbosePrintOut("'" + fjsonchecksum + "' != " + "'" + jsonfcs + "'")
@@ -4656,7 +4656,7 @@ def ReadFileHeaderDataWithContentToList(fp, listonly=False, contentasfile=False,
46564656 fcontents.seek(0, 0)
46574657 newfccs = GetFileChecksum(
46584658 fcontents, HeaderOut[-3].lower(), False, formatspecs)
4659- if(fccs != newfccs and not skipchecksum and not listonly):
4659+ if(not hmac.compare_digest( fccs, newfccs) and not skipchecksum and not listonly):
46604660 VerbosePrintOut("File Content Checksum Error with file " +
46614661 fname + " at offset " + str(fcontentstart))
46624662 VerbosePrintOut("'" + fccs + "' != " + "'" + newfccs + "'")
@@ -4840,15 +4840,15 @@ def ReadFileDataWithContentToArray(fp, filestart=0, seekstart=0, seekend=0, list
48404840 prejsoncontent = fp.read(prefjsonsize).decode("UTF-8")
48414841 fp.seek(len(delimiter), 1)
48424842 prejsonfcs = GetFileChecksum(prejsoncontent, prefjsonchecksumtype, True, formatspecs)
4843- if(prejsonfcs != prefjsonchecksum and not skipchecksum):
4843+ if(not hmac.compare_digest( prefjsonchecksum, prejsonfcs) and not skipchecksum):
48444844 VerbosePrintOut("File JSON Data Checksum Error with file " +
48454845 prefname + " at offset " + str(prefhstart))
48464846 VerbosePrintOut("'" + prefjsonchecksum + "' != " + "'" + prejsonfcs + "'")
48474847 return False
48484848 prenewfcs = GetHeaderChecksum(
48494849 preheaderdata[:-2], preheaderdata[-4].lower(), True, formatspecs)
48504850 prefcs = preheaderdata[-2]
4851- if(prefcs != prenewfcs and not skipchecksum):
4851+ if(not hmac.compare_digest( prefcs, prenewfcs) and not skipchecksum):
48524852 VerbosePrintOut("File Header Checksum Error with file " +
48534853 prefname + " at offset " + str(prefhstart))
48544854 VerbosePrintOut("'" + prefcs + "' != " +
@@ -4867,7 +4867,7 @@ def ReadFileDataWithContentToArray(fp, filestart=0, seekstart=0, seekend=0, list
48674867 prefcontents, preheaderdata[-3].lower(), False, formatspecs)
48684868 prefccs = preheaderdata[-1]
48694869 pyhascontents = True
4870- if(prefccs != prenewfccs and not skipchecksum):
4870+ if(not hmac.compare_digest( prefccs, prenewfccs) and not skipchecksum):
48714871 VerbosePrintOut("File Content Checksum Error with file " +
48724872 prefname + " at offset " + str(prefcontentstart))
48734873 VerbosePrintOut("'" + prefccs +
@@ -5001,7 +5001,7 @@ def ReadFileDataWithContentToList(fp, filestart=0, seekstart=0, seekend=0, listo
50015001 prefprejsoncontent = fp.read(prefjsonsize).decode("UTF-8")
50025002 fp.seek(len(delimiter), 1)
50035003 prejsonfcs = GetFileChecksum(prefprejsoncontent, prefjsonchecksumtype, True, formatspecs)
5004- if(prejsonfcs != prefjsonchecksum and not skipchecksum):
5004+ if(not hmac.compare_digest( prefjsonchecksum, prejsonfcs) and not skipchecksum):
50055005 VerbosePrintOut("File JSON Data Checksum Error with file " +
50065006 prefname + " at offset " + str(prefhstart))
50075007 VerbosePrintOut("'" + prefjsonchecksum + "' != " + "'" + prejsonfcs + "'")
@@ -5030,7 +5030,7 @@ def ReadFileDataWithContentToList(fp, filestart=0, seekstart=0, seekend=0, listo
50305030 prefcontents, preheaderdata[-3].lower(), False, formatspecs)
50315031 prefccs = preheaderdata[-1]
50325032 pyhascontents = True
5033- if(prefccs != prenewfccs and not skipchecksum):
5033+ if(not hmac.compare_digest(prefcs, prenewfcs) and not skipchecksum):
50345034 VerbosePrintOut("File Content Checksum Error with file " +
50355035 prefname + " at offset " + str(prefcontentstart))
50365036 VerbosePrintOut("'" + prefccs +
@@ -9561,7 +9561,7 @@ def FoxFileValidate(infile, fmttype="auto", filestart=0,
95619561 VerbosePrintOut(outfname)
95629562 VerbosePrintOut("Record Number " + str(il) + "; File ID " + str(fid) + "; iNode Number " + str(finode))
95639563
9564- if(hmac.compare_digest(infcs, outfcs )):
9564+ if(hmac.compare_digest(outfcs, infcs )):
95659565 if(verbose):
95669566 VerbosePrintOut("File Header Checksum Passed at offset " + str(outfhstart))
95679567 VerbosePrintOut("'" + outfcs + "' == " + "'" + infcs + "'")
@@ -9597,7 +9597,7 @@ def FoxFileValidate(infile, fmttype="auto", filestart=0,
95979597 infccs = GetFileChecksum(outfcontents, inheaderdata[-3].lower(), False, formatspecs)
95989598 pyhascontents = True
95999599
9600- if(outfccs == infccs):
9600+ if(hmac.compare_digest( outfccs, infccs) ):
96019601 if(verbose):
96029602 VerbosePrintOut("File Content Checksum Passed at offset " + str(outfcontentstart))
96039603 VerbosePrintOut("'" + outfccs + "' == " + "'" + infccs + "'")
0 commit comments