From fc3048f55ed8c531e63865f11c01cedfe7d24cc4 Mon Sep 17 00:00:00 2001 From: martin Date: Sat, 13 Aug 2005 13:04:02 +0000 Subject: [PATCH] Remove the (stupid) use_pinpad option from pkcs15 structures git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2482 c6295689-39f2-0310-b995-f0e70906c6a9 --- etc/opensc.conf.in | 4 ---- src/libopensc/pkcs15-pin.c | 48 ++++++++++++-------------------------- src/libopensc/pkcs15.c | 2 -- src/libopensc/pkcs15.h | 1 - 4 files changed, 15 insertions(+), 40 deletions(-) diff --git a/etc/opensc.conf.in b/etc/opensc.conf.in index 00f274c2..202eb044 100644 --- a/etc/opensc.conf.in +++ b/etc/opensc.conf.in @@ -237,10 +237,6 @@ app default { # Default: false # use_caching = true; - # If the given slot has pinpad capabilities, default to pinpad enabled - # operation and don't do pointless guessing - # Default: false - use_pinpad = false; # Enable pkcs15 emulation. # Default: yes enable_pkcs15_emulation = yes; diff --git a/src/libopensc/pkcs15-pin.c b/src/libopensc/pkcs15-pin.c index d9c125a0..6a1071b6 100644 --- a/src/libopensc/pkcs15-pin.c +++ b/src/libopensc/pkcs15-pin.c @@ -170,7 +170,7 @@ static int _validate_pin(struct sc_pkcs15_card *p15card, return SC_ERROR_BUFFER_TOO_SMALL; /* if we use pinpad, no more checks are needed */ - if (p15card->opts.use_pinpad) + if (p15card->card->slot->capabilities & SC_SLOT_CAP_PIN_PAD) return SC_SUCCESS; /* If pin is given, make sure it is within limits */ @@ -205,10 +205,8 @@ int sc_pkcs15_verify_pin(struct sc_pkcs15_card *p15card, /* the path in the pin object is optional */ if (pin->path.len > 0) { r = sc_select_file(card, &pin->path, NULL); - if (r) { - sc_unlock(card); - return r; - } + if (r) + goto out; } /* Initialize arguments */ @@ -220,6 +218,8 @@ int sc_pkcs15_verify_pin(struct sc_pkcs15_card *p15card, data.pin1.max_length = pin->max_length; data.pin1.pad_length = pin->stored_length; data.pin1.pad_char = pin->pad_char; + data.pin1.data = pincode; + data.pin1.len = pinlen; if (pin->flags & SC_PKCS15_PIN_FLAG_NEEDS_PADDING) data.flags |= SC_PIN_CMD_NEED_PADDING; @@ -236,13 +236,7 @@ int sc_pkcs15_verify_pin(struct sc_pkcs15_card *p15card, data.pin1.encoding = 0; } - if (pinlen != 0) { - /* Good old-fashioned PIN verification */ - data.pin1.data = pincode; - data.pin1.len = pinlen; - } else { - /* Use the reader's PIN PAD */ - /* XXX need some sort of internationalization here */ + if(p15card->card->slot->capabilities & SC_SLOT_CAP_PIN_PAD) { data.flags |= SC_PIN_CMD_USE_PINPAD; if (pin->flags & SC_PKCS15_PIN_FLAG_SO_PIN) data.pin1.prompt = "Please enter SO PIN"; @@ -251,7 +245,7 @@ int sc_pkcs15_verify_pin(struct sc_pkcs15_card *p15card, } r = sc_pin_cmd(card, &data, &pin->tries_left); - +out: sc_unlock(card); return r; } @@ -274,21 +268,14 @@ int sc_pkcs15_change_pin(struct sc_pkcs15_card *p15card, if ((r = _validate_pin(p15card, pin, newpinlen)) != SC_SUCCESS) return r; - /* pin change with pin pad reader not yet supported */ - if ((p15card->card->slot->capabilities & SC_SLOT_CAP_PIN_PAD) && - (oldpin == NULL || newpin == NULL || oldpinlen == 0 || newpinlen == 0)) - return SC_ERROR_NOT_SUPPORTED; - card = p15card->card; r = sc_lock(card); SC_TEST_RET(card->ctx, r, "sc_lock() failed"); /* the path in the pin object is optional */ if (pin->path.len > 0) { r = sc_select_file(card, &pin->path, NULL); - if (r) { - sc_unlock(card); - return r; - } + if (r) + goto out; } /* set pin_cmd data */ @@ -323,7 +310,7 @@ int sc_pkcs15_change_pin(struct sc_pkcs15_card *p15card, break; } - if(p15card->opts.use_pinpad) { + if(p15card->card->slot->capabilities & SC_SLOT_CAP_PIN_PAD) { data.flags |= SC_PIN_CMD_USE_PINPAD; if (pin->flags & SC_PKCS15_PIN_FLAG_SO_PIN) { data.pin1.prompt = "Please enter SO PIN"; @@ -336,6 +323,7 @@ int sc_pkcs15_change_pin(struct sc_pkcs15_card *p15card, r = sc_pin_cmd(card, &data, &pin->tries_left); +out: sc_unlock(card); return r; } @@ -358,11 +346,6 @@ int sc_pkcs15_unblock_pin(struct sc_pkcs15_card *p15card, if ((r = _validate_pin(p15card, pin, newpinlen)) != SC_SUCCESS) return r; - /* pin change with pin pad reader not yet supported */ - if ((p15card->card->slot->capabilities & SC_SLOT_CAP_PIN_PAD) && - (newpin == NULL || newpinlen == 0)) - return SC_ERROR_NOT_SUPPORTED; - card = p15card->card; /* get pin_info object of the puk (this is a little bit complicated * as we don't have the id of the puk (at least now)) @@ -392,10 +375,8 @@ int sc_pkcs15_unblock_pin(struct sc_pkcs15_card *p15card, /* the path in the pin object is optional */ if (pin->path.len > 0) { r = sc_select_file(card, &pin->path, NULL); - if (r) { - sc_unlock(card); - return r; - } + if (r) + goto out; } /* set pin_cmd data */ @@ -437,7 +418,7 @@ int sc_pkcs15_unblock_pin(struct sc_pkcs15_card *p15card, break; } - if(p15card->opts.use_pinpad) { + if(p15card->card->slot->capabilities & SC_SLOT_CAP_PIN_PAD) { data.flags |= SC_PIN_CMD_USE_PINPAD; if (pin->flags & SC_PKCS15_PIN_FLAG_SO_PIN) { data.pin1.prompt = "Please enter PUK"; @@ -450,6 +431,7 @@ int sc_pkcs15_unblock_pin(struct sc_pkcs15_card *p15card, r = sc_pin_cmd(card, &data, &pin->tries_left); +out: sc_unlock(card); return r; } diff --git a/src/libopensc/pkcs15.c b/src/libopensc/pkcs15.c index 144f1280..95f59a16 100644 --- a/src/libopensc/pkcs15.c +++ b/src/libopensc/pkcs15.c @@ -610,8 +610,6 @@ int sc_pkcs15_bind(sc_card_t *card, if (conf_block) { p15card->opts.use_cache = scconf_get_bool(conf_block, "use_caching", 0); - p15card->opts.use_pinpad = scconf_get_bool(conf_block, "use_pinpad", 0) - && card->slot->capabilities & SC_SLOT_CAP_PIN_PAD; } r = sc_lock(card); diff --git a/src/libopensc/pkcs15.h b/src/libopensc/pkcs15.h index 008471c2..c21966da 100644 --- a/src/libopensc/pkcs15.h +++ b/src/libopensc/pkcs15.h @@ -354,7 +354,6 @@ typedef struct sc_pkcs15_card { struct sc_pkcs15_card_opts { int use_cache; - int use_pinpad; } opts; unsigned int magic;