2 from zeroinstall
.injector
.model
import SafeException
3 from zeroinstall
.injector
import gpg
, trust
6 import dialog
, help_box
10 for x
in range(4, len(fp
), 4):
11 s
+= ' ' + fp
[x
:x
+ 4]
14 class TrustBox(dialog
.Dialog
):
22 def __init__(self
, interface
, sigs
, iface_xml
):
23 dialog
.Dialog
.__init
__(self
)
24 self
.connect('destroy', lambda a
: _pop_queue())
26 self
.interface
= interface
28 self
.iface_xml
= iface_xml
30 self
.set_title('Confirm trust')
32 label
= gtk
.Label('Please confirm that you trust '
33 'these keys to sign software updates:')
34 label
.set_padding(8, 8)
35 self
.vbox
.pack_start(label
, False, True, 0)
37 swin
= gtk
.ScrolledWindow()
38 self
.vbox
.pack_start(swin
, True, True, 0)
39 swin
.set_policy(gtk
.POLICY_NEVER
, gtk
.POLICY_AUTOMATIC
)
40 swin
.set_shadow_type(gtk
.SHADOW_IN
)
41 swin
.set_border_width(8)
43 self
.model
= gtk
.ListStore(str, object)
44 self
.tree_view
= gtk
.TreeView(self
.model
)
45 self
.tree_view
.get_selection().set_mode(gtk
.SELECTION_NONE
)
46 swin
.add(self
.tree_view
)
48 self
.tree_view
.set_size_request(-1, 100)
50 text
= gtk
.CellRendererText()
52 for column
in [gtk
.TreeViewColumn('Key fingerprint', text
, text
= 0)]:
53 self
.tree_view
.append_column(column
)
57 self
.add_button(gtk
.STOCK_HELP
, gtk
.RESPONSE_HELP
)
58 self
.add_button(gtk
.STOCK_CANCEL
, gtk
.RESPONSE_CANCEL
)
59 self
.add_button(gtk
.STOCK_ADD
, gtk
.RESPONSE_OK
)
60 self
.set_default_response(gtk
.RESPONSE_OK
)
62 def response(box
, resp
):
63 if resp
== gtk
.RESPONSE_HELP
:
66 if resp
== gtk
.RESPONSE_OK
:
69 self
.connect('response', response
)
71 valid_sigs
= [s
for s
in sigs
if isinstance(s
, gpg
.ValidSig
)]
73 raise SafeException('No valid signatures found')
76 titer
= self
.model
.append()
77 self
.model
[titer
][0] = pretty_fp(sig
.fingerprint
)
78 self
.model
[titer
][1] = sig
80 self
.tree_view
.expand_all()
84 for row
in self
.model
:
86 trust
.trust_db
.trust_key(sig
.fingerprint
)
88 if not gui
.policy
.update_interface_if_trusted(self
.interface
, self
.sigs
,
90 raise Exception('Bug: still not trusted!!')
98 def confirm_trust(interface
, sigs
, iface_xml
):
99 _queue
.append(TrustBox(interface
, sigs
, iface_xml
))
103 trust_help
= help_box
.HelpBox("Trust Help",
105 When you run a program, it typically has access to all your files and can generally do \
106 anything that you're allowed to do (delete files, send emails, etc). So it's important \
107 to make sure that you don't run anything malicious."""),
109 ('Digital signatures', """
110 Each software author creates a 'key-pair'; a 'public key' and a 'private key'. Without going \
111 into the maths, only something encrypted with the private key will decrypt with the public key.
113 So, when a programmer releases some software, they encrypt it with their private key (which no-one \
114 else has). When you download it, the injector checks that it decrypts using their public key, thus \
115 proving that it came from them and hasn't been tampered with."""),
118 After the injector has checked that the software hasn't been modified since it was signed with \
119 the private key, you still have the following problems:
121 1. Does the public key you have really belong to the author?
122 2. Even if the software really did come from that person, do you trust them?"""),
124 ('Key fingerprints', """
125 To confirm (1), you should compare the public key you have with the genuine one. To make this \
126 easier, the injector displays a 'fingerprint' for the key. Look in mailing list postings or some \
127 other source to check that the fingerprint is right (a different key will have a different \
130 You're trying to protect against the situation where an attacker breaks into a web site \
131 and puts up malicious software, signed with the attacker's private key, and puts up their \
132 public key too. If you've downloaded the real software before, you should be suspicious that \
133 the fingerprint has changed!"""),
136 In general, most problems seem to come from malicous and otherwise-unknown people \
137 replacing software with modified versiosn, or creating new programs intended only to \
138 cause damage. So, check your programs are signed by a key with a good reputation!"""))