Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
gajim-plugins
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
Evert Mouw
gajim-plugins
Commits
b4927cd3
Commit
b4927cd3
authored
12 years ago
by
Kjell Braden
Browse files
Options
Downloads
Patches
Plain Diff
updated gotr to version 1.5
parent
38efc8c3
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
gotr/manifest.ini
+1
-1
1 addition, 1 deletion
gotr/manifest.ini
gotr/otrmodule.py
+63
-31
63 additions, 31 deletions
gotr/otrmodule.py
with
64 additions
and
32 deletions
gotr/manifest.ini
+
1
−
1
View file @
b4927cd3
[info]
name:
Off-The-Record
Encryption
short_name:
gotr
version:
1.
4
version:
1.
5
description:
See
http://www.cypherpunks.ca/otr/
authors:
Kjell
Braden
<afflux.gajim@pentabarf.de>
homepage:
http://gajim-otr.pentabarf.de
This diff is collapsed.
Click to expand it.
gotr/otrmodule.py
+
63
−
31
View file @
b4927cd3
...
...
@@ -24,12 +24,12 @@
Off-The-Record encryption plugin.
:author: Kjell self.Braden <kb.otr@pentabarf.de>
:since: 20
May 2011
:copyright: Copyright
(
201
1)
Kjell Braden <
kb.otr
@pentabarf.de>
:since: 20
08
:copyright: Copyright
2008-
201
2
Kjell Braden <
afflux
@pentabarf.de>
:license: GPL
'''
MINVERSION
=
(
1
,
0
,
0
,
'
beta
4
'
)
MINVERSION
=
(
1
,
0
,
0
,
'
beta
5
'
)
IGNORE
=
True
PASS
=
False
...
...
@@ -77,11 +77,18 @@ try:
except
ImportError
:
HAS_POTR
=
False
def
get_jid_from_fjid
(
fjid
):
return
gajim
.
get_room_and_nick_from_fjid
(
fjid
)[
0
]
class
GajimContext
(
potr
.
context
.
Context
):
__slots__
=
[
'
smpWindow
'
]
# self.peer is fjid
# self.jid does not contain resource
__slots__
=
[
'
smpWindow
'
,
'
jid
'
]
def
__init__
(
self
,
account
,
peer
):
super
(
GajimContext
,
self
).
__init__
(
account
,
peer
)
self
.
jid
=
get_jid_from_fjid
(
peer
)
self
.
trustName
=
self
.
jid
self
.
smpWindow
=
ui
.
ContactOtrSmpWindow
(
self
)
def
inject
(
self
,
msg
,
appdata
=
None
):
...
...
@@ -137,8 +144,7 @@ class GajimContext(potr.context.Context):
self
.
user
.
plugin
.
update_context_list
()
def
getPolicy
(
self
,
key
):
jid
=
gajim
.
get_room_and_nick_from_fjid
(
self
.
peer
)[
0
]
ret
=
self
.
user
.
plugin
.
get_flags
(
self
.
user
.
accountname
,
jid
)[
key
]
ret
=
self
.
user
.
plugin
.
get_flags
(
self
.
user
.
accountname
,
self
.
jid
)[
key
]
log
.
debug
(
'
getPolicy(key=%s) = %s
'
,
key
,
ret
)
return
ret
...
...
@@ -191,7 +197,8 @@ class GajimOtrAccount(potr.context.Account):
if
acc
!=
self
.
name
or
proto
!=
PROTOCOL
:
continue
self
.
getContext
(
ctx
,
newCtxCb
).
setTrust
(
fpr
,
trust
)
jid
=
get_jid_from_fjid
(
ctx
)
self
.
setTrust
(
jid
,
fpr
,
trust
)
except
IOError
,
e
:
if
e
.
errno
!=
2
:
log
.
exception
(
'
IOError occurred when loading fpr file for %s
'
,
...
...
@@ -200,10 +207,10 @@ class GajimOtrAccount(potr.context.Account):
def
saveTrusts
(
self
):
try
:
with
open
(
self
.
keyFilePath
+
'
.fpr
'
,
'
w
'
)
as
fprFile
:
for
uid
,
ctx
in
self
.
ctx
s
.
iteritems
():
for
fpr
,
trust
in
ctx
.
trust
.
iteritems
():
for
uid
,
trusts
in
self
.
trust
s
.
iteritems
():
for
fpr
,
trust
Val
in
trust
s
.
iteritems
():
fprFile
.
write
(
'
\t
'
.
join
(
(
uid
,
self
.
name
,
PROTOCOL
,
fpr
,
trust
)))
(
uid
,
self
.
name
,
PROTOCOL
,
fpr
,
trust
Val
)))
fprFile
.
write
(
'
\n
'
)
except
IOError
,
e
:
log
.
exception
(
'
IOError occurred when loading fpr file for %s
'
,
...
...
@@ -237,6 +244,7 @@ class OtrPlugin(GajimPlugin):
acc
=
str
(
acc
)
if
acc
not
in
self
.
config
or
None
not
in
self
.
config
[
acc
]:
self
.
config
[
acc
]
=
{
None
:
DEFAULTFLAGS
.
copy
()}
self
.
update_context_list
()
@log_calls
(
'
OtrPlugin
'
)
def
activate
(
self
):
...
...
@@ -370,27 +378,42 @@ class OtrPlugin(GajimPlugin):
def
update_context_list
(
self
):
self
.
config_dialog
.
fpr_model
.
clear
()
for
us
in
self
.
us
.
itervalues
():
for
uid
,
ctx
in
us
.
ctxs
.
iteritems
():
for
fpr
,
trust
in
ctx
.
trust
.
iteritems
():
trust
=
False
if
ctx
.
state
==
potr
.
context
.
STATE_ENCRYPTED
:
if
ctx
.
getCurrentKey
().
cfingerprint
()
==
fpr
:
state
=
"
encrypted
"
tip
=
enc_tip
trust
=
bool
(
ctx
.
getCurrentTrust
())
else
:
state
=
"
unused
"
tip
=
unused_tip
elif
ctx
.
state
==
potr
.
context
.
STATE_FINISHED
:
state
=
"
finished
"
tip
=
ended_tip
else
:
state
=
'
inactive
'
tip
=
inactive_tip
usedFpr
=
set
()
for
fjid
,
ctx
in
us
.
ctxs
.
iteritems
():
# get active contexts first
key
=
ctx
.
getCurrentKey
()
if
not
key
:
continue
fpr
=
key
.
cfingerprint
()
usedFpr
.
add
(
fpr
)
human_hash
=
potr
.
human_hash
(
fpr
)
trust
=
bool
(
us
.
getTrust
(
ctx
.
trustName
,
fpr
))
if
ctx
.
state
==
potr
.
context
.
STATE_ENCRYPTED
:
state
=
"
encrypted
"
tip
=
enc_tip
elif
ctx
.
state
==
potr
.
context
.
STATE_FINISHED
:
state
=
"
finished
"
tip
=
ended_tip
else
:
state
=
'
inactive
'
tip
=
inactive_tip
self
.
config_dialog
.
fpr_model
.
append
((
fjid
,
state
,
trust
,
'
<tt>%s</tt>
'
%
human_hash
,
us
.
name
,
tip
,
fpr
))
for
uid
,
trusts
in
us
.
trusts
.
iteritems
():
for
fpr
,
trust
in
trusts
.
iteritems
():
if
fpr
in
usedFpr
:
continue
state
=
'
inactive
'
tip
=
inactive_tip
human_hash
=
potr
.
human_hash
(
fpr
)
self
.
config_dialog
.
fpr_model
.
append
((
uid
,
state
,
trust
,
self
.
config_dialog
.
fpr_model
.
append
((
uid
,
state
,
bool
(
trust
)
,
'
<tt>%s</tt>
'
%
human_hash
,
us
.
name
,
tip
,
fpr
))
@classmethod
...
...
@@ -470,22 +493,31 @@ class OtrPlugin(GajimPlugin):
ctx
=
self
.
us
[
account
].
getContext
(
event
.
fjid
)
msgtxt
,
tlvs
=
ctx
.
receiveMessage
(
event
.
msgtxt
,
appdata
=
{
'
session
'
:
event
.
session
})
except
potr
.
context
.
NotOTRMessage
,
e
:
# received message was not OTR - pass it on
return
PASS
except
potr
.
context
.
UnencryptedMessage
,
e
:
# we are encrypted but got some plaintext
# display it with a warning
tlvs
=
[]
msgtxt
=
_
(
'
The following message received from %(jid)s was
'
'
*not encrypted*: [%(error)s]
'
)
%
{
'
jid
'
:
event
.
fjid
,
'
error
'
:
e
.
args
[
0
]}
except
potr
.
context
.
NotEncryptedError
,
e
:
# we got some encrypted data
# but we don't have an encrypted session
self
.
gajim_log
(
_
(
'
The encrypted message received from %s is
'
'
unreadable, as you are not currently communicating
'
'
privately
'
)
%
event
.
fjid
,
account
,
event
.
fjid
)
return
IGNORE
except
potr
.
context
.
ErrorReceived
,
e
:
# got a protocol error
self
.
gajim_log
(
_
(
'
We received the following OTR error
'
'
message from %(jid)s: [%(error)s]
'
)
%
{
'
jid
'
:
event
.
fjid
,
'
error
'
:
e
.
args
[
0
].
error
})
return
IGNORE
except
RuntimeError
,
e
:
# generic library bug?
self
.
gajim_log
(
_
(
'
The following error occurred when trying to
'
'
decrypt a message from %(jid)s: [%(error)s]
'
)
%
{
'
jid
'
:
event
.
fjid
,
'
error
'
:
e
},
...
...
@@ -494,12 +526,12 @@ class OtrPlugin(GajimPlugin):
if
ctx
is
not
None
:
ctx
.
smpWindow
.
handle_tlv
(
tlvs
)
if
not
msgtxt
:
return
IGNORE
event
.
msgtxt
=
unicode
(
msgtxt
)
event
.
msgtxt
=
unicode
(
msgtxt
or
''
)
event
.
stanza
.
setBody
(
event
.
msgtxt
)
# every message that went through OTR (ie. was OTR-related) gets
# stripped from html. I don't like html.
html_node
=
event
.
stanza
.
getTag
(
'
html
'
)
if
html_node
:
event
.
stanza
.
delChild
(
html_node
)
...
...
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