33 |
#include "wptErrors.h" |
#include "wptErrors.h" |
34 |
#include "wptVersion.h" |
#include "wptVersion.h" |
35 |
|
|
36 |
|
/* XXX use out directly and do not use gpg_data_extract to store the plain text. */ |
37 |
|
|
38 |
|
|
39 |
/* Verify data from the clipboard. If @is_detached is set, a detached |
/* Verify data from the clipboard. If @is_detached is set, a detached |
40 |
signature is assumed with the data the signature was calculated over |
signature is assumed with the data the signature was calculated over |
50 |
gpgme_error_t err; |
gpgme_error_t err; |
51 |
gpgme_ctx_t ctx; |
gpgme_ctx_t ctx; |
52 |
gpgme_data_t dat = NULL; |
gpgme_data_t dat = NULL; |
53 |
|
gpgme_data_t out = NULL; |
54 |
gpgme_data_t sig = NULL; |
gpgme_data_t sig = NULL; |
55 |
gpgme_verify_result_t res; |
gpgme_verify_result_t res; |
56 |
|
|
57 |
if (is_detached) { |
if (is_detached) { |
58 |
|
msg_box (NULL, "detached sig", "debug", 0); |
59 |
err = gpgme_data_new_from_mem (&dat, det_data, det_len, 1); |
err = gpgme_data_new_from_mem (&dat, det_data, det_len, 1); |
60 |
if (err) |
if (err) |
61 |
return err; |
return err; |
66 |
goto leave; |
goto leave; |
67 |
err = gpg_data_new_from_clipboard (&sig, 0); |
err = gpg_data_new_from_clipboard (&sig, 0); |
68 |
if (err) |
if (err) |
69 |
goto leave; |
goto leave; |
70 |
err = gpgme_op_verify (ctx, sig, dat, NULL); |
err = gpgme_data_new (&out); |
71 |
|
if (err) |
72 |
|
goto leave; |
73 |
|
|
74 |
|
err = gpgme_op_verify (ctx, sig, dat, out); |
75 |
if (err) |
if (err) |
76 |
goto leave; |
goto leave; |
77 |
res = gpgme_op_verify_result (ctx); |
res = gpgme_op_verify_result (ctx); |
89 |
} |
} |
90 |
if (dat) |
if (dat) |
91 |
gpgme_data_release (dat); |
gpgme_data_release (dat); |
92 |
|
if (out) |
93 |
|
gpgme_data_release (out); |
94 |
gpgme_data_release (sig); |
gpgme_data_release (sig); |
95 |
return err; |
return err; |
96 |
} |
} |
108 |
|
|
109 |
for (n=not; n; n = n->next) { |
for (n=not; n; n = n->next) { |
110 |
if (n->name) |
if (n->name) |
111 |
len += strlen (n->name) + 1; |
len += strlen (n->name) + 1 + 2; |
112 |
else |
else |
113 |
len += strlen ("policy URL") + 1; |
len += strlen ("policy URL") + 1 + 2; |
114 |
len += strlen (n->value) + 1; |
len += strlen (n->value) + 1 + 2; |
115 |
len += 6; |
len += 6; |
116 |
} |
} |
117 |
p = (char *)calloc (1, len+64); |
p = (char *)calloc (1, len+64); |
125 |
strcat (p, n->name); |
strcat (p, n->name); |
126 |
strcat (p, " : "); |
strcat (p, " : "); |
127 |
} |
} |
128 |
|
strcat (p, "\""); |
129 |
strcat (p, n->value); |
strcat (p, n->value); |
130 |
strcat (p, "\n"); |
strcat (p, "\"\n"); |
131 |
} |
} |
132 |
|
|
133 |
msg_box (dlg, p, _("Signature Information"), MB_INFO); |
msg_box (dlg, p, _("Signature Information"), MB_INFO); |
144 |
gpgme_error_t err; |
gpgme_error_t err; |
145 |
gpgme_signature_t sig = NULL, s; |
gpgme_signature_t sig = NULL, s; |
146 |
gpgme_keycache_t kc = NULL; |
gpgme_keycache_t kc = NULL; |
147 |
gpgme_ctx_t c; |
gpgme_ctx_t c=NULL; |
148 |
char keyid[16+1]; |
char keyid[16+1]; |
149 |
|
const char *det_data=NULL; |
150 |
u16 port = HKP_PORT; |
u16 port = HKP_PORT; |
151 |
int rc = 0; |
int rc = 0, det_len=0; |
152 |
|
|
153 |
switch( msg ) { |
switch( msg ) { |
154 |
case WM_INITDIALOG: |
case WM_INITDIALOG: |
159 |
if (!kc) |
if (!kc) |
160 |
BUG (NULL); |
BUG (NULL); |
161 |
ctx = (text_input_s *)lparam; |
ctx = (text_input_s *)lparam; |
162 |
|
if (ctx) { |
163 |
|
det_data = ctx->data; |
164 |
|
det_len = ctx->length; |
165 |
|
} |
166 |
err = gpg_clip_verify (ctx && ctx->length > 0, |
err = gpg_clip_verify (ctx && ctx->length > 0, |
167 |
ctx->data, ctx->length, &c, &sig); |
det_data, det_len, &c, &sig); |
168 |
if (err) { |
if (err) { |
169 |
msg_box (dlg, gpgme_strerror (err), _("Verify"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Verify"), MB_ERR); |
170 |
gpgme_release (c); |
if (c) |
171 |
|
gpgme_release (c); |
172 |
EndDialog (dlg, FALSE); |
EndDialog (dlg, FALSE); |
173 |
return FALSE; |
return FALSE; |
174 |
} |
} |
175 |
|
|
176 |
if (sig->status == gpg_error (GPG_ERR_NO_PUBKEY)) { |
if (gpgme_err_code (sig->status) == GPG_ERR_NO_PUBKEY) { |
177 |
const char * kserv; |
const char * kserv; |
178 |
const char *fpr = sig->fpr; |
const char *fpr = sig->fpr; |
179 |
if (!fpr) |
if (!fpr) |
218 |
BUG (dlg); |
BUG (dlg); |
219 |
} |
} |
220 |
} |
} |
221 |
else if (sig->status == gpg_error (GPG_ERR_BAD_SIGNATURE) && !sig->timestamp) |
else if (gpgme_err_code (sig->status) == GPG_ERR_BAD_SIGNATURE && !sig->timestamp) |
222 |
; |
; |
223 |
else if (!sig->timestamp || !sig->validity) { |
else if (!sig->timestamp || !sig->validity) { |
224 |
msg_box (dlg, _("Invalid signature state."), _("Verify"), MB_ERR); |
msg_box (dlg, _("Invalid signature state."), _("Verify"), MB_ERR); |