From 38251aa74f92134ac164a0090b70e4a6bc2a0519 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 13 Jan 2009 14:01:56 +0000 Subject: [PATCH] Add a sample key. Detect and show the card type. --- g10/ChangeLog | 7 +++++ g10/call-agent.c | 19 ++++++++++++- g10/call-agent.h | 1 + g10/card-util.c | 25 ++++++++++++++++-- scd/command.c | 3 ++- tests/openpgp/samplekeys/README | 4 +++ tests/openpgp/samplekeys/no-creation-time.gpg | Bin 0 -> 979 bytes 7 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 tests/openpgp/samplekeys/README create mode 100644 tests/openpgp/samplekeys/no-creation-time.gpg 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 0000000000000000000000000000000000000000..94275f2bef752bfbcf0077d98db77748cadbbe28 GIT binary patch literal 979 zcmV;^11$W;z~BS`0000H1Ni}|@GbT#`O`+9P-8We$=&&f=?qG84ECv|;ws`}@|0E6 zlAbJ67HF3m_t~d_$f5*SFBQIOlVGm-cN{+8cgs_sEYvv^e&B}e5$?h(p+eihGy|cn zzR6GEzR(d!xA2w|3wBahEz39b0I!m001w*Ps7@+l~>2WJ4F#5o!g0Yj50 zkMH`vm5`bP9JgXs1Nh9Gq7LpAiqvYRdjBf!@bjd0h_^(pL-G`Go#V(CPs!bHWkp*( zb?qJQ zV!1bWkoFq{8;yVrwBB*+v3wfTEXj)`RfHZCMD?=+_>#BHyt5iUG9RVMN*0v%j0Mwe z(E9D~rg+SF@Q|GS7^PHNJ7;OI(Mj0yZGRHW^)7kxpWsyf;1XELNw03MU!{`*=$b8j z-gx6x3u`ld$n$2NPUc>UI#O#kVLoY^&6@wHU?*mLS@SK5BWPaM0) z)qQmUvb}ehG(V_Awp>0(;@5Q9hkp=LFC4ME9Bw{W`91q^L{!cz@lF*|N>?0x&FxS3 zyFxUqoJcw! B(X#*m literal 0 HcmV?d00001