From 75877effef66dd93f447010e0672b9b4a21b9bbc Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Wed, 25 May 2016 19:13:37 -0700 Subject: [PATCH] finish renaming "confirm" to "version" --- src/wormhole/test/test_wormhole.py | 26 ++++++++++---------- src/wormhole/wormhole.py | 38 +++++++++++++++--------------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/wormhole/test/test_wormhole.py b/src/wormhole/test/test_wormhole.py index 590eaf6..26c7d87 100644 --- a/src/wormhole/test/test_wormhole.py +++ b/src/wormhole/test/test_wormhole.py @@ -239,8 +239,8 @@ class Basic(unittest.TestCase): plaintext = json.dumps({}).encode("utf-8") data_key = w._derive_phase_key(side2, u"version") confmsg = w._encrypt_data(data_key, plaintext) - confirm2_hex = hexlify(confmsg).decode("ascii") - response(w, type=u"message", phase=u"version", body=confirm2_hex, + version2_hex = hexlify(confmsg).decode("ascii") + response(w, type=u"message", phase=u"version", body=version2_hex, side=side2) # and it releases the verifier @@ -515,7 +515,7 @@ class Basic(unittest.TestCase): def _test_verifier(self, when, order, success): assert when in ("early", "middle", "late") - assert order in ("key-then-confirm", "confirm-then-key") + assert order in ("key-then-version", "version-then-key") assert isinstance(success, bool) #print(when, order, success) @@ -540,22 +540,22 @@ class Basic(unittest.TestCase): d = w.verify() self.assertNoResult(d) - if order == "key-then-confirm": + if order == "key-then-version": w._key = b"key" w._event_established_key() else: - w._event_received_confirm(side2, confmsg) + w._event_received_version(side2, confmsg) if when == "middle": d = w.verify() if d: self.assertNoResult(d) # still waiting for other msg - if order == "confirm-then-key": + if order == "version-then-key": w._key = b"key" w._event_established_key() else: - w._event_received_confirm(side2, confmsg) + w._event_received_version(side2, confmsg) if when == "late": d = w.verify() @@ -567,7 +567,7 @@ class Basic(unittest.TestCase): def test_verifier(self): for when in ("early", "middle", "late"): - for order in ("key-then-confirm", "confirm-then-key"): + for order in ("key-then-version", "version-then-key"): for success in (False, True): self._test_verifier(when, order, success) @@ -611,7 +611,7 @@ class Basic(unittest.TestCase): self.failureResultOf(w.get(), WelcomeError) self.failureResultOf(w.verify(), WelcomeError) - def test_confirm_error(self): + def test_version_error(self): # we should only receive the "version" message after we receive the # PAKE message, by which point we should know the key. If the # confirmation message doesn't decrypt, we signal an error. @@ -641,12 +641,12 @@ class Basic(unittest.TestCase): self.assertNoResult(d1) self.assertNoResult(d2) # verify() waits for confirmation - # sending a random confirm message will cause a confirmation error + # sending a random version message will cause a confirmation error confkey = w.derive_key(u"WRONG", SecretBox.KEY_SIZE) nonce = os.urandom(wormhole.CONFMSG_NONCE_LENGTH) - badconfirm = wormhole.make_confmsg(confkey, nonce) - badconfirm_hex = hexlify(badconfirm).decode("ascii") - response(w, type=u"message", phase=u"version", body=badconfirm_hex, + badversion = wormhole.make_confmsg(confkey, nonce) + badversion_hex = hexlify(badversion).decode("ascii") + response(w, type=u"message", phase=u"version", body=badversion_hex, side=u"s2") self.failureResultOf(d1, WrongPasswordError) diff --git a/src/wormhole/wormhole.py b/src/wormhole/wormhole.py index 09055f6..00833d7 100644 --- a/src/wormhole/wormhole.py +++ b/src/wormhole/wormhole.py @@ -39,7 +39,7 @@ def to_bytes(u): # * early warmup for connection hints ("I can do tor, spin up HS") # * wordlist l10n identifier # phase=pake: just the SPAKE2 'start' message (binary) -# phase=confirm: key verification (HKDF(key, nonce)+nonce) +# phase=version: version data, key verification (HKDF(key, nonce)+nonce) # phase=1,2,3,..: application messages class WSClient(websocket.WebSocketClientProtocol): @@ -238,8 +238,8 @@ class _Wormhole: self._flag_need_to_send_PAKE = True self._key = None - self._confirmation_message = None - self._confirmation_checked = False + self._version_message = None + self._version_checked = False self._get_verifier_called = False self._verifier = None # bytes self._verify_result = None # bytes or a Failure @@ -544,16 +544,16 @@ class _Wormhole: def _event_established_key(self): self._timing.add("key established") - # both sides send different (random) confirmation messages - self._send_confirmation_message() + # both sides send different (random) version messages + self._send_version_message() verifier = self._derive_key(b"wormhole:verifier") self._event_computed_verifier(verifier) - self._maybe_check_confirmation() + self._maybe_check_version() self._maybe_send_phase_messages() - def _send_confirmation_message(self): + def _send_version_message(self): # this is encrypted like a normal phase message, and includes a # dictionary of version flags to let the other Wormhole know what # we're capable of (for future expansion) @@ -577,7 +577,7 @@ class _Wormhole: self._maybe_notify_verify() def _maybe_notify_verify(self): - if not (self._verifier and self._confirmation_checked): + if not (self._verifier and self._version_checked): return if self._error: self._verify_result = failure.Failure(self._error) @@ -586,23 +586,23 @@ class _Wormhole: if self._verifier_waiter and not self._verifier_waiter.called: self._verifier_waiter.callback(self._verify_result) - def _event_received_confirm(self, side, body): + def _event_received_version(self, side, body): # We ought to have the master key by now, because sensible peers # should always send "pake" before sending "version". It might be # nice to relax this requirement, which means storing the received - # confirmation message, and having _event_established_key call - # _check_confirmation() - self._confirmation_message = (side, body) - self._maybe_check_confirmation() + # version message, and having _event_established_key call + # _check_version() + self._version_message = (side, body) + self._maybe_check_version() - def _maybe_check_confirmation(self): - if not (self._key and self._confirmation_message): + def _maybe_check_version(self): + if not (self._key and self._version_message): return - if self._confirmation_checked: + if self._version_checked: return - self._confirmation_checked = True + self._version_checked = True - side, body = self._confirmation_message + side, body = self._version_message data_key = self._derive_phase_key(side, u"version") try: plaintext = self._decrypt_data(data_key, body) @@ -718,7 +718,7 @@ class _Wormhole: if phase == u"pake": return self._event_received_pake(body) if phase == u"version": - return self._event_received_confirm(side, body) + return self._event_received_version(side, body) if re.search(r'^\d+$', phase): return self._event_received_phase_message(side, phase, body) # ignore unrecognized phases, for forwards-compatibility