45 |
in @det_data. The context is returned in @r_ctx and the signature |
in @det_data. The context is returned in @r_ctx and the signature |
46 |
in @r_sig. |
in @r_sig. |
47 |
Return value: 0 on success. */ |
Return value: 0 on success. */ |
48 |
gpgme_error_t |
static gpgme_error_t |
49 |
gpg_clip_verify (int is_detached, |
gpg_clip_verify (int is_detached, |
50 |
const char *det_data, size_t det_len, |
const char *det_data, size_t det_len, |
51 |
gpgme_ctx_t *r_ctx, |
gpgme_ctx_t *r_ctx, |
141 |
} |
} |
142 |
|
|
143 |
|
|
|
/* Ask the user whether to fetch the missing key from the keyserver. */ |
|
|
static BOOL |
|
|
fetch_key_from_keyserver (HWND dlg, gpgme_signature_t sig) |
|
|
{ |
|
|
const char *keyid; |
|
|
int id; |
|
|
|
|
|
if (!sig->fpr) |
|
|
return FALSE; |
|
|
keyid = get_keyid_from_fpr (sig->fpr); |
|
|
id = log_box (_("Verify"), MB_INFO|MB_YESNO, |
|
|
_("Signature made %s using %s key ID 0x%s\n" |
|
|
"Cannot check signature: public key not found\n\n" |
|
|
"Do you want to try to retrieve the key from the keyserver?"), |
|
|
strtimestamp (sig->timestamp), |
|
|
get_key_pubalgo (sig->pubkey_algo), keyid); |
|
|
if (id == IDNO) { |
|
|
msg_box (dlg, get_gpg_sigstat (GPGME_SIGSUM_KEY_MISSING), |
|
|
_("Verify"), MB_WARN); |
|
|
return FALSE; |
|
|
} |
|
|
|
|
|
/* XXX: gpgme currently does not include to return the preferred |
|
|
keyserver that might be stored within the signature. */ |
|
|
|
|
|
if (!hkp_recv_key (dlg, default_keyserver, default_keyserver_port, |
|
|
keyid, 0, 0)) |
|
|
keycache_update (0, keyid); |
|
|
return TRUE; |
|
|
} |
|
|
|
|
|
|
|
144 |
/* Dialog procedure for the clipboard verification. */ |
/* Dialog procedure for the clipboard verification. */ |
145 |
BOOL CALLBACK |
BOOL CALLBACK |
146 |
clip_verify_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
clip_verify_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
168 |
det_data, det_len, &c, &sig); |
det_data, det_len, &c, &sig); |
169 |
if (err) { |
if (err) { |
170 |
msg_box (dlg, gpgme_strerror (err), _("Verify"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Verify"), MB_ERR); |
|
if (c) |
|
|
gpgme_release (c); |
|
171 |
EndDialog (dlg, FALSE); |
EndDialog (dlg, FALSE); |
172 |
return FALSE; |
return FALSE; |
173 |
} |
} |
174 |
|
|
175 |
if (gpgme_err_code (sig->status) == GPG_ERR_NO_PUBKEY) { |
if (gpgme_err_code (sig->status) == GPG_ERR_NO_PUBKEY) { |
176 |
|
gpgme_verify_result_t res; |
177 |
|
|
178 |
if (fetch_key_from_keyserver (dlg, sig)) { |
if (fetch_key_from_keyserver (dlg, sig)) { |
|
gpgme_release (c); |
|
179 |
EndDialog (dlg, FALSE); |
EndDialog (dlg, FALSE); |
180 |
return TRUE; |
return TRUE; |
181 |
} |
} |
182 |
|
/* We need to call GPG again to get the real sig status. */ |
183 |
|
err = gpg_clip_verify (ctx && ctx->length > 0, |
184 |
|
det_data, det_len, &c, &sig); |
185 |
|
if (err) { |
186 |
|
msg_box (dlg, gpgme_strerror (err), _("Verify"), MB_ERR); |
187 |
|
EndDialog (dlg, FALSE); |
188 |
|
return TRUE; |
189 |
|
} |
190 |
|
/* Refresh the pointer because a new GPG instance has been |
191 |
|
created for the new verify operation. */ |
192 |
|
res = gpgme_op_verify_result (c); |
193 |
|
if (!res || res->signatures == NULL) |
194 |
|
BUG (0); |
195 |
|
sig = res->signatures; |
196 |
|
|
197 |
} |
} |
198 |
else if (gpgme_err_code (sig->status) == GPG_ERR_BAD_SIGNATURE && |
|
199 |
|
if (gpgme_err_code (sig->status) == GPG_ERR_BAD_SIGNATURE && |
200 |
!sig->timestamp) |
!sig->timestamp) |
201 |
; |
; |
202 |
else if (!sig->timestamp) { |
else if (!sig->timestamp) { |
203 |
msg_box (dlg, _("Invalid signature state."), _("Verify"), MB_ERR); |
msg_box (dlg, _("Invalid signature state."), _("Verify"), MB_ERR); |
|
gpgme_release (c); |
|
204 |
EndDialog (dlg, FALSE); |
EndDialog (dlg, FALSE); |
205 |
return FALSE; |
return FALSE; |
206 |
} |
} |
209 |
|
|
210 |
for (s = sig; s; s = s->next) { |
for (s = sig; s; s = s->next) { |
211 |
rc = verlist_add_sig (vlv, s); |
rc = verlist_add_sig (vlv, s); |
212 |
if (rc) |
if (rc) { |
213 |
msg_box (dlg, _("Could not extract key or signature information."), |
msg_box (dlg, _("Error while adding signature information."), |
214 |
_("Verify"), MB_ERR); |
_("Verify"), MB_ERR); |
215 |
|
break; |
216 |
|
} |
217 |
} |
} |
218 |
|
|
219 |
if (!sig->notations) |
if (!sig->notations) |