diff options
author | Werner Koch <[email protected]> | 2020-04-03 08:00:57 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2020-04-15 13:18:41 +0000 |
commit | 88b456bdf4e4763e8f1b718f5597d4d075d989cd (patch) | |
tree | 6b588e49fec96807a854ef316eacebfbd4273e88 | |
parent | scd:openpgp: New attribute "MANUFACTURER". (diff) | |
download | gnupg-88b456bdf4e4763e8f1b718f5597d4d075d989cd.tar.gz gnupg-88b456bdf4e4763e8f1b718f5597d4d075d989cd.zip |
gpg: Use the new MANUFACTURER attribute.
* g10/call-agent.h (struct agent_card_info_s): Add manufacturer fields.
* g10/call-agent.c (agent_release_card_info): Release them.
(learn_status_cb): Parse MANUFACTURER attribute.
* g10/card-util.c (get_manufacturer): Remove.
(current_card_status): Use new attribute.
--
This does away with the duplicated OpenPGP vendor tables; they are now
at a better place (app-openpgp.c).
Signed-off-by: Werner Koch <[email protected]>
Backported from master:
- Removed the gpg-card stuff.
Signed-off-by: Werner Koch <[email protected]>
-rw-r--r-- | g10/call-agent.c | 12 | ||||
-rw-r--r-- | g10/call-agent.h | 2 | ||||
-rw-r--r-- | g10/card-util.c | 49 |
3 files changed, 20 insertions, 43 deletions
diff --git a/g10/call-agent.c b/g10/call-agent.c index 574f6cada..6ebb8383e 100644 --- a/g10/call-agent.c +++ b/g10/call-agent.c @@ -484,6 +484,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; @@ -507,6 +508,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++) ; @@ -706,6 +708,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 94ca1543a..bc8c3927a 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 3aaea84b7..00b64b34b 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."; - 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_sha1_fpr (estream_t fp, const unsigned char *fpr) @@ -393,6 +353,7 @@ current_card_status (ctrl_t ctrl, estream_t fp, unsigned int uval; const unsigned char *thefpr; int i; + char *pesc; if (serialno && serialnobuflen) *serialno = 0; @@ -479,7 +440,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); @@ -572,8 +536,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); |