check DF name on SELECT command

This commit is contained in:
NIIBE Yutaka
2012-01-05 15:14:35 +09:00
parent a4e0e67340
commit 41537cc827
3 changed files with 15 additions and 8 deletions

View File

@@ -1,5 +1,7 @@
2012-01-05 Niibe Yutaka <gniibe@fsij.org> 2012-01-05 Niibe Yutaka <gniibe@fsij.org>
* src/openpgp.c (cmd_select_file): Check DF name.
* tool/pinpadtest.py: Rename from pinpad-test.py. * tool/pinpadtest.py: Rename from pinpad-test.py.
2011-12-28 Niibe Yutaka <gniibe@fsij.org> 2011-12-28 Niibe Yutaka <gniibe@fsij.org>

View File

@@ -417,10 +417,12 @@ do_kgtime_all (uint16_t tag, int with_tag)
} }
const uint8_t openpgpcard_aid[] = { const uint8_t openpgpcard_aid[] = {
0xd2, 0x76, 0x00, 0x01, 0x24, 0x01, 0xd2, 0x76, /* D: National, 276: DEU ISO 3166-1 */
0x00, 0x01, 0x24, /* Registered Application Provider Identifier */
0x01, /* Application: OpenPGPcard */
0x02, 0x00, /* Version 2.0 */ 0x02, 0x00, /* Version 2.0 */
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* To be overwritten */
/* v. id */ /* serial number */ /* v. id */ /* serial number */
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* To be overwritten */
}; };
static int static int

View File

@@ -529,16 +529,19 @@ cmd_read_binary (void)
static void static void
cmd_select_file (void) cmd_select_file (void)
{ {
if (cmd_APDU[2] == 4) /* Selection by DF name: it must be OpenPGP card */ if (cmd_APDU[2] == 4) /* Selection by DF name */
{ {
DEBUG_INFO (" - select DF by name\r\n"); DEBUG_INFO (" - select DF by name\r\n");
/* /* name = D2 76 00 01 24 01 */
* P2 == 0, LC=6, name = D2 76 00 01 24 01 if (cmd_APDU[4] != 6 || memcmp (openpgpcard_aid, &cmd_APDU[5], 6) != 0)
*/ {
GPG_NO_FILE()
return;
}
file_selection = FILE_DF_OPENPGP; file_selection = FILE_DF_OPENPGP;
if (cmd_APDU[3] == 0x0c) /* No FCI */ if ((cmd_APDU[3] & 0x0c) == 0x0c) /* No FCI */
GPG_SUCCESS (); GPG_SUCCESS ();
else else
{ {