diff --git a/g10/ChangeLog b/g10/ChangeLog index c76d0f561..a17c809e9 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,10 @@ +2009-01-13 Werner Koch + + * call-agent.c (dummy_data_cb): New. + (agent_learn): Use it. + * card-util.c (card_status): Print type of non-OpenPGP card. + * call-agent.h (agent_card_info_s): Add field APPTYPE. + 2009-01-12 Werner Koch * getkey.c (finish_lookup): Take care of keys with a zero diff --git a/g10/call-agent.c b/g10/call-agent.c index 33025ef27..57d963dfd 100644 --- a/g10/call-agent.c +++ b/g10/call-agent.c @@ -208,6 +208,17 @@ store_serialno (const char *line) +/* This is a dummy data line callback. */ +static int +dummy_data_cb (void *opaque, const void *buffer, size_t length) +{ + (void)opaque; + (void)buffer; + (void)length; + return 0; +} + + /* This is the default inquiry callback. It mainly handles the Pinentry notifications. */ static int @@ -239,6 +250,7 @@ agent_release_card_info (struct agent_card_info_s *info) return; xfree (info->serialno); info->serialno = NULL; + xfree (info->apptype); info->apptype = NULL; xfree (info->disp_name); info->disp_name = NULL; xfree (info->disp_lang); info->disp_lang = NULL; xfree (info->pubkey_url); info->pubkey_url = NULL; @@ -267,6 +279,11 @@ learn_status_cb (void *opaque, const char *line) parm->is_v2 = (strlen (parm->serialno) >= 16 && xtoi_2 (parm->serialno+12) >= 2 ); } + else if (keywordlen == 7 && !memcmp (keyword, "APPTYPE", keywordlen)) + { + xfree (parm->apptype); + parm->apptype = unescape_status_string (line); + } else if (keywordlen == 9 && !memcmp (keyword, "DISP-NAME", keywordlen)) { xfree (parm->disp_name); @@ -372,7 +389,7 @@ agent_learn (struct agent_card_info_s *info) memset (info, 0, sizeof *info); rc = assuan_transact (agent_ctx, "LEARN --send", - NULL, NULL, default_inq_cb, NULL, + dummy_data_cb, NULL, default_inq_cb, NULL, learn_status_cb, info); return rc; diff --git a/g10/call-agent.h b/g10/call-agent.h index ee69793fa..ef4ad85c5 100644 --- a/g10/call-agent.h +++ b/g10/call-agent.h @@ -23,6 +23,7 @@ struct agent_card_info_s { int error; /* private. */ + char *apptype; /* Malloced application type string. */ 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 e25427f51..24a7b094b 100644 --- a/g10/card-util.c +++ b/g10/card-util.c @@ -369,8 +369,29 @@ card_status (FILE *fp, char *serialno, size_t serialnobuflen) if (!info.serialno || strncmp (info.serialno, "D27600012401", 12) || strlen (info.serialno) != 32 ) { - if (opt.with_colons) - fputs ("unknown:\n", fp); + if (info.apptype && !strcmp (info.apptype, "NKS")) + { + if (opt.with_colons) + fputs ("netkey-card:\n", fp); + log_info ("this is a NetKey card\n"); + } + else if (info.apptype && !strcmp (info.apptype, "DINSIG")) + { + if (opt.with_colons) + fputs ("dinsig-card:\n", fp); + log_info ("this is a DINSIG compliant card\n"); + } + else if (info.apptype && !strcmp (info.apptype, "P15")) + { + if (opt.with_colons) + fputs ("pkcs15-card:\n", fp); + log_info ("this is a PKCS#15 compliant card\n"); + } + else + { + if (opt.with_colons) + fputs ("unknown:\n", fp); + } log_info ("not an OpenPGP card\n"); agent_release_card_info (&info); xfree (pk); diff --git a/scd/command.c b/scd/command.c index 31c5f1748..c2b97e64d 100644 --- a/scd/command.c +++ b/scd/command.c @@ -543,7 +543,8 @@ cmd_serialno (assuan_context_t ctx, char *line) P15 = PKCS-15 structure used DINSIG = DIN SIG OPENPGP = OpenPGP card - + NKS = NetKey card + are implemented. These strings are aliases for the AID S KEYPAIRINFO diff --git a/tests/openpgp/samplekeys/README b/tests/openpgp/samplekeys/README new file mode 100644 index 000000000..d38616990 --- /dev/null +++ b/tests/openpgp/samplekeys/README @@ -0,0 +1,4 @@ + +no-creation-time.gpg A key with a zero creation time. + + diff --git a/tests/openpgp/samplekeys/no-creation-time.gpg b/tests/openpgp/samplekeys/no-creation-time.gpg new file mode 100644 index 000000000..94275f2be Binary files /dev/null and b/tests/openpgp/samplekeys/no-creation-time.gpg differ