@@ -4202,7 +4202,7 @@ def ReadFileHeaderDataWithContent(fp, listonly=False, uncompress=True, skipcheck
42024202 pass
42034203 fp.seek(len(delimiter), 1)
42044204 jsonfcs = GetFileChecksum(fprejsoncontent, fjsonchecksumtype, True, formatspecs)
4205- if(jsonfcs != fjsonchecksum and not skipchecksum):
4205+ if(not hmac.compare_digest( fjsonchecksum, jsonfcs) and not skipchecksum):
42064206 VerbosePrintOut("File JSON Data Checksum Error with file " +
42074207 fname + " at offset " + str(fheaderstart))
42084208 VerbosePrintOut("'" + fjsonchecksum + "' != " + "'" + jsonfcs + "'")
@@ -4231,7 +4231,7 @@ def ReadFileHeaderDataWithContent(fp, listonly=False, uncompress=True, skipcheck
42314231 newfccs = GetFileChecksum(
42324232 fcontents, HeaderOut[-3].lower(), False, formatspecs)
42334233 fcontents.seek(0, 0)
4234- if(fccs != newfccs and not skipchecksum and not listonly):
4234+ if(not hmac.compare_digest( fccs, newfccs) and not skipchecksum and not listonly):
42354235 VerbosePrintOut("File Content Checksum Error with file " +
42364236 fname + " at offset " + str(fcontentstart))
42374237 VerbosePrintOut("'" + fccs + "' != " + "'" + newfccs + "'")
@@ -4403,7 +4403,7 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
44034403 fp.seek(len(delimiter), 1)
44044404 fjend = fp.tell() - 1
44054405 jsonfcs = GetFileChecksum(fprejsoncontent, fjsonchecksumtype, True, formatspecs)
4406- if(jsonfcs != fjsonchecksum and not skipchecksum):
4406+ if(not hmac.compare_digest( fjsonchecksum, jsonfcs) and not skipchecksum):
44074407 VerbosePrintOut("File JSON Data Checksum Error with file " +
44084408 fname + " at offset " + str(fheaderstart))
44094409 VerbosePrintOut("'" + fjsonchecksum + "' != " + "'" + jsonfcs + "'")
@@ -4437,7 +4437,7 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
44374437 newfccs = GetFileChecksum(
44384438 fcontents, HeaderOut[-3].lower(), False, formatspecs)
44394439 fcontents.seek(0, 0)
4440- if(fccs != newfccs and not skipchecksum and not listonly):
4440+ if(not hmac.compare_digest( fccs, newfccs) and not skipchecksum and not listonly):
44414441 VerbosePrintOut("File Content Checksum Error with file " +
44424442 fname + " at offset " + str(fcontentstart))
44434443 VerbosePrintOut("'" + fccs + "' != " + "'" + newfccs + "'")
@@ -4615,7 +4615,7 @@ def ReadFileHeaderDataWithContentToList(fp, listonly=False, contentasfile=False,
46154615 pass
46164616 fp.seek(len(delimiter), 1)
46174617 jsonfcs = GetFileChecksum(fprejsoncontent, fjsonchecksumtype, True, formatspecs)
4618- if(jsonfcs != fjsonchecksum and not skipchecksum):
4618+ if(not hmac.compare_digest( fjsonchecksum, jsonfcs) and not skipchecksum):
46194619 VerbosePrintOut("File JSON Data Checksum Error with file " +
46204620 fname + " at offset " + str(fheaderstart))
46214621 VerbosePrintOut("'" + fjsonchecksum + "' != " + "'" + jsonfcs + "'")
@@ -4648,7 +4648,7 @@ def ReadFileHeaderDataWithContentToList(fp, listonly=False, contentasfile=False,
46484648 fcontents.seek(0, 0)
46494649 newfccs = GetFileChecksum(
46504650 fcontents, HeaderOut[-3].lower(), False, formatspecs)
4651- if(fccs != newfccs and not skipchecksum and not listonly):
4651+ if(not hmac.compare_digest( fccs, newfccs) and not skipchecksum and not listonly):
46524652 VerbosePrintOut("File Content Checksum Error with file " +
46534653 fname + " at offset " + str(fcontentstart))
46544654 VerbosePrintOut("'" + fccs + "' != " + "'" + newfccs + "'")
@@ -4832,15 +4832,15 @@ def ReadFileDataWithContentToArray(fp, filestart=0, seekstart=0, seekend=0, list
48324832 prejsoncontent = fp.read(prefjsonsize).decode("UTF-8")
48334833 fp.seek(len(delimiter), 1)
48344834 prejsonfcs = GetFileChecksum(prejsoncontent, prefjsonchecksumtype, True, formatspecs)
4835- if(prejsonfcs != prefjsonchecksum and not skipchecksum):
4835+ if(not hmac.compare_digest( prefjsonchecksum, prejsonfcs) and not skipchecksum):
48364836 VerbosePrintOut("File JSON Data Checksum Error with file " +
48374837 prefname + " at offset " + str(prefhstart))
48384838 VerbosePrintOut("'" + prefjsonchecksum + "' != " + "'" + prejsonfcs + "'")
48394839 return False
48404840 prenewfcs = GetHeaderChecksum(
48414841 preheaderdata[:-2], preheaderdata[-4].lower(), True, formatspecs)
48424842 prefcs = preheaderdata[-2]
4843- if(prefcs != prenewfcs and not skipchecksum):
4843+ if(not hmac.compare_digest( prefcs, prenewfcs) and not skipchecksum):
48444844 VerbosePrintOut("File Header Checksum Error with file " +
48454845 prefname + " at offset " + str(prefhstart))
48464846 VerbosePrintOut("'" + prefcs + "' != " +
@@ -4859,7 +4859,7 @@ def ReadFileDataWithContentToArray(fp, filestart=0, seekstart=0, seekend=0, list
48594859 prefcontents, preheaderdata[-3].lower(), False, formatspecs)
48604860 prefccs = preheaderdata[-1]
48614861 pyhascontents = True
4862- if(prefccs != prenewfccs and not skipchecksum):
4862+ if(not hmac.compare_digest( prefccs, prenewfccs) and not skipchecksum):
48634863 VerbosePrintOut("File Content Checksum Error with file " +
48644864 prefname + " at offset " + str(prefcontentstart))
48654865 VerbosePrintOut("'" + prefccs +
@@ -4993,15 +4993,15 @@ def ReadFileDataWithContentToList(fp, filestart=0, seekstart=0, seekend=0, listo
49934993 prefprejsoncontent = fp.read(prefjsonsize).decode("UTF-8")
49944994 fp.seek(len(delimiter), 1)
49954995 prejsonfcs = GetFileChecksum(prefprejsoncontent, prefjsonchecksumtype, True, formatspecs)
4996- if(prejsonfcs != prefjsonchecksum and not skipchecksum):
4996+ if(not hmac.compare_digest( prefjsonchecksum, prejsonfcs) and not skipchecksum):
49974997 VerbosePrintOut("File JSON Data Checksum Error with file " +
49984998 prefname + " at offset " + str(prefhstart))
49994999 VerbosePrintOut("'" + prefjsonchecksum + "' != " + "'" + prejsonfcs + "'")
50005000 return False
50015001 prenewfcs = GetHeaderChecksum(
50025002 preheaderdata[:-2], preheaderdata[-4].lower(), True, formatspecs)
50035003 prefcs = preheaderdata[-2]
5004- if(prefcs != prenewfcs and not skipchecksum):
5004+ if(not hmac.compare_digest( prefcs, prenewfcs) and not skipchecksum):
50055005 VerbosePrintOut("File Header Checksum Error with file " +
50065006 prefname + " at offset " + str(prefhstart))
50075007 VerbosePrintOut("'" + prefcs + "' != " +
@@ -5022,7 +5022,7 @@ def ReadFileDataWithContentToList(fp, filestart=0, seekstart=0, seekend=0, listo
50225022 prefcontents, preheaderdata[-3].lower(), False, formatspecs)
50235023 prefccs = preheaderdata[-1]
50245024 pyhascontents = True
5025- if(prefccs != prenewfccs and not skipchecksum):
5025+ if(not hmac.compare_digest( prefccs, prenewfccs) and not skipchecksum):
50265026 VerbosePrintOut("File Content Checksum Error with file " +
50275027 prefname + " at offset " + str(prefcontentstart))
50285028 VerbosePrintOut("'" + prefccs +
@@ -9553,7 +9553,7 @@ def ArchiveFileValidate(infile, fmttype="auto", filestart=0,
95539553 VerbosePrintOut(outfname)
95549554 VerbosePrintOut("Record Number " + str(il) + "; File ID " + str(fid) + "; iNode Number " + str(finode))
95559555
9556- if(hmac.compare_digest(infcs, outfcs )):
9556+ if(hmac.compare_digest(outfcs, infcs )):
95579557 if(verbose):
95589558 VerbosePrintOut("File Header Checksum Passed at offset " + str(outfhstart))
95599559 VerbosePrintOut("'" + outfcs + "' == " + "'" + infcs + "'")
@@ -9589,7 +9589,7 @@ def ArchiveFileValidate(infile, fmttype="auto", filestart=0,
95899589 infccs = GetFileChecksum(outfcontents, inheaderdata[-3].lower(), False, formatspecs)
95909590 pyhascontents = True
95919591
9592- if(outfccs == infccs):
9592+ if(hmac.compare_digest( outfccs, infccs) ):
95939593 if(verbose):
95949594 VerbosePrintOut("File Content Checksum Passed at offset " + str(outfcontentstart))
95959595 VerbosePrintOut("'" + outfccs + "' == " + "'" + infccs + "'")
0 commit comments