From e1e359b4403485ec75640ff7750423a607e6e549 Mon Sep 17 00:00:00 2001 From: frankmorgner Date: Fri, 2 Sep 2011 15:38:01 +0000 Subject: [PATCH] fixed bugs for pin modification git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@519 96b47cad-a561-4643-ad3b-153ac7d7599c --- ccid/src/cats-test.c | 9 +++++++-- ccid/src/ccid.c | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ccid/src/cats-test.c b/ccid/src/cats-test.c index 33ca9fd..43bc7b0 100644 --- a/ccid/src/cats-test.c +++ b/ccid/src/cats-test.c @@ -284,6 +284,7 @@ main(int argc, char *argv[]) memcpy(&modify_ctl, recvbuf+i+2, 4); } } + if (0 == pace_ctl) { printf("Reader does not support PACE\n"); goto err; @@ -292,6 +293,8 @@ main(int argc, char *argv[]) pace_ctl = ntohl(pace_ctl); modify_ctl = ntohl(modify_ctl); +#define TESTPACE 1 +#ifdef TESTPACE recvlen = sizeof(recvbuf); sendbuf[0] = 0x01; /* idxFunction = GetReadersPACECapabilities */ sendbuf[1] = 0x00; /* lengthInputData */ @@ -338,6 +341,7 @@ main(int argc, char *argv[]) printf("Established PACE channel returned in %.0fs.\n", difftime(t_end, t_start)); +#endif #ifdef SIMULATE_TA_CA @@ -396,17 +400,18 @@ main(int argc, char *argv[]) } #endif +#define MODIFY_PIN 1 #ifdef MODIFY_PIN if (0 == modify_ctl) { printf("Reader does not support MODIFY_PIN_DIRECT\n"); goto err; } - BYTE = bufs2[] = {0x15, 0x05, 0x82, 0x08, 0x00, 0x00, 0x00, 0x06, 0x06, + BYTE bufs2[] = {0x15, 0x05, 0x82, 0x08, 0x00, 0x00, 0x00, 0x06, 0x06, 0x01, 0x02, 0x02, 0x09, 0x04, 0x00, 0x01, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x2C, 0x02, 0x03, 0x00}; recvlen = sizeof(recvbuf); - rv = SCardControl(hCard, modify_ioctl, bufs2, + r = SCardControl(hCard, modify_ctl, bufs2, sizeof bufs2, recvbuf, sizeof recvbuf, &recvlen); #endif diff --git a/ccid/src/ccid.c b/ccid/src/ccid.c index d3709ad..9d809af 100644 --- a/ccid/src/ccid.c +++ b/ccid/src/ccid.c @@ -703,7 +703,8 @@ write_pin_length(sc_apdu_t *apdu, const struct sc_pin_cmd_pin *pin, if (!apdu || !apdu->data || !pin || apdu->datalen <= pin->length_offset || !sc_result) { - *sc_result = SC_ERROR_INVALID_ARGUMENTS; + if (sc_result) + *sc_result = SC_ERROR_INVALID_ARGUMENTS; return 0; } @@ -1504,6 +1505,8 @@ int ccid_parse_bulkout(const __u8* inbuf, size_t inlen, __u8** outbuf) if (!inbuf) return 0; + bin_log(ctx, SC_LOG_DEBUG_VERBOSE, "CCID input", inbuf, inlen); + switch (*inbuf) { case 0x62: sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "PC_to_RDR_IccPowerOn");