Turns out there's a bit of code that isn't compatible w/ the Python version,
eliminate it... This was to support encoding lengths (via negative length
parameters)...
Also, the default C version (which we want to use) is Keccak(800) and not
Keccak(1600), switch Python to 800, as it'll be faster on the 32-bit uC, and
still has plenty of security margin...
The old method would introduce a race condition where the buffer
could be overwritten before the data was consumed. For slow, single
character typing this was fine, but w/ packets being generated by
a computer, this would cause corruption of the incoming data..
symbols defined by the linker script are all treated as addresses, so
we need to get the address, and cast it to an integer for the length
case..
The return value must be used, but as we init early on, we don't need
to check it, so just hide the error w/ an inline function..
a lot more will need to be added as we go on..
This was pulled from heltec's PingPong example, but all licenses
are free.. Also, the files were cleaned up, that is CRs removed,
and trailing white space removed from lines...
This can be useful for doing trial receptions of messages, and
if they work, update the state when successful... Setting the
state on the old object is best as it's hard to change all references
to the new object..
copyof = strb.copy()
try:
copyof.recv_enc(msg)
copyof.recv_mac(mac)
except AuthenticationFailed: # failed, ignore message
return
else: # it worked
strb.set_state_from(copyof)
<process msg>