summaryrefslogtreecommitdiff
path: root/fw/hexnoise.py
diff options
context:
space:
mode:
Diffstat (limited to 'fw/hexnoise.py')
-rwxr-xr-xfw/hexnoise.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/fw/hexnoise.py b/fw/hexnoise.py
index b0217e2..9e9f63a 100755
--- a/fw/hexnoise.py
+++ b/fw/hexnoise.py
@@ -3,6 +3,7 @@
import time
import enum
import os
+import warnings
import sys
import binascii
from contextlib import contextmanager, suppress, wraps
@@ -29,6 +30,7 @@ class PacketType(enum.Enum):
COMM_ERROR = 4
CRYPTO_ERROR = 5
TOO_MANY_FAILS = 6
+ PASSTHROUGH_REPORT = 7
class ReportType(enum.Enum):
_RESERVED = 0
@@ -263,7 +265,7 @@ class NoiseEngine:
self.connected, self.paired = True, False
else:
self.connected, self.paired = True, False
- raise UserWarning(f'Unexpected record type {rtype} in {msg_type} packet. Ignoring.')
+ warnings.warn(f'Unexpected record type {rtype} in {msg_type} packet. Ignoring.')
if self.debug:
print('Handshake finished, handshake hash:')
@@ -281,15 +283,19 @@ class NoiseEngine:
except Exception as e:
self.debug_print('Invalid framing:', e)
- if pkt_type is not PacketType.DATA:
- raise UserWarning(f'Unexpected packet type {pkt_type}. Ignoring.')
+ if pkt_type not in [PacketType.DATA, PacketType.PASSTHROUGH_REPORT]:
+ warnings.warn(f'Unexpected packet type {pkt_type}. Ignoring.')
continue
- rtype, data = self._decrypt(received)
- if self.debug:
- print(f'Decrypted packet {rtype} ({rtype.value}):')
- hexdump(print, data)
- yield rtype, data
+ if pkt_type == PacketType.DATA:
+ rtype, data = self._decrypt(received)
+ if self.debug:
+ print(f'Decrypted packet {rtype} ({rtype.value}):')
+ hexdump(print, data)
+ yield rtype, data
+
+ else: # plaintext passthrough input
+ print('Plaintext report: ', binascii.hexlify(received))
def _decrypt(self, received):
try: