dilation side needs to be 16-chars to match transit relay

This commit is contained in:
Brian Warner 2019-08-11 19:51:21 -07:00
parent 840dfa603b
commit 49c36b0277
3 changed files with 5 additions and 3 deletions

View File

@ -28,7 +28,9 @@ from ._noise import NoiseConnection
def build_sided_relay_handshake(key, side):
assert isinstance(side, type(u""))
assert len(side) == 8 * 2
# magic-wormhole-transit-relay expects a specific layout for the
# handshake message: "please relay {64} for side {16}\n"
assert len(side) == 8 * 2, side
token = HKDF(key, 32, CTXinfo=b"transit_relay_token")
return (b"please relay " + hexlify(token) +
b" for side " + side.encode("ascii") + b"\n")

View File

@ -65,7 +65,7 @@ class EndpointRecord(Sequence):
return (self.control, self.connect, self.listen)[n]
def make_side():
return bytes_to_hexstr(os.urandom(6))
return bytes_to_hexstr(os.urandom(8))
# new scheme:

View File

@ -216,7 +216,7 @@ class TestManager(unittest.TestCase):
def test_make_side(self):
side = make_side()
self.assertEqual(type(side), type(u""))
self.assertEqual(len(side), 2 * 6)
self.assertEqual(len(side), 2 * 8)
def test_create(self):
m, h = make_manager()