47 |
static char *gpg_secring = NULL; |
static char *gpg_secring = NULL; |
48 |
|
|
49 |
|
|
50 |
|
/* Return 1 if no cache is available. |
51 |
|
This can be the case if WinPT were run in command line mode. */ |
52 |
int |
int |
53 |
keycache_not_available (void) |
keycache_not_available (void) |
54 |
{ |
{ |
60 |
void |
void |
61 |
keycache_release (int cleanup) |
keycache_release (int cleanup) |
62 |
{ |
{ |
|
int n = gpg_keycache_get_size (pub); |
|
63 |
char tmpbuf[64]; |
char tmpbuf[64]; |
64 |
|
int n = gpg_keycache_get_size (pub); |
65 |
|
|
66 |
/* XXX: update the value when the cache has changed. */ |
/* XXX: update the value when the cache has changed. */ |
67 |
sprintf (tmpbuf, "%d", n); |
_snprintf (tmpbuf, DIM (tmpbuf)-1, "%d", n); |
68 |
set_reg_key (HKEY_CURRENT_USER, "Software\\WinPT", "nKeys", tmpbuf); |
set_reg_key (HKEY_CURRENT_USER, "Software\\WinPT", "nKeys", tmpbuf); |
69 |
|
|
70 |
if (pub) { |
if (pub) { |
110 |
if (secring != NULL) { |
if (secring != NULL) { |
111 |
free_if_alloc (gpg_secring); |
free_if_alloc (gpg_secring); |
112 |
gpg_secring = get_gnupg_keyring (0, NO_STRICT); |
gpg_secring = get_gnupg_keyring (0, NO_STRICT); |
113 |
|
log_debug ("keycache_init: secring path '%s'\r\n", gpg_secring); |
114 |
} |
} |
115 |
|
|
116 |
p = get_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "nKeys"); |
p = get_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "nKeys"); |
253 |
} |
} |
254 |
|
|
255 |
|
|
|
|
|
256 |
/* Map the signature summary in @sum to signature status table index. |
/* Map the signature summary in @sum to signature status table index. |
257 |
Return value: index to table. */ |
Return value: index to table. */ |
258 |
static int |
static int |
259 |
sigsum_to_index (gpgme_sigsum_t sum) |
sigsum_to_index (gpgme_sigsum_t sum) |
260 |
{ |
{ |
261 |
if ((sum & GPGME_SIGSUM_VALID) && (sum & GPGME_SIGSUM_KEY_REVOKED)) |
if (sum & GPGME_SIGSUM_RED) |
262 |
|
return 2; |
263 |
|
else if (sum & GPGME_SIGSUM_SIG_EXPIRED) |
264 |
|
return 8; |
265 |
|
else if (sum & GPGME_SIGSUM_KEY_REVOKED) |
266 |
return 7; |
return 7; |
267 |
if ((sum & GPGME_SIGSUM_VALID) && (sum & GPGME_SIGSUM_SIG_EXPIRED)) |
else if (sum & GPGME_SIGSUM_KEY_EXPIRED) |
268 |
return 6; |
return 6; |
269 |
if (sum & GPGME_SIGSUM_GREEN) |
else if (sum & GPGME_SIGSUM_GREEN) |
270 |
return 1; |
return 1; |
|
else if (sum & GPGME_SIGSUM_RED) |
|
|
return 2; |
|
271 |
else if (sum & GPGME_SIGSUM_KEY_MISSING) |
else if (sum & GPGME_SIGSUM_KEY_MISSING) |
272 |
return 3; |
return 3; |
273 |
return 0; |
return 0; |
274 |
} |
} |
275 |
|
|
276 |
|
|
277 |
/* Return a humand readable description for the signature status @sum. */ |
/* Return a humand readable description for the signature status @sum. |
278 |
|
Warning: this function does not consider the validity of the key. */ |
279 |
const char* |
const char* |
280 |
get_gpg_sigstat (gpgme_sigsum_t sum) |
get_gpg_sigstat (gpgme_sigsum_t sum) |
281 |
{ |
{ |
282 |
const char *gpg_sigstat[] = { |
const char *gpg_sigstat[] = { |
283 |
_("Error during verification process."), |
_("Error during verification process"), |
284 |
_("The signature is good."), |
_("The signature is good"), |
285 |
_("The signature is BAD!"), |
_("The signature is BAD!"), |
286 |
_("The signature could not be checked due to a missing key."), |
_("The signature could not be checked due to a missing key"), |
287 |
_("No valid OpenPGP signature."), |
_("No valid OpenPGP signature"), |
288 |
_("Signature Error"), |
_("Signature Error"), |
289 |
_("Good Signature (Expired Key)"), |
_("Good signature (Expired Key)"), |
290 |
_("Good Signature (Revoked Key)"), |
_("Good signature (Revoked Key)"), |
291 |
|
_("Good signature (Expired)"), |
292 |
NULL |
NULL |
293 |
}; |
}; |
294 |
const unsigned int mask = 8; |
const unsigned int mask = 9; |
295 |
|
|
296 |
return gpg_sigstat[sigsum_to_index (sum) % mask]; |
return gpg_sigstat[sigsum_to_index (sum) % mask]; |
297 |
} |
} |
298 |
|
|
299 |
|
|
300 |
|
/* Return true if at least one secret key is available. */ |
301 |
bool |
bool |
302 |
secret_key_available (void) |
secret_key_available (void) |
303 |
{ |
{ |