Skip to content

Commit b9747f7

Browse files
committed
process xor skips when key is zero
1 parent d4830b8 commit b9747f7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

kaitaistruct.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,19 @@ def bytes_terminate(data, term, include_term):
336336

337337
@staticmethod
338338
def process_xor_one(data, key):
339+
if key == 0:
340+
return data
341+
339342
if PY2:
340343
return bytes(bytearray(v ^ key for v in bytearray(data)))
341344
else:
342345
return bytes(v ^ key for v in data)
343346

344347
@staticmethod
345348
def process_xor_many(data, key):
349+
if key == b'\x00' * len(key):
350+
return data
351+
346352
if PY2:
347353
return bytes(bytearray(a ^ b for a, b in zip(bytearray(data), itertools.cycle(bytearray(key)))))
348354
else:

0 commit comments

Comments
 (0)