finish renaming "confirm" to "version"

This commit is contained in:
Brian Warner 2016-05-25 19:13:37 -07:00
parent dcdddc9d60
commit 75877effef
2 changed files with 32 additions and 32 deletions

View File

@ -239,8 +239,8 @@ class Basic(unittest.TestCase):
plaintext = json.dumps({}).encode("utf-8") plaintext = json.dumps({}).encode("utf-8")
data_key = w._derive_phase_key(side2, u"version") 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") version2_hex = hexlify(confmsg).decode("ascii")
response(w, type=u"message", phase=u"version", body=confirm2_hex, response(w, type=u"message", phase=u"version", body=version2_hex,
side=side2) side=side2)
# and it releases the verifier # and it releases the verifier
@ -515,7 +515,7 @@ class Basic(unittest.TestCase):
def _test_verifier(self, when, order, success): def _test_verifier(self, when, order, success):
assert when in ("early", "middle", "late") 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) assert isinstance(success, bool)
#print(when, order, success) #print(when, order, success)
@ -540,22 +540,22 @@ class Basic(unittest.TestCase):
d = w.verify() d = w.verify()
self.assertNoResult(d) self.assertNoResult(d)
if order == "key-then-confirm": if order == "key-then-version":
w._key = b"key" w._key = b"key"
w._event_established_key() w._event_established_key()
else: else:
w._event_received_confirm(side2, confmsg) w._event_received_version(side2, confmsg)
if when == "middle": if when == "middle":
d = w.verify() d = w.verify()
if d: if d:
self.assertNoResult(d) # still waiting for other msg self.assertNoResult(d) # still waiting for other msg
if order == "confirm-then-key": if order == "version-then-key":
w._key = b"key" w._key = b"key"
w._event_established_key() w._event_established_key()
else: else:
w._event_received_confirm(side2, confmsg) w._event_received_version(side2, confmsg)
if when == "late": if when == "late":
d = w.verify() d = w.verify()
@ -567,7 +567,7 @@ class Basic(unittest.TestCase):
def test_verifier(self): def test_verifier(self):
for when in ("early", "middle", "late"): 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): for success in (False, True):
self._test_verifier(when, order, success) self._test_verifier(when, order, success)
@ -611,7 +611,7 @@ class Basic(unittest.TestCase):
self.failureResultOf(w.get(), WelcomeError) self.failureResultOf(w.get(), WelcomeError)
self.failureResultOf(w.verify(), 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 # 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.
@ -641,12 +641,12 @@ class Basic(unittest.TestCase):
self.assertNoResult(d1) self.assertNoResult(d1)
self.assertNoResult(d2) # verify() waits for confirmation 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) confkey = w.derive_key(u"WRONG", SecretBox.KEY_SIZE)
nonce = os.urandom(wormhole.CONFMSG_NONCE_LENGTH) nonce = os.urandom(wormhole.CONFMSG_NONCE_LENGTH)
badconfirm = wormhole.make_confmsg(confkey, nonce) badversion = wormhole.make_confmsg(confkey, nonce)
badconfirm_hex = hexlify(badconfirm).decode("ascii") badversion_hex = hexlify(badversion).decode("ascii")
response(w, type=u"message", phase=u"version", body=badconfirm_hex, response(w, type=u"message", phase=u"version", body=badversion_hex,
side=u"s2") side=u"s2")
self.failureResultOf(d1, WrongPasswordError) self.failureResultOf(d1, WrongPasswordError)

View File

@ -39,7 +39,7 @@ def to_bytes(u):
# * early warmup for connection hints ("I can do tor, spin up HS") # * early warmup for connection hints ("I can do tor, spin up HS")
# * wordlist l10n identifier # * wordlist l10n identifier
# phase=pake: just the SPAKE2 'start' message (binary) # 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 # phase=1,2,3,..: application messages
class WSClient(websocket.WebSocketClientProtocol): class WSClient(websocket.WebSocketClientProtocol):
@ -238,8 +238,8 @@ class _Wormhole:
self._flag_need_to_send_PAKE = True self._flag_need_to_send_PAKE = True
self._key = None self._key = None
self._confirmation_message = None self._version_message = None
self._confirmation_checked = False self._version_checked = False
self._get_verifier_called = False self._get_verifier_called = False
self._verifier = None # bytes self._verifier = None # bytes
self._verify_result = None # bytes or a Failure self._verify_result = None # bytes or a Failure
@ -544,16 +544,16 @@ class _Wormhole:
def _event_established_key(self): def _event_established_key(self):
self._timing.add("key established") self._timing.add("key established")
# both sides send different (random) confirmation messages # both sides send different (random) version messages
self._send_confirmation_message() self._send_version_message()
verifier = self._derive_key(b"wormhole:verifier") verifier = self._derive_key(b"wormhole:verifier")
self._event_computed_verifier(verifier) self._event_computed_verifier(verifier)
self._maybe_check_confirmation() self._maybe_check_version()
self._maybe_send_phase_messages() 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 # this is encrypted like a normal phase message, and includes a
# 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)
@ -577,7 +577,7 @@ class _Wormhole:
self._maybe_notify_verify() self._maybe_notify_verify()
def _maybe_notify_verify(self): def _maybe_notify_verify(self):
if not (self._verifier and self._confirmation_checked): if not (self._verifier and self._version_checked):
return return
if self._error: if self._error:
self._verify_result = failure.Failure(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: if self._verifier_waiter and not self._verifier_waiter.called:
self._verifier_waiter.callback(self._verify_result) 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 # We ought to have the master key by now, because sensible peers
# should always send "pake" before sending "version". 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 # version message, and having _event_established_key call
# _check_confirmation() # _check_version()
self._confirmation_message = (side, body) self._version_message = (side, body)
self._maybe_check_confirmation() self._maybe_check_version()
def _maybe_check_confirmation(self): def _maybe_check_version(self):
if not (self._key and self._confirmation_message): if not (self._key and self._version_message):
return return
if self._confirmation_checked: if self._version_checked:
return 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") 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)
@ -718,7 +718,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"version": if phase == u"version":
return self._event_received_confirm(side, body) return self._event_received_version(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)
# ignore unrecognized phases, for forwards-compatibility # ignore unrecognized phases, for forwards-compatibility