aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--g10/call-agent.c12
-rw-r--r--g10/call-agent.h2
-rw-r--r--g10/card-util.c49
-rw-r--r--tools/card-call-scd.c13
-rw-r--r--tools/gpg-card.c52
-rw-r--r--tools/gpg-card.h2
6 files changed, 42 insertions, 88 deletions
diff --git a/g10/call-agent.c b/g10/call-agent.c
index 98d965cbe..5c6a4a66d 100644
--- a/g10/call-agent.c
+++ b/g10/call-agent.c
@@ -517,6 +517,7 @@ agent_release_card_info (struct agent_card_info_s *info)
return;
xfree (info->reader); info->reader = NULL;
+ xfree (info->manufacturer_name); info->manufacturer_name = NULL;
xfree (info->serialno); info->serialno = NULL;
xfree (info->apptype); info->apptype = NULL;
xfree (info->disp_name); info->disp_name = NULL;
@@ -540,6 +541,7 @@ learn_status_cb (void *opaque, const char *line)
const char *keyword = line;
int keywordlen;
int i;
+ char *endp;
for (keywordlen=0; *line && !spacep (line); line++, keywordlen++)
;
@@ -741,6 +743,16 @@ learn_status_cb (void *opaque, const char *line)
xfree (parm->private_do[no]);
parm->private_do[no] = unescape_status_string (line);
}
+ else if (keywordlen == 12 && !memcmp (keyword, "MANUFACTURER", 12))
+ {
+ xfree (parm->manufacturer_name);
+ parm->manufacturer_name = NULL;
+ parm->manufacturer_id = strtoul (line, &endp, 0);
+ while (endp && spacep (endp))
+ endp++;
+ if (endp && *endp)
+ parm->manufacturer_name = xstrdup (endp);
+ }
else if (keywordlen == 3 && !memcmp (keyword, "KDF", 3))
{
unsigned char *data = unescape_status_string (line);
diff --git a/g10/call-agent.h b/g10/call-agent.h
index 8df5ff5a3..be5c777d4 100644
--- a/g10/call-agent.h
+++ b/g10/call-agent.h
@@ -32,6 +32,8 @@ struct agent_card_info_s
int error; /* private. */
char *reader; /* Reader information. */
char *apptype; /* Malloced application type string. */
+ unsigned int manufacturer_id;
+ char *manufacturer_name; /* malloced. */
char *serialno; /* malloced hex string. */
char *disp_name; /* malloced. */
char *disp_lang; /* malloced. */
diff --git a/g10/card-util.c b/g10/card-util.c
index 98adc61ad..cf365e9d2 100644
--- a/g10/card-util.c
+++ b/g10/card-util.c
@@ -192,46 +192,6 @@ change_pin (int unblock_v2, int allow_admin)
agent_release_card_info (&info);
}
-static const char *
-get_manufacturer (unsigned int no)
-{
- /* Note: Make sure that there is no colon or linefeed in the string. */
- switch (no)
- {
- case 0x0001: return "PPC Card Systems";
- case 0x0002: return "Prism";
- case 0x0003: return "OpenFortress";
- case 0x0004: return "Wewid";
- case 0x0005: return "ZeitControl";
- case 0x0006: return "Yubico";
- case 0x0007: return "OpenKMS";
- case 0x0008: return "LogoEmail";
- case 0x0009: return "Fidesmo";
- case 0x000A: return "Dangerous Things";
- case 0x000B: return "Feitian Technologies";
-
- case 0x002A: return "Magrathea";
- case 0x0042: return "GnuPG e.V.";
-
- case 0x1337: return "Warsaw Hackerspace";
- case 0x2342: return "warpzone"; /* hackerspace Muenster. */
- case 0x4354: return "Confidential Technologies"; /* cotech.de */
- case 0x5443: return "TIF-IT e.V."; break;
- case 0x63AF: return "Trustica";
- case 0xBA53: return "c-base e.V.";
- case 0xBD0E: return "Paranoidlabs";
- case 0xF517: return "FSIJ";
- case 0xF5EC: return "F-Secure";
-
- /* 0x0000 and 0xFFFF are defined as test cards per spec,
- 0xFF00 to 0xFFFE are assigned for use with randomly created
- serial numbers. */
- case 0x0000:
- case 0xffff: return "test card";
- default: return (no & 0xff00) == 0xff00? "unmanaged S/N range":"unknown";
- }
-}
-
static void
print_shax_fpr (estream_t fp, const unsigned char *fpr, unsigned int fprlen)
@@ -396,6 +356,7 @@ current_card_status (ctrl_t ctrl, estream_t fp,
const unsigned char *thefpr;
unsigned int thefprlen;
int i;
+ char *pesc;
if (serialno && serialnobuflen)
*serialno = 0;
@@ -482,7 +443,10 @@ current_card_status (ctrl_t ctrl, estream_t fp,
{
es_fprintf (fp, "version:%.4s:\n", info.serialno+12);
uval = xtoi_2(info.serialno+16)*256 + xtoi_2 (info.serialno+18);
- es_fprintf (fp, "vendor:%04x:%s:\n", uval, get_manufacturer (uval));
+ pesc = (info.manufacturer_name
+ ? percent_escape (info.manufacturer_name, NULL) : NULL);
+ es_fprintf (fp, "vendor:%04x:%s:\n", uval, pesc? pesc:"");
+ xfree (pesc);
es_fprintf (fp, "serial:%.8s:\n", info.serialno+20);
print_isoname (fp, "Name of cardholder: ", "name", info.disp_name);
@@ -583,8 +547,7 @@ current_card_status (ctrl_t ctrl, estream_t fp,
info.serialno[14] == '0'?"":info.serialno+14,
info.serialno[15]);
tty_fprintf (fp, "Manufacturer .....: %s\n",
- get_manufacturer (xtoi_2(info.serialno+16)*256
- + xtoi_2 (info.serialno+18)));
+ info.manufacturer_name? info.manufacturer_name : "?");
tty_fprintf (fp, "Serial number ....: %.8s\n", info.serialno+20);
print_isoname (fp, "Name of cardholder: ", "name", info.disp_name);
diff --git a/tools/card-call-scd.c b/tools/card-call-scd.c
index bcf630a28..c6ae5edd4 100644
--- a/tools/card-call-scd.c
+++ b/tools/card-call-scd.c
@@ -139,6 +139,7 @@ release_card_info (card_info_t info)
xfree (info->reader); info->reader = NULL;
xfree (info->cardtype); info->cardtype = NULL;
+ xfree (info->manufacturer_name); info->manufacturer_name = NULL;
xfree (info->serialno); info->serialno = NULL;
xfree (info->dispserialno); info->dispserialno = NULL;
xfree (info->apptypestr); info->apptypestr = NULL;
@@ -648,7 +649,7 @@ learn_status_cb (void *opaque, const char *line)
const char *keyword = line;
int keywordlen;
char *line_buffer = NULL; /* In case we need a copy. */
- char *pline;
+ char *pline, *endp;
key_info_t kinfo;
const char *keyref;
int i;
@@ -1012,6 +1013,16 @@ learn_status_cb (void *opaque, const char *line)
xfree (parm->private_do[no]);
parm->private_do[no] = unescape_status_string (line);
}
+ else if (!memcmp (keyword, "MANUFACTURER", 12))
+ {
+ xfree (parm->manufacturer_name);
+ parm->manufacturer_name = NULL;
+ parm->manufacturer_id = strtoul (line, &endp, 0);
+ while (endp && spacep (endp))
+ endp++;
+ if (endp && *endp)
+ parm->manufacturer_name = xstrdup (endp);
+ }
break;
case 13:
diff --git a/tools/gpg-card.c b/tools/gpg-card.c
index c79f98a21..03b5c8c18 100644
--- a/tools/gpg-card.c
+++ b/tools/gpg-card.c
@@ -493,47 +493,6 @@ print_help (const char *text, ...)
}
-/* Return the OpenPGP card manufacturer name. */
-static const char *
-get_manufacturer (unsigned int no)
-{
- /* Note: Make sure that there is no colon or linefeed in the string. */
- switch (no)
- {
- case 0x0001: return "PPC Card Systems";
- case 0x0002: return "Prism";
- case 0x0003: return "OpenFortress";
- case 0x0004: return "Wewid";
- case 0x0005: return "ZeitControl";
- case 0x0006: return "Yubico";
- case 0x0007: return "OpenKMS";
- case 0x0008: return "LogoEmail";
- case 0x0009: return "Fidesmo";
- case 0x000A: return "Dangerous Things";
- case 0x000B: return "Feitian Technologies";
-
- case 0x002A: return "Magrathea";
- case 0x0042: return "GnuPG e.V.";
-
- case 0x1337: return "Warsaw Hackerspace";
- case 0x2342: return "warpzone"; /* hackerspace Muenster. */
- case 0x4354: return "Confidential Technologies"; /* cotech.de */
- case 0x5443: return "TIF-IT e.V.";
- case 0x63AF: return "Trustica";
- case 0xBA53: return "c-base e.V.";
- case 0xBD0E: return "Paranoidlabs";
- case 0xF517: return "FSIJ";
- case 0xF5EC: return "F-Secure";
-
- /* 0x0000 and 0xFFFF are defined as test cards per spec,
- * 0xFF00 to 0xFFFE are assigned for use with randomly created
- * serial numbers. */
- case 0x0000:
- case 0xffff: return "test card";
- default: return (no & 0xff00) == 0xff00? "unmanaged S/N range":"unknown";
- }
-}
-
/* Print an (OpenPGP) fingerprint. */
static void
print_shax_fpr (estream_t fp, const unsigned char *fpr, unsigned int fprlen)
@@ -841,9 +800,6 @@ list_openpgp (card_info_t info, estream_t fp, int no_key_lookup)
return;
}
- tty_fprintf (fp, "Manufacturer .....: %s\n",
- get_manufacturer (xtoi_2(info->serialno+16)*256
- + xtoi_2 (info->serialno+18)));
tty_fprintf (fp, "Name of cardholder: ");
print_isoname (fp, info->disp_name);
@@ -1006,6 +962,14 @@ list_card (card_info_t info, int no_key_lookup)
&& strcmp (info->serialno, info->dispserialno))
tty_fprintf (fp, "Displayed s/n ....: %s\n", info->dispserialno);
+ if (info->manufacturer_name && info->manufacturer_id)
+ tty_fprintf (fp, "Manufacturer .....: %s (%x)\n",
+ info->manufacturer_name, info->manufacturer_id);
+ else if (info->manufacturer_name && !info->manufacturer_id)
+ tty_fprintf (fp, "Manufacturer .....: %s\n", info->manufacturer_name);
+ else if (info->manufacturer_id)
+ tty_fprintf (fp, "Manufacturer .....: (%x)\n", info->manufacturer_id);
+
switch (info->apptype)
{
case APP_TYPE_OPENPGP: list_openpgp (info, fp, no_key_lookup); break;
diff --git a/tools/gpg-card.h b/tools/gpg-card.h
index 005316182..0e12955a1 100644
--- a/tools/gpg-card.h
+++ b/tools/gpg-card.h
@@ -145,6 +145,8 @@ struct card_info_s
char *apptypestr; /* Malloced application type string. */
app_type_t apptype;/* Translated from APPTYPESTR. */
unsigned int appversion; /* Version of the application. */
+ unsigned int manufacturer_id;
+ char *manufacturer_name; /* malloced. */
char *serialno; /* malloced hex string. */
char *dispserialno;/* malloced string. */
char *disp_name; /* malloced. */