From 5991dfb433ce39f942ddb07994a1654452f85edd Mon Sep 17 00:00:00 2001 From: martin Date: Thu, 11 Feb 2010 14:50:18 +0000 Subject: [PATCH] Remove the dummy EMV driver. git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4021 c6295689-39f2-0310-b995-f0e70906c6a9 --- src/libopensc/Makefile.am | 2 +- src/libopensc/Makefile.mak | 2 +- src/libopensc/card-emv.c | 159 ------------------------------------- src/libopensc/cards.h | 1 - src/libopensc/ctx.c | 2 - src/libopensc/opensc.h | 2 +- 6 files changed, 3 insertions(+), 165 deletions(-) delete mode 100644 src/libopensc/card-emv.c diff --git a/src/libopensc/Makefile.am b/src/libopensc/Makefile.am index ad3b7f8e..abe84002 100644 --- a/src/libopensc/Makefile.am +++ b/src/libopensc/Makefile.am @@ -34,7 +34,7 @@ libopensc_la_SOURCES = \ ctbcs.c reader-ctapi.c reader-pcsc.c reader-openct.c \ \ card-setcos.c card-miocos.c card-flex.c card-gpk.c \ - card-cardos.c card-tcos.c card-emv.c card-default.c \ + card-cardos.c card-tcos.c card-default.c \ card-mcrd.c card-starcos.c card-openpgp.c card-jcop.c \ card-oberthur.c card-belpic.c card-atrust-acos.c card-entersafe.c \ card-incrypto34.c card-piv.c card-muscle.c card-acos5.c \ diff --git a/src/libopensc/Makefile.mak b/src/libopensc/Makefile.mak index bca7664c..24df6145 100644 --- a/src/libopensc/Makefile.mak +++ b/src/libopensc/Makefile.mak @@ -20,7 +20,7 @@ OBJECTS = \ ctbcs.obj reader-ctapi.obj reader-pcsc.obj reader-openct.obj \ \ card-setcos.obj card-miocos.obj card-flex.obj card-gpk.obj \ - card-cardos.obj card-tcos.obj card-emv.obj card-default.obj \ + card-cardos.obj card-tcos.obj card-default.obj \ card-mcrd.obj card-starcos.obj card-openpgp.obj card-jcop.obj \ card-oberthur.obj card-belpic.obj card-atrust-acos.obj card-entersafe.obj \ card-incrypto34.obj card-piv.obj card-muscle.obj card-acos5.obj \ diff --git a/src/libopensc/card-emv.c b/src/libopensc/card-emv.c deleted file mode 100644 index cb8ca00b..00000000 --- a/src/libopensc/card-emv.c +++ /dev/null @@ -1,159 +0,0 @@ -/* - * card-emv.c: Functions specified by the EMV standard - * - * Copyright (C) 2001, 2002 Juha Yrjölä - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "internal.h" -#include - -static struct sc_card_operations emv_ops; -static struct sc_card_driver emv_drv = { - "EMV cards (unsupported)", - "emv", - &emv_ops, - NULL, 0, NULL -}; - -static int emv_finish(sc_card_t *card) -{ - return SC_SUCCESS; -} - -static int parse_atr(const u8 *atr, size_t atr_len, int *t0_out, int *tx1, int *tx2, - u8 *hist_bytes, int *hbcount) -{ - const u8 *p = atr; - int len = atr_len; - int nr_hist_bytes, tx, i; - - if (len < 2) - return -1; - p++; - len--; - *t0_out = *p; - nr_hist_bytes = *p & 0x0F; - tx = *p >> 4; - p++; - for (i = 0; i < 4; i++) - tx1[i] = tx2[i] = -1; - for (i = 0; i < 4; i++) - if (tx & (1 << i)) { - if (len <= 0) - return -1; - tx1[i] = *p++; - len--; - } - if (tx1[3] != -1) { - tx = tx1[3] >> 4; - for (i = 0; i < 4; i++) - if (tx & (1 << i)) { - if (len <= 0) - return -1; - tx2[i] = *p++; - len--; - } - } - /* FIXME: possibly check TD2 */ - if (hist_bytes == NULL || nr_hist_bytes == 0) - return 0; - if (len < nr_hist_bytes) - return -1; - memcpy(hist_bytes, p, nr_hist_bytes); - *hbcount = nr_hist_bytes; - - return 0; -} - -static int emv_match_card(sc_card_t *card) -{ - int i, r, hbcount = 0, match = 1; - int tx1[4], tx2[4], t0; - char line[200], *linep = line; - u8 hist_bytes[32]; - - r = parse_atr(card->atr, card->atr_len, &t0, tx1, tx2, hist_bytes, &hbcount); - if (r) - return 0; - for (i = 0; i < 4; i++) - if (tx1[i] != -1) - linep += sprintf(linep, "T%c1 = 0x%02X ", 'A' + i, tx1[i]); - for (i = 0; i < 4; i++) - if (tx2[i] != -1) - linep += sprintf(linep, "T%c2 = 0x%02X ", 'A' + i, tx2[i]); - if (card->ctx->debug >= 4) { - sc_debug(card->ctx, "ATR parse: %s\n", line); - if (hbcount) { - sc_hex_dump(card->ctx, hist_bytes, hbcount, line, sizeof(line)); - sc_debug(card->ctx, "historic bytes:\n%s", line); - } - } - if ((t0 & 0xF0) != 0x60) - match = 0; - if (match && tx1[1] != 0x00) - match = 0; - if (match && tx1[2] == -1) - match = 0; - if (match) - for (i = 0; i < 4; i++) - if (tx2[i] != -1) - match = 0; - return match; -} - -static int emv_init(sc_card_t *card) -{ - card->drv_data = NULL; - card->cla = 0x00; - - return SC_SUCCESS; -} - -static int emv_select_file(sc_card_t *card, const sc_path_t *path, - sc_file_t **file) -{ - int r; - struct sc_card_driver *iso_drv = sc_get_iso7816_driver(); - const struct sc_card_operations *ops = iso_drv->ops; - - r = ops->select_file(card, path, file); - if (r) - return r; - if (file != NULL && path->len == 2 && memcmp(path->value, "\x3F\x00", 2) == 0) - (*file)->type = SC_FILE_TYPE_DF; - if (file != NULL && (*file)->namelen) - (*file)->type = SC_FILE_TYPE_DF; - return SC_SUCCESS; -} - -static struct sc_card_driver * sc_get_driver(void) -{ - struct sc_card_driver *iso_drv = sc_get_iso7816_driver(); - - emv_ops = *iso_drv->ops; - emv_ops.match_card = emv_match_card; - emv_ops.init = emv_init; - emv_ops.finish = emv_finish; - emv_ops.select_file = emv_select_file; - - return &emv_drv; -} - -struct sc_card_driver * sc_get_emv_driver(void) -{ - return sc_get_driver(); -} diff --git a/src/libopensc/cards.h b/src/libopensc/cards.h index 0997758d..ad6b32e7 100644 --- a/src/libopensc/cards.h +++ b/src/libopensc/cards.h @@ -167,7 +167,6 @@ enum { }; extern sc_card_driver_t *sc_get_default_driver(void); -extern sc_card_driver_t *sc_get_emv_driver(void); extern sc_card_driver_t *sc_get_cardos_driver(void); extern sc_card_driver_t *sc_get_cryptoflex_driver(void); extern sc_card_driver_t *sc_get_cyberflex_driver(void); diff --git a/src/libopensc/ctx.c b/src/libopensc/ctx.c index d718e68c..6a202322 100644 --- a/src/libopensc/ctx.c +++ b/src/libopensc/ctx.c @@ -78,8 +78,6 @@ static const struct _sc_driver_entry internal_card_drivers[] = { { "rutoken_ecp",(void *(*)(void)) sc_get_rtecp_driver }, { "westcos", (void *(*)(void)) sc_get_westcos_driver }, { "myeid", (void *(*)(void)) sc_get_myeid_driver }, - /* emv is not really implemented */ - { "emv", (void *(*)(void)) sc_get_emv_driver }, /* Here should be placed drivers that need some APDU transactions to * recognise its cards. */ diff --git a/src/libopensc/opensc.h b/src/libopensc/opensc.h index ded4c10e..afd6c040 100644 --- a/src/libopensc/opensc.h +++ b/src/libopensc/opensc.h @@ -763,7 +763,7 @@ unsigned int sc_ctx_get_reader_count(sc_context_t *ctx); /** * Forces the use of a specified card driver * @param ctx OpenSC context - * @param short_name The short name of the driver to use (e.g. 'emv') + * @param short_name The short name of the driver to use (e.g. 'cardos') */ int sc_set_card_driver(sc_context_t *ctx, const char *short_name); /**