Unverified Commit ab0fef0d by Marcus T Committed by GitHub

Actually implement exponent and shift operators

These operators are listed in the "Signature File Format" wiki page but don't actually exist.
parent 3154b001
...@@ -97,7 +97,7 @@ class SignatureLine(object): ...@@ -97,7 +97,7 @@ class SignatureLine(object):
# AND the data with 0xFF before the comparison is performed). # AND the data with 0xFF before the comparison is performed).
# #
# We support the following operators: # We support the following operators:
for operator in ['&', '|', '*', '+', '-', '/', '~', '^']: for operator in ['**', '<<', '>>', '&', '|', '*', '+', '-', '/', '~', '^']:
# Look for each operator in self.type # Look for each operator in self.type
if operator in self.type: if operator in self.type:
# If found, split self.type into the type and operator value # If found, split self.type into the type and operator value
...@@ -632,7 +632,13 @@ class Magic(object): ...@@ -632,7 +632,13 @@ class Magic(object):
opval = self._do_math(offset, line.opvalue) opval = self._do_math(offset, line.opvalue)
# Perform the specified operation # Perform the specified operation
if line.operator == '&': if line.operator == '**':
dvalue **= opval
elif line.operator == '<<':
dvalue <<= opval
elif line.operator == '>>':
dvalue >>= opval
elif line.operator == '&':
dvalue &= opval dvalue &= opval
elif line.operator == '|': elif line.operator == '|':
dvalue |= opval dvalue |= opval
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment