293 |
} |
} |
294 |
*/ |
*/ |
295 |
|
|
296 |
|
|
297 |
|
/* Extract the serial number from the card ID @id and return it. */ |
298 |
|
const char* |
299 |
|
extract_serial_no (const char *id) |
300 |
|
{ |
301 |
|
static char buf[8]; |
302 |
|
char *p; |
303 |
|
|
304 |
|
p = strchr (id, '/'); |
305 |
|
if (!p) |
306 |
|
return NULL; |
307 |
|
strncpy (buf, id+(p-id)-6, 6); |
308 |
|
return buf; |
309 |
|
} |
310 |
|
|
311 |
|
|
312 |
/* Passphrase callback with the ability to support caching. */ |
/* Passphrase callback with the ability to support caching. */ |
313 |
gpgme_error_t |
gpgme_error_t |
314 |
passphrase_cb (void *hook, const char *uid_hint, |
passphrase_cb (void *hook, const char *uid_hint, |
364 |
/* if @passphrase_info contains 'OPENPGP' we assume a smart card |
/* if @passphrase_info contains 'OPENPGP' we assume a smart card |
365 |
has been used. */ |
has been used. */ |
366 |
if (strstr (passphrase_info, "OPENPGP")) { |
if (strstr (passphrase_info, "OPENPGP")) { |
367 |
char buf[16]; |
const char *s=passphrase_info; |
368 |
memset (buf, 0, sizeof buf); |
while (s && *s && *s != 'D') |
369 |
strncpy (buf, "??", 2); /* XXX: fixme we need the serial no. */ |
s++; |
370 |
_snprintf (c->info, sizeof c->info-1, |
_snprintf (c->info, sizeof c->info-1, |
371 |
_("Please enter the PIN to unlock your secret card key\n" |
_("Please enter the PIN to unlock your secret card key\n" |
372 |
"Card: %s"), buf); |
"Card: %s"), extract_serial_no (s)); |
373 |
c->is_card = 1; |
c->is_card = 1; |
374 |
} |
} |
375 |
else if (uid_hint) |
else if (uid_hint) |