diff options
author | jmagne <jmagne@fba4d07e-fe0f-4d7f-8147-e0026e666dc0> | 2009-01-24 00:08:01 +0000 |
---|---|---|
committer | jmagne <jmagne@fba4d07e-fe0f-4d7f-8147-e0026e666dc0> | 2009-01-24 00:08:01 +0000 |
commit | 51adf01a08aedd143927eb091491123f083f707f (patch) | |
tree | bb4c021f27ebdb15d53e0e697be7f5fa4edc1a77 /src | |
parent | d0af5393c77ab7f924ff7f754e92dc0640149cc4 (diff) |
Fix to allow protocol T1 cards to work. Bug# 479880.
git-svn-id: http://svn.fedorahosted.org/svn/coolkey/trunk@73 fba4d07e-fe0f-4d7f-8147-e0026e666dc0
Diffstat (limited to 'src')
-rw-r--r-- | src/libckyapplet/cky_card.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/libckyapplet/cky_card.c b/src/libckyapplet/cky_card.c index 41e1741..3c615e0 100644 --- a/src/libckyapplet/cky_card.c +++ b/src/libckyapplet/cky_card.c @@ -129,6 +129,7 @@ typedef struct _SCard { SCardGetStatusChangeFn SCardGetStatusChange; SCardCancelFn SCardCancel; SCARD_IO_REQUEST *SCARD_PCI_T0_; + SCARD_IO_REQUEST *SCARD_PCI_T1_; } SCard; #define GET_ADDRESS(library, scard, name) \ @@ -195,6 +196,12 @@ ckySCard_Init(void) if( status != CKYSUCCESS ) { goto fail; } + + status = ckyShLibrary_getAddress( library, + (void**) &scard->SCARD_PCI_T1_, MAKE_DLL_SYMBOL(g_rgSCardT1Pci)); + if( status != CKYSUCCESS ) { + goto fail; + } return scard; fail: @@ -884,6 +891,7 @@ struct _CKYCardConnection { SCARDHANDLE cardHandle; unsigned long lastError; CKYBool inTransaction; + unsigned long protocol; }; static void @@ -894,6 +902,7 @@ ckyCardConnection_init(CKYCardConnection *conn, const CKYCardContext *ctx) conn->cardHandle = 0; conn->lastError = 0; conn->inTransaction = 0; + conn->protocol = SCARD_PROTOCOL_T0; } CKYCardConnection * @@ -934,14 +943,13 @@ CKYCardConnection_Connect(CKYCardConnection *conn, const char *readerName) { CKYStatus ret; unsigned long rv; - unsigned long protocol; ret = CKYCardConnection_Disconnect(conn); if (ret != CKYSUCCESS) { return ret; } rv = conn->scard->SCardConnect( conn->ctx->context, readerName, - SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0, &conn->cardHandle, &protocol); + SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1, &conn->cardHandle, &conn->protocol); if (rv != SCARD_S_SUCCESS) { conn->lastError = rv; return CKYSCARDERR; @@ -978,7 +986,7 @@ ckyCardConnection_reconnectRaw(CKYCardConnection *conn, unsigned long init) unsigned long protocol; rv = conn->scard->SCardReconnect(conn->cardHandle, - SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0, init, &protocol); + SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1 , init, &protocol); if (rv != SCARD_S_SUCCESS) { conn->lastError = rv; return CKYSCARDERR; @@ -1039,10 +1047,17 @@ CKYCardConnection_TransmitAPDU(CKYCardConnection *conn, CKYAPDU *apdu, return ret; } - rv = conn->scard->SCardTransmit(conn->cardHandle, - conn->scard->SCARD_PCI_T0_, - CKYBuffer_Data(&apdu->apduBuf), CKYBuffer_Size(&apdu->apduBuf), - NULL, response->data, &response->len); + if( conn->protocol == SCARD_PROTOCOL_T0 ) { + rv = conn->scard->SCardTransmit(conn->cardHandle, + conn->scard->SCARD_PCI_T0_, + CKYBuffer_Data(&apdu->apduBuf), CKYBuffer_Size(&apdu->apduBuf), + NULL, response->data, &response->len); + } else { + rv = conn->scard->SCardTransmit(conn->cardHandle, + conn->scard->SCARD_PCI_T1_, + CKYBuffer_Data(&apdu->apduBuf), CKYBuffer_Size(&apdu->apduBuf), + NULL, response->data, &response->len); + } if (rv != SCARD_S_SUCCESS) { conn->lastError =rv; |