From 4bfe14d3cfce03d77c61d6d257319779d9fe4d75 Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Tue, 7 Aug 2007 07:42:31 +0000 Subject: [PATCH] prompt with SAS during 3 message negotiation --- src/chat_control.py | 3 ++- src/common/stanza_session.py | 14 +++++++++----- src/gajim.py | 4 ++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/chat_control.py b/src/chat_control.py index ec04c7bb7..bc21d4599 100644 --- a/src/chat_control.py +++ b/src/chat_control.py @@ -1957,7 +1957,8 @@ class ChatControl(ChatControlBase): if not self.session: self.session = gajim.connections[self.account].make_new_session(self.contact.jid) - self.session.negotiate_e2e() + # XXX decide whether to use 4 or 3 message negotiation + self.session.negotiate_e2e(False) def got_connected(self): ChatControlBase.got_connected(self) diff --git a/src/common/stanza_session.py b/src/common/stanza_session.py index 1c3d30328..d2a2dc4eb 100644 --- a/src/common/stanza_session.py +++ b/src/common/stanza_session.py @@ -330,7 +330,7 @@ class EncryptedStanzaSession(StanzaSession): # if none exists, prompt the user with the SAS if self.sas_algs == 'sas28x5': self.sas = self.sas_28x5(m_a, self.form_b) - + mac_a = self.decrypt(id_a) form_a2 = self.c7lize_mac_id(form) @@ -357,8 +357,8 @@ class EncryptedStanzaSession(StanzaSession): content = self.n_s + self.n_o + self.encode_mpi(self.d) + pubkey_b if sigmai: - form_b = c7l_form - content += form_b + self.form_b = c7l_form + content += self.form_b else: form_b2 = c7l_form content += self.form_b + form_b2 @@ -383,6 +383,9 @@ class EncryptedStanzaSession(StanzaSession): # if none exists, prompt the user with the SAS if self.sas_algs == 'sas28x5': self.sas = self.sas_28x5(m_a, self.form_b) + + if self.sigmai: + self.check_identity() return (xmpp.DataField(name='identity', value=base64.b64encode(id_a)), \ xmpp.DataField(name='mac', value=base64.b64encode(m_a))) @@ -606,8 +609,6 @@ class EncryptedStanzaSession(StanzaSession): self.negotiated = negotiated - self.form_b = ''.join(map(lambda el: xmpp.c14n.c14n(el), form.getChildren())) - accept = xmpp.Message() feature = accept.NT.feature feature.setNamespace(xmpp.NS_FEATURE) @@ -647,6 +648,9 @@ class EncryptedStanzaSession(StanzaSession): rshashes = [base64.b64encode(rshash) for rshash in rshashes] result.addChild(node=xmpp.DataField(name='rshashes', value=rshashes)) result.addChild(node=xmpp.DataField(name='dhkeys', value=base64.b64encode(self.encode_mpi(e)))) + + self.form_b = ''.join(map(lambda el: xmpp.c14n.c14n(el), form.getChildren())) + # MUST securely destroy K unless it will be used later to generate the final shared secret diff --git a/src/gajim.py b/src/gajim.py index b18d4c792..15647a26a 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -1765,11 +1765,15 @@ class Interface: elif session.status == 'requested-e2e' and form.getType() == 'submit': negotiated, not_acceptable, ask_user = session.verify_options_alice(form) + if session.sigmai: + session.check_identity = lambda: negotiation.show_sas_dialog(jid, session.sas) + if ask_user: def accept_nondefault_options(widget): dialog.destroy() negotiated.update(ask_user) + session.accept_e2e_alice(form, negotiated) def reject_nondefault_options(widget):