2 from zeroinstall
.injector
.model
import SafeException
3 from zeroinstall
.injector
import gpg
, trust
4 from zeroinstall
.injector
.iface_cache
import iface_cache
7 import dialog
, help_box
11 return sig
.fingerprint
13 # Work around a bug in injector-0.9
14 return sig
.status
[sig
.FINGERPRINT
]
18 for x
in range(4, len(fp
), 4):
19 s
+= ' ' + fp
[x
:x
+ 4]
22 class TrustBox(dialog
.Dialog
):
27 def __init__(self
, interface
, sigs
, iface_xml
):
28 dialog
.Dialog
.__init
__(self
)
29 self
.connect('destroy', lambda a
: _pop_queue())
32 label
= gtk
.Label(text
)
33 label
.set_alignment(0, 0.5)
34 label
.set_selectable(True)
37 self
.interface
= interface
39 self
.iface_xml
= iface_xml
41 self
.set_title('Confirm trust')
43 vbox
= gtk
.VBox(False, 4)
44 vbox
.set_border_width(4)
45 self
.vbox
.pack_start(vbox
, True, True, 0)
47 label
= left('Checking: ' + interface
.uri
+ '\n\n'
48 'Please confirm that you trust '
49 'these keys to sign software updates:')
50 vbox
.pack_start(label
, False, True, 0)
52 notebook
= gtk
.Notebook()
53 vbox
.pack_start(notebook
, True, True, 0)
55 self
.add_button(gtk
.STOCK_HELP
, gtk
.RESPONSE_HELP
)
56 self
.add_button(gtk
.STOCK_CANCEL
, gtk
.RESPONSE_CANCEL
)
57 self
.add_button(gtk
.STOCK_ADD
, gtk
.RESPONSE_OK
)
58 self
.set_default_response(gtk
.RESPONSE_OK
)
60 valid_sigs
= [s
for s
in sigs
if isinstance(s
, gpg
.ValidSig
)]
62 raise SafeException('No valid signatures found')
64 trust
= {} # Sig -> CheckButton
67 for toggle
in trust
.values():
68 if toggle
.get_active():
71 self
.set_response_sensitive(gtk
.RESPONSE_OK
, trust_any
)
73 if hasattr(sig
, 'get_details'):
75 details
= sig
.get_details()
77 if item
[0] in ('pub', 'uid'):
82 page
= gtk
.VBox(False, 4)
83 page
.set_border_width(8)
84 page
.pack_start(left('Fingerprint: ' + pretty_fp(fingerprint(sig
))), False, True, 0)
86 page
.pack_start(left('Claimed identity: ' + name
), False, True, 0)
88 frame
= gtk
.Frame('Unreliable hints database says')
89 frame
.set_border_width(4)
90 hint
= left(hints
.get(fingerprint(sig
), 'Warning: Nothing known about this key!'))
91 hint
.set_line_wrap(True)
92 hint
.set_padding(4, 4)
94 page
.pack_start(frame
, True, True, 0)
96 trust
[sig
] = gtk
.CheckButton('Trust this key')
97 page
.pack_start(trust
[sig
], False, True, 0)
98 trust
[sig
].connect('toggled', lambda t
: ok_sensitive())
100 notebook
.append_page(page
, gtk
.Label(name
or 'Signature'))
105 def response(box
, resp
):
106 if resp
== gtk
.RESPONSE_HELP
:
109 if resp
== gtk
.RESPONSE_OK
:
110 self
.trust_keys([sig
for sig
in trust
if trust
[sig
].get_active()])
112 self
.connect('response', response
)
116 def trust_keys(self
, sigs
):
119 trust
.trust_db
.trust_key(fingerprint(sig
))
121 if not iface_cache
.update_interface_if_trusted(self
.interface
, self
.sigs
,
123 raise Exception('Bug: still not trusted!!')
124 except Exception, ex
:
125 dialog
.alert(None, ex
)
133 def confirm_trust(interface
, sigs
, iface_xml
):
134 _queue
.append(TrustBox(interface
, sigs
, iface_xml
))
138 trust_help
= help_box
.HelpBox("Trust Help",
140 When you run a program, it typically has access to all your files and can generally do \
141 anything that you're allowed to do (delete files, send emails, etc). So it's important \
142 to make sure that you don't run anything malicious."""),
144 ('Digital signatures', """
145 Each software author creates a 'key-pair'; a 'public key' and a 'private key'. Without going \
146 into the maths, only something encrypted with the private key will decrypt with the public key.
148 So, when a programmer releases some software, they encrypt it with their private key (which no-one \
149 else has). When you download it, the injector checks that it decrypts using their public key, thus \
150 proving that it came from them and hasn't been tampered with."""),
153 After the injector has checked that the software hasn't been modified since it was signed with \
154 the private key, you still have the following problems:
156 1. Does the public key you have really belong to the author?
157 2. Even if the software really did come from that person, do you trust them?"""),
159 ('Key fingerprints', """
160 To confirm (1), you should compare the public key you have with the genuine one. To make this \
161 easier, the injector displays a 'fingerprint' for the key. Look in mailing list postings or some \
162 other source to check that the fingerprint is right (a different key will have a different \
165 You're trying to protect against the situation where an attacker breaks into a web site \
166 and puts up malicious software, signed with the attacker's private key, and puts up the \
167 attacker's public key too. If you've downloaded this software before, you \
168 should be suspicious that you're being asked to confirm another key!"""),
171 In general, most problems seem to come from malicous and otherwise-unknown people \
172 replacing software with modified versions, or creating new programs intended only to \
173 cause damage. So, check your programs are signed by a key with a good reputation!"""))
176 '1DC295D11A3F910DA49D3839AA1A7812B40B0B6E' :
177 'Ken Hayber has been writing ROX applications since 2003. This key '
178 'was announced on the rox-users list on 5 Jun 2005.',
180 '4338D5420E0BAEB6B2E73530B66A4F24AB8B4B65' :
181 'Thomas Formella is experimenting with packaging programs for 0launch. This key '
182 'was announced on 11 Sep 2005 on the zero-install mailing list.',
184 '92429807C9853C0744A68B9AAE07828059A53CC1' :
185 'Thomas Leonard created Zero Install and ROX. This key is normally trusted by default.',
187 '0597A2AFB6B372ACB97AC6E433B938C2E9D8826D' :
188 'Stephen Watson is a project admin for the ROX desktop, and has been involved with the '
189 'project since 2000. This key has been used for signing software since the 23 Jul 2005 '
190 'announcement on the zero-install mailing list.',