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
):
30 def __init__(self
, interface
, sigs
, iface_xml
):
31 dialog
.Dialog
.__init
__(self
)
32 self
.connect('destroy', lambda a
: _pop_queue())
34 self
.interface
= interface
36 self
.iface_xml
= iface_xml
38 self
.set_title('Confirm trust')
40 label
= gtk
.Label('Please confirm that you trust '
41 'these keys to sign software updates:')
42 label
.set_padding(8, 8)
43 self
.vbox
.pack_start(label
, False, True, 0)
45 swin
= gtk
.ScrolledWindow()
46 self
.vbox
.pack_start(swin
, True, True, 0)
47 swin
.set_policy(gtk
.POLICY_NEVER
, gtk
.POLICY_AUTOMATIC
)
48 swin
.set_shadow_type(gtk
.SHADOW_IN
)
49 swin
.set_border_width(8)
51 self
.model
= gtk
.ListStore(str, object)
52 self
.tree_view
= gtk
.TreeView(self
.model
)
53 self
.tree_view
.get_selection().set_mode(gtk
.SELECTION_NONE
)
54 swin
.add(self
.tree_view
)
56 self
.tree_view
.set_size_request(-1, 100)
58 text
= gtk
.CellRendererText()
60 for column
in [gtk
.TreeViewColumn('Key fingerprint', text
, text
= 0)]:
61 self
.tree_view
.append_column(column
)
65 self
.add_button(gtk
.STOCK_HELP
, gtk
.RESPONSE_HELP
)
66 self
.add_button(gtk
.STOCK_CANCEL
, gtk
.RESPONSE_CANCEL
)
67 self
.add_button(gtk
.STOCK_ADD
, gtk
.RESPONSE_OK
)
68 self
.set_default_response(gtk
.RESPONSE_OK
)
70 def response(box
, resp
):
71 if resp
== gtk
.RESPONSE_HELP
:
74 if resp
== gtk
.RESPONSE_OK
:
77 self
.connect('response', response
)
79 valid_sigs
= [s
for s
in sigs
if isinstance(s
, gpg
.ValidSig
)]
81 raise SafeException('No valid signatures found')
84 titer
= self
.model
.append()
85 self
.model
[titer
][0] = pretty_fp(fingerprint(sig
))
86 self
.model
[titer
][1] = sig
88 self
.tree_view
.expand_all()
92 for row
in self
.model
:
94 trust
.trust_db
.trust_key(fingerprint(sig
))
96 if not iface_cache
.update_interface_if_trusted(self
.interface
, self
.sigs
,
98 raise Exception('Bug: still not trusted!!')
106 def confirm_trust(interface
, sigs
, iface_xml
):
107 _queue
.append(TrustBox(interface
, sigs
, iface_xml
))
111 trust_help
= help_box
.HelpBox("Trust Help",
113 When you run a program, it typically has access to all your files and can generally do \
114 anything that you're allowed to do (delete files, send emails, etc). So it's important \
115 to make sure that you don't run anything malicious."""),
117 ('Digital signatures', """
118 Each software author creates a 'key-pair'; a 'public key' and a 'private key'. Without going \
119 into the maths, only something encrypted with the private key will decrypt with the public key.
121 So, when a programmer releases some software, they encrypt it with their private key (which no-one \
122 else has). When you download it, the injector checks that it decrypts using their public key, thus \
123 proving that it came from them and hasn't been tampered with."""),
126 After the injector has checked that the software hasn't been modified since it was signed with \
127 the private key, you still have the following problems:
129 1. Does the public key you have really belong to the author?
130 2. Even if the software really did come from that person, do you trust them?"""),
132 ('Key fingerprints', """
133 To confirm (1), you should compare the public key you have with the genuine one. To make this \
134 easier, the injector displays a 'fingerprint' for the key. Look in mailing list postings or some \
135 other source to check that the fingerprint is right (a different key will have a different \
138 You're trying to protect against the situation where an attacker breaks into a web site \
139 and puts up malicious software, signed with the attacker's private key, and puts up the \
140 attacker's public key too. If you've downloaded this software before, you \
141 should be suspicious that you're being asked to confirm another key!"""),
144 In general, most problems seem to come from malicous and otherwise-unknown people \
145 replacing software with modified versions, or creating new programs intended only to \
146 cause damage. So, check your programs are signed by a key with a good reputation!"""))