From 49c36b0277e1dabb3661442771c5468af734af6a Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Sun, 11 Aug 2019 19:51:21 -0700 Subject: [PATCH] dilation side needs to be 16-chars to match transit relay --- src/wormhole/_dilation/connector.py | 4 +++- src/wormhole/_dilation/manager.py | 2 +- src/wormhole/test/dilate/test_manager.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/wormhole/_dilation/connector.py b/src/wormhole/_dilation/connector.py index 320ae43..2ccd080 100644 --- a/src/wormhole/_dilation/connector.py +++ b/src/wormhole/_dilation/connector.py @@ -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") diff --git a/src/wormhole/_dilation/manager.py b/src/wormhole/_dilation/manager.py index 19430bb..5e2c4df 100644 --- a/src/wormhole/_dilation/manager.py +++ b/src/wormhole/_dilation/manager.py @@ -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: diff --git a/src/wormhole/test/dilate/test_manager.py b/src/wormhole/test/dilate/test_manager.py index 3fdd051..d8aa8ab 100644 --- a/src/wormhole/test/dilate/test_manager.py +++ b/src/wormhole/test/dilate/test_manager.py @@ -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()