Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Weblate
gajim
Commits
4cfd56a6
Commit
4cfd56a6
authored
15 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
add a workarround for backward compatibility about esession. see #4396
parent
678e3807
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/common/stanza_session.py
+25
-7
25 additions, 7 deletions
src/common/stanza_session.py
src/common/xmpp/c14n.py
+3
-3
3 additions, 3 deletions
src/common/xmpp/c14n.py
with
28 additions
and
10 deletions
src/common/stanza_session.py
+
25
−
7
View file @
4cfd56a6
...
@@ -215,6 +215,18 @@ class EncryptedStanzaSession(StanzaSession):
...
@@ -215,6 +215,18 @@ class EncryptedStanzaSession(StanzaSession):
# has the remote contact's identity ever been verified?
# has the remote contact's identity ever been verified?
self
.
verified_identity
=
False
self
.
verified_identity
=
False
def
_get_contact
(
self
):
c
=
gajim
.
contacts
.
get_contact
(
self
.
conn
.
name
,
self
.
jid
,
self
.
resource
)
if
not
c
:
c
=
gajim
.
contacts
.
get_contact
(
self
.
conn
.
name
,
self
.
jid
)
return
c
def
_is_buggy_gajim
(
self
):
c
=
self
.
_get_contact
()
if
gajim
.
capscache
.
is_supported
(
c
,
xmpp
.
NS_ROSTERX
):
return
False
return
True
def
set_kc_s
(
self
,
value
):
def
set_kc_s
(
self
,
value
):
'''
'''
keep the encrypter updated with my latest cipher key
keep the encrypter updated with my latest cipher key
...
@@ -376,7 +388,8 @@ class EncryptedStanzaSession(StanzaSession):
...
@@ -376,7 +388,8 @@ class EncryptedStanzaSession(StanzaSession):
def
c7lize_mac_id
(
self
,
form
):
def
c7lize_mac_id
(
self
,
form
):
kids
=
form
.
getChildren
()
kids
=
form
.
getChildren
()
macable
=
[
x
for
x
in
kids
if
x
.
getVar
()
not
in
(
'
mac
'
,
'
identity
'
)]
macable
=
[
x
for
x
in
kids
if
x
.
getVar
()
not
in
(
'
mac
'
,
'
identity
'
)]
return
''
.
join
(
xmpp
.
c14n
.
c14n
(
el
)
for
el
in
macable
)
return
''
.
join
(
xmpp
.
c14n
.
c14n
(
el
,
self
.
_is_buggy_gajim
())
for
el
in
\
macable
)
def
verify_identity
(
self
,
form
,
dh_i
,
sigmai
,
i_o
):
def
verify_identity
(
self
,
form
,
dh_i
,
sigmai
,
i_o
):
m_o
=
base64
.
b64decode
(
form
[
'
mac
'
])
m_o
=
base64
.
b64decode
(
form
[
'
mac
'
])
...
@@ -409,7 +422,7 @@ class EncryptedStanzaSession(StanzaSession):
...
@@ -409,7 +422,7 @@ class EncryptedStanzaSession(StanzaSession):
keyvalue
.
getTagData
(
x
)))
for
x
in
(
'
Modulus
'
,
'
Exponent
'
))
keyvalue
.
getTagData
(
x
)))
for
x
in
(
'
Modulus
'
,
'
Exponent
'
))
eir_pubkey
=
RSA
.
construct
((
n
,
long
(
e
)))
eir_pubkey
=
RSA
.
construct
((
n
,
long
(
e
)))
pubkey_o
=
xmpp
.
c14n
.
c14n
(
keyvalue
)
pubkey_o
=
xmpp
.
c14n
.
c14n
(
keyvalue
,
self
.
_is_buggy_gajim
()
)
else
:
else
:
# FIXME DSA, etc.
# FIXME DSA, etc.
raise
NotImplementedError
()
raise
NotImplementedError
()
...
@@ -459,7 +472,8 @@ class EncryptedStanzaSession(StanzaSession):
...
@@ -459,7 +472,8 @@ class EncryptedStanzaSession(StanzaSession):
else
:
else
:
pubkey_s
=
''
pubkey_s
=
''
form_s2
=
''
.
join
(
xmpp
.
c14n
.
c14n
(
el
)
for
el
in
form
.
getChildren
())
form_s2
=
''
.
join
(
xmpp
.
c14n
.
c14n
(
el
,
self
.
_is_buggy_gajim
())
for
el
in
\
form
.
getChildren
())
old_c_s
=
self
.
c_s
old_c_s
=
self
.
c_s
content
=
self
.
n_o
+
self
.
n_s
+
crypto
.
encode_mpi
(
dh_i
)
+
pubkey_s
+
\
content
=
self
.
n_o
+
self
.
n_s
+
crypto
.
encode_mpi
(
dh_i
)
+
pubkey_s
+
\
...
@@ -560,7 +574,8 @@ class EncryptedStanzaSession(StanzaSession):
...
@@ -560,7 +574,8 @@ class EncryptedStanzaSession(StanzaSession):
x
.
addChild
(
node
=
self
.
make_dhfield
(
modp_options
,
sigmai
))
x
.
addChild
(
node
=
self
.
make_dhfield
(
modp_options
,
sigmai
))
self
.
sigmai
=
sigmai
self
.
sigmai
=
sigmai
self
.
form_s
=
''
.
join
(
xmpp
.
c14n
.
c14n
(
el
)
for
el
in
x
.
getChildren
())
self
.
form_s
=
''
.
join
(
xmpp
.
c14n
.
c14n
(
el
,
self
.
_is_buggy_gajim
())
for
el
\
in
x
.
getChildren
())
feature
.
addChild
(
node
=
x
)
feature
.
addChild
(
node
=
x
)
...
@@ -689,8 +704,10 @@ class EncryptedStanzaSession(StanzaSession):
...
@@ -689,8 +704,10 @@ class EncryptedStanzaSession(StanzaSession):
b64ed
=
base64
.
b64encode
(
to_add
[
name
])
b64ed
=
base64
.
b64encode
(
to_add
[
name
])
x
.
addChild
(
node
=
xmpp
.
DataField
(
name
=
name
,
value
=
b64ed
))
x
.
addChild
(
node
=
xmpp
.
DataField
(
name
=
name
,
value
=
b64ed
))
self
.
form_o
=
''
.
join
(
xmpp
.
c14n
.
c14n
(
el
)
for
el
in
form
.
getChildren
())
self
.
form_o
=
''
.
join
(
xmpp
.
c14n
.
c14n
(
el
,
self
.
_is_buggy_gajim
())
for
el
\
self
.
form_s
=
''
.
join
(
xmpp
.
c14n
.
c14n
(
el
)
for
el
in
x
.
getChildren
())
in
form
.
getChildren
())
self
.
form_s
=
''
.
join
(
xmpp
.
c14n
.
c14n
(
el
,
self
.
_is_buggy_gajim
())
for
el
\
in
x
.
getChildren
())
self
.
status
=
'
responded-e2e
'
self
.
status
=
'
responded-e2e
'
...
@@ -792,7 +809,8 @@ class EncryptedStanzaSession(StanzaSession):
...
@@ -792,7 +809,8 @@ class EncryptedStanzaSession(StanzaSession):
result
.
addChild
(
node
=
xmpp
.
DataField
(
name
=
'
dhkeys
'
,
result
.
addChild
(
node
=
xmpp
.
DataField
(
name
=
'
dhkeys
'
,
value
=
base64
.
b64encode
(
crypto
.
encode_mpi
(
e
))))
value
=
base64
.
b64encode
(
crypto
.
encode_mpi
(
e
))))
self
.
form_o
=
''
.
join
(
xmpp
.
c14n
.
c14n
(
el
)
for
el
in
form
.
getChildren
())
self
.
form_o
=
''
.
join
(
xmpp
.
c14n
.
c14n
(
el
,
self
.
_is_buggy_gajim
())
for
\
el
in
form
.
getChildren
())
# MUST securely destroy K unless it will be used later to generate the
# MUST securely destroy K unless it will be used later to generate the
# final shared secret
# final shared secret
...
...
This diff is collapsed.
Click to expand it.
src/common/xmpp/c14n.py
+
3
−
3
View file @
4cfd56a6
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
'''
XML canonicalisation methods (for XEP-0116)
'''
'''
XML canonicalisation methods (for XEP-0116)
'''
from
simplexml
import
ustr
from
simplexml
import
ustr
def
c14n
(
node
):
def
c14n
(
node
,
is_buggy
):
s
=
"
<
"
+
node
.
name
s
=
"
<
"
+
node
.
name
if
node
.
namespace
:
if
node
.
namespace
:
if
not
node
.
parent
or
node
.
parent
.
namespace
!=
node
.
namespace
:
if
not
node
.
parent
or
node
.
parent
.
namespace
!=
node
.
namespace
:
...
@@ -29,7 +29,7 @@ def c14n(node):
...
@@ -29,7 +29,7 @@ def c14n(node):
sorted_attrs
=
sorted
(
node
.
attrs
.
keys
())
sorted_attrs
=
sorted
(
node
.
attrs
.
keys
())
for
key
in
sorted_attrs
:
for
key
in
sorted_attrs
:
if
key
==
'
xmlns
'
:
if
not
is_buggy
and
key
==
'
xmlns
'
:
continue
continue
val
=
ustr
(
node
.
attrs
[
key
])
val
=
ustr
(
node
.
attrs
[
key
])
# like XMLescape() but with whitespace and without >
# like XMLescape() but with whitespace and without >
...
@@ -40,7 +40,7 @@ def c14n(node):
...
@@ -40,7 +40,7 @@ def c14n(node):
for
a
in
node
.
kids
:
for
a
in
node
.
kids
:
if
(
len
(
node
.
data
)
-
1
)
>=
cnt
:
if
(
len
(
node
.
data
)
-
1
)
>=
cnt
:
s
=
s
+
normalise_text
(
node
.
data
[
cnt
])
s
=
s
+
normalise_text
(
node
.
data
[
cnt
])
s
=
s
+
c14n
(
a
)
s
=
s
+
c14n
(
a
,
is_buggy
)
cnt
=
cnt
+
1
cnt
=
cnt
+
1
if
(
len
(
node
.
data
)
-
1
)
>=
cnt
:
s
=
s
+
normalise_text
(
node
.
data
[
cnt
])
if
(
len
(
node
.
data
)
-
1
)
>=
cnt
:
s
=
s
+
normalise_text
(
node
.
data
[
cnt
])
if
not
node
.
kids
and
s
.
endswith
(
'
>
'
):
if
not
node
.
kids
and
s
.
endswith
(
'
>
'
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment