46 |
char* |
char* |
47 |
get_key_userid (const char *keyid) |
get_key_userid (const char *keyid) |
48 |
{ |
{ |
49 |
gpgme_key_t key; |
winpt_key_s key; |
50 |
char *p, *uid; |
char *uid; |
51 |
|
|
52 |
if (get_pubkey (keyid, &key)) |
memset (&key, 0, sizeof (key)); |
53 |
|
if (winpt_get_pubkey (keyid, &key)) |
54 |
return m_strdup (_("user ID not found")); |
return m_strdup (_("user ID not found")); |
55 |
uid = utf8_to_native (key->uids->uid); |
uid = new char[strlen (key.ext->uids->uid) + 4 + 8]; |
56 |
if (!uid) |
if (!uid) |
|
uid = strdup (_("user ID not found")); |
|
|
p = new char[strlen (uid) + 4 + 8]; |
|
|
if (!p) |
|
57 |
BUG (NULL); |
BUG (NULL); |
58 |
sprintf (p, "\n \"%s\"", uid); |
sprintf (uid, "\n \"%s\"", key.ext->uids->uid); |
59 |
safe_free (uid); |
return uid; |
|
return p; |
|
60 |
} |
} |
61 |
|
|
62 |
|
|
101 |
gpgme_verify_result_t sigres; |
gpgme_verify_result_t sigres; |
102 |
passphrase_cb_s pwd; |
passphrase_cb_s pwd; |
103 |
const char *s; |
const char *s; |
104 |
char *uid; |
const char *uid; |
105 |
int pgp_type = 0; |
int pgp_type = 0; |
106 |
int novalid = 0; |
int novalid = 0; |
107 |
|
|
125 |
res = gpgme_op_decrypt_result (ctx); |
res = gpgme_op_decrypt_result (ctx); |
126 |
if (err && res->recipients && !secret_key_available (res->recipients)) { |
if (err && res->recipients && !secret_key_available (res->recipients)) { |
127 |
gpgme_recipient_t r = res->recipients; |
gpgme_recipient_t r = res->recipients; |
128 |
uid = get_key_userid (r->keyid+8); |
char *u = get_key_userid (r->keyid+8); |
129 |
log_box (_("Decryption"), MB_ERR, |
log_box (_("Decryption"), MB_ERR, |
130 |
_("Encrypted with %s key, ID %s.%s\n" |
_("Encrypted with %s key, ID %s.%s\n" |
131 |
"Decryption failed: secret key not available."), |
"Decryption failed: secret key not available."), |
132 |
get_key_pubalgo (r->pubkey_algo), r->keyid+8, uid); |
get_key_pubalgo (r->pubkey_algo), r->keyid+8, u); |
133 |
free_if_alloc (uid); |
free_if_alloc (u); |
134 |
goto leave; |
goto leave; |
135 |
} |
} |
136 |
else if (res->unsupported_algorithm) { |
else if (res->unsupported_algorithm) { |
160 |
|
|
161 |
sigres = gpgme_op_verify_result (ctx); |
sigres = gpgme_op_verify_result (ctx); |
162 |
if (sigres && sigres->signatures) { |
if (sigres && sigres->signatures) { |
163 |
gpgme_key_t key=NULL; |
winpt_key_s key; |
164 |
const char *keyid; |
const char *keyid; |
165 |
|
|
166 |
sig = sigres->signatures; |
sig = sigres->signatures; |
167 |
if (!sig->fpr) |
if (!sig->fpr) |
168 |
BUG (NULL); |
BUG (NULL); |
169 |
keyid = get_keyid_from_fpr (sig->fpr); |
keyid = get_keyid_from_fpr (sig->fpr); |
170 |
get_pubkey (keyid, &key); |
memset (&key, 0, sizeof (key)); |
171 |
if (key) { |
if (!winpt_get_pubkey (keyid, &key)) { |
172 |
if (key->owner_trust == GPGME_VALIDITY_FULL || |
if (key.ctx->owner_trust == GPGME_VALIDITY_FULL || |
173 |
key->owner_trust == GPGME_VALIDITY_ULTIMATE) |
key.ctx->owner_trust == GPGME_VALIDITY_ULTIMATE) |
174 |
s = _("Signature Status: Created with a fully trusted key"); |
s = _("Signature Status: Created with a fully trusted key"); |
175 |
else if (key->owner_trust == GPGME_VALIDITY_MARGINAL) |
else if (key.ctx->owner_trust == GPGME_VALIDITY_MARGINAL) |
176 |
s = _("Signature Status: Created with a marginal trusted key"); |
s = _("Signature Status: Created with a marginal trusted key"); |
177 |
else if (key->owner_trust == GPGME_VALIDITY_NEVER) { |
else if (key.ctx->owner_trust == GPGME_VALIDITY_NEVER) { |
178 |
novalid = 1; |
novalid = 1; |
179 |
s = _("Signature Status: Created with an UNTRUSTED key"); |
s = _("Signature Status: Created with an UNTRUSTED key"); |
180 |
} |
} |
181 |
else |
else |
182 |
s = _("Signature Status: Created with an undefined trusted key"); |
s = _("Signature Status: Created with an undefined trusted key"); |
183 |
uid = utf8_to_native (key->uids->uid); |
uid = key.ext->uids->uid; |
184 |
} |
} |
185 |
else { |
else { |
186 |
s = ""; |
s = ""; |
187 |
uid = strdup (_("user ID not found")); |
uid = _("user ID not found"); |
188 |
} |
} |
189 |
log_box (_("WinPT Verify"), MB_OK, |
log_box (_("WinPT Verify"), MB_OK, |
190 |
_("%s\n" |
_("%s\n" |
196 |
strtimestamp (sig->timestamp), |
strtimestamp (sig->timestamp), |
197 |
uid, keyid, |
uid, keyid, |
198 |
novalid? "\nPrimary key fingerprint: " : "", |
novalid? "\nPrimary key fingerprint: " : "", |
199 |
novalid? get_key_fpr (key) : ""); |
novalid? get_key_fpr (key.ctx) : ""); |
|
safe_free (uid); |
|
200 |
} |
} |
201 |
|
|
202 |
leave: |
leave: |