INCOMPATIBILITY: rename "confirm" phase to "version"
This better reflects the purpose of the message. Key confirmation is a side-effect. This patch only changes the "phase:" name and the key-derivation string. A subsequent patch will modify the function and variable names to match.
This commit is contained in:
parent
424474cd7e
commit
dcdddc9d60
|
@ -232,15 +232,15 @@ class Basic(unittest.TestCase):
|
||||||
out = ws.outbound()
|
out = ws.outbound()
|
||||||
self.assertEqual(len(out), 2, out)
|
self.assertEqual(len(out), 2, out)
|
||||||
self.check_out(out[0], type=u"release")
|
self.check_out(out[0], type=u"release")
|
||||||
self.check_out(out[1], type=u"add", phase=u"confirm")
|
self.check_out(out[1], type=u"add", phase=u"version")
|
||||||
self.assertNoResult(v)
|
self.assertNoResult(v)
|
||||||
|
|
||||||
# hearing a valid confirmation message doesn't throw an error
|
# hearing a valid confirmation message doesn't throw an error
|
||||||
plaintext = json.dumps({}).encode("utf-8")
|
plaintext = json.dumps({}).encode("utf-8")
|
||||||
data_key = w._derive_phase_key(side2, u"confirm")
|
data_key = w._derive_phase_key(side2, u"version")
|
||||||
confmsg = w._encrypt_data(data_key, plaintext)
|
confmsg = w._encrypt_data(data_key, plaintext)
|
||||||
confirm2_hex = hexlify(confmsg).decode("ascii")
|
confirm2_hex = hexlify(confmsg).decode("ascii")
|
||||||
response(w, type=u"message", phase=u"confirm", body=confirm2_hex,
|
response(w, type=u"message", phase=u"version", body=confirm2_hex,
|
||||||
side=side2)
|
side=side2)
|
||||||
|
|
||||||
# and it releases the verifier
|
# and it releases the verifier
|
||||||
|
@ -532,7 +532,7 @@ class Basic(unittest.TestCase):
|
||||||
else:
|
else:
|
||||||
w._key = b"wrongkey"
|
w._key = b"wrongkey"
|
||||||
plaintext = json.dumps({}).encode("utf-8")
|
plaintext = json.dumps({}).encode("utf-8")
|
||||||
data_key = w._derive_phase_key(side2, u"confirm")
|
data_key = w._derive_phase_key(side2, u"version")
|
||||||
confmsg = w._encrypt_data(data_key, plaintext)
|
confmsg = w._encrypt_data(data_key, plaintext)
|
||||||
w._key = None
|
w._key = None
|
||||||
|
|
||||||
|
@ -612,7 +612,7 @@ class Basic(unittest.TestCase):
|
||||||
self.failureResultOf(w.verify(), WelcomeError)
|
self.failureResultOf(w.verify(), WelcomeError)
|
||||||
|
|
||||||
def test_confirm_error(self):
|
def test_confirm_error(self):
|
||||||
# we should only receive the "confirm" message after we receive the
|
# we should only receive the "version" message after we receive the
|
||||||
# PAKE message, by which point we should know the key. If the
|
# PAKE message, by which point we should know the key. If the
|
||||||
# confirmation message doesn't decrypt, we signal an error.
|
# confirmation message doesn't decrypt, we signal an error.
|
||||||
timing = DebugTiming()
|
timing = DebugTiming()
|
||||||
|
@ -646,7 +646,7 @@ class Basic(unittest.TestCase):
|
||||||
nonce = os.urandom(wormhole.CONFMSG_NONCE_LENGTH)
|
nonce = os.urandom(wormhole.CONFMSG_NONCE_LENGTH)
|
||||||
badconfirm = wormhole.make_confmsg(confkey, nonce)
|
badconfirm = wormhole.make_confmsg(confkey, nonce)
|
||||||
badconfirm_hex = hexlify(badconfirm).decode("ascii")
|
badconfirm_hex = hexlify(badconfirm).decode("ascii")
|
||||||
response(w, type=u"message", phase=u"confirm", body=badconfirm_hex,
|
response(w, type=u"message", phase=u"version", body=badconfirm_hex,
|
||||||
side=u"s2")
|
side=u"s2")
|
||||||
|
|
||||||
self.failureResultOf(d1, WrongPasswordError)
|
self.failureResultOf(d1, WrongPasswordError)
|
||||||
|
|
|
@ -558,7 +558,7 @@ class _Wormhole:
|
||||||
# dictionary of version flags to let the other Wormhole know what
|
# dictionary of version flags to let the other Wormhole know what
|
||||||
# we're capable of (for future expansion)
|
# we're capable of (for future expansion)
|
||||||
plaintext = json.dumps(self._my_versions).encode("utf-8")
|
plaintext = json.dumps(self._my_versions).encode("utf-8")
|
||||||
phase = u"confirm"
|
phase = u"version"
|
||||||
data_key = self._derive_phase_key(self._side, phase)
|
data_key = self._derive_phase_key(self._side, phase)
|
||||||
encrypted = self._encrypt_data(data_key, plaintext)
|
encrypted = self._encrypt_data(data_key, plaintext)
|
||||||
self._msg_send(phase, encrypted)
|
self._msg_send(phase, encrypted)
|
||||||
|
@ -588,7 +588,7 @@ class _Wormhole:
|
||||||
|
|
||||||
def _event_received_confirm(self, side, body):
|
def _event_received_confirm(self, side, body):
|
||||||
# We ought to have the master key by now, because sensible peers
|
# We ought to have the master key by now, because sensible peers
|
||||||
# should always send "pake" before sending "confirm". It might be
|
# should always send "pake" before sending "version". It might be
|
||||||
# nice to relax this requirement, which means storing the received
|
# nice to relax this requirement, which means storing the received
|
||||||
# confirmation message, and having _event_established_key call
|
# confirmation message, and having _event_established_key call
|
||||||
# _check_confirmation()
|
# _check_confirmation()
|
||||||
|
@ -603,7 +603,7 @@ class _Wormhole:
|
||||||
self._confirmation_checked = True
|
self._confirmation_checked = True
|
||||||
|
|
||||||
side, body = self._confirmation_message
|
side, body = self._confirmation_message
|
||||||
data_key = self._derive_phase_key(side, u"confirm")
|
data_key = self._derive_phase_key(side, u"version")
|
||||||
try:
|
try:
|
||||||
plaintext = self._decrypt_data(data_key, body)
|
plaintext = self._decrypt_data(data_key, body)
|
||||||
except CryptoError:
|
except CryptoError:
|
||||||
|
@ -717,7 +717,7 @@ class _Wormhole:
|
||||||
|
|
||||||
if phase == u"pake":
|
if phase == u"pake":
|
||||||
return self._event_received_pake(body)
|
return self._event_received_pake(body)
|
||||||
if phase == u"confirm":
|
if phase == u"version":
|
||||||
return self._event_received_confirm(side, body)
|
return self._event_received_confirm(side, body)
|
||||||
if re.search(r'^\d+$', phase):
|
if re.search(r'^\d+$', phase):
|
||||||
return self._event_received_phase_message(side, phase, body)
|
return self._event_received_phase_message(side, phase, body)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user