deallocate channel even if key-exchange fails (wrong password)

This commit is contained in:
Brian Warner 2015-02-14 18:50:31 -08:00
parent 0474cc18d5
commit bc1b367f06

View File

@ -104,15 +104,16 @@ class Initiator(Common):
def get_data(self): def get_data(self):
key = self._poll_pake([]) key = self._poll_pake([])
outbound_key = HKDF(key, SecretBox.KEY_SIZE, CTXinfo=b"sender") try:
outbound_encrypted = self._encrypt_data(outbound_key, self.data) outbound_key = HKDF(key, SecretBox.KEY_SIZE, CTXinfo=b"sender")
other_msgs = self._post_data(outbound_encrypted) outbound_encrypted = self._encrypt_data(outbound_key, self.data)
other_msgs = self._post_data(outbound_encrypted)
inbound_encrypted = self._poll_data(other_msgs) inbound_encrypted = self._poll_data(other_msgs)
inbound_key = HKDF(key, SecretBox.KEY_SIZE, CTXinfo=b"receiver") inbound_key = HKDF(key, SecretBox.KEY_SIZE, CTXinfo=b"receiver")
inbound_data = self._decrypt_data(inbound_key, inbound_encrypted) inbound_data = self._decrypt_data(inbound_key, inbound_encrypted)
finally:
self._deallocate() self._deallocate()
return inbound_data return inbound_data
@ -142,13 +143,14 @@ class Receiver(Common):
other_msgs = self._post_pake() other_msgs = self._post_pake()
key = self._poll_pake(other_msgs) key = self._poll_pake(other_msgs)
outbound_key = HKDF(key, SecretBox.KEY_SIZE, CTXinfo=b"receiver") try:
outbound_encrypted = self._encrypt_data(outbound_key, self.data) outbound_key = HKDF(key, SecretBox.KEY_SIZE, CTXinfo=b"receiver")
other_msgs = self._post_data(outbound_encrypted) outbound_encrypted = self._encrypt_data(outbound_key, self.data)
other_msgs = self._post_data(outbound_encrypted)
inbound_encrypted = self._poll_data(other_msgs) inbound_encrypted = self._poll_data(other_msgs)
inbound_key = HKDF(key, SecretBox.KEY_SIZE, CTXinfo=b"sender") inbound_key = HKDF(key, SecretBox.KEY_SIZE, CTXinfo=b"sender")
inbound_data = self._decrypt_data(inbound_key, inbound_encrypted) inbound_data = self._decrypt_data(inbound_key, inbound_encrypted)
finally:
self._deallocate() self._deallocate()
return inbound_data return inbound_data