diff options
author | rrelyea <rrelyea@fba4d07e-fe0f-4d7f-8147-e0026e666dc0> | 2006-11-10 19:08:07 +0000 |
---|---|---|
committer | rrelyea <rrelyea@fba4d07e-fe0f-4d7f-8147-e0026e666dc0> | 2006-11-10 19:08:07 +0000 |
commit | 61e1011c5fe010d4dc7c009a9c1d076f02d2df62 (patch) | |
tree | 97390f1a3db7060e19ff391942f10b7dfdb5cf0c /src | |
parent | 6d86a2a26d729fde99085d12c330acab0ed0b74d (diff) |
Add syslog support.
Add CAC support
git-svn-id: http://svn.fedorahosted.org/svn/coolkey/trunk@34 fba4d07e-fe0f-4d7f-8147-e0026e666dc0
Diffstat (limited to 'src')
-rw-r--r-- | src/coolkey/log.h | 10 | ||||
-rw-r--r-- | src/coolkey/slot.cpp | 31 |
2 files changed, 39 insertions, 2 deletions
diff --git a/src/coolkey/log.h b/src/coolkey/log.h index 8b24e5b..a586ced 100644 --- a/src/coolkey/log.h +++ b/src/coolkey/log.h @@ -53,4 +53,14 @@ class FileLog : public Log { virtual ~FileLog(); }; +class SysLog : public Log { + private: + SysLog(SysLog &) {} + SysLog * operator=(SysLog &) { return *this; } + public: + SysLog() { } + void log(const char *msg, ...); + virtual ~SysLog() { } +}; + #endif diff --git a/src/coolkey/slot.cpp b/src/coolkey/slot.cpp index 997271a..6cfde33 100644 --- a/src/coolkey/slot.cpp +++ b/src/coolkey/slot.cpp @@ -585,16 +585,41 @@ Slot::connectToToken() } Transaction trans; - trans.begin(conn); + status = trans.begin(conn); + + /* CAC card are cranky after they are first inserted. + * don't continue until we can convince the tranaction to work */ + for (int count = 0; count < 10 && status == CKYSCARDERR + && CKYCardConnection_GetLastError(conn) == SCARD_W_RESET_CARD; count++) { + log->log("CAC Card Reset detected retry %d: time %d ms\n", count, + OSTimeNow() - time); + CKYCardConnection_Disconnect(conn); + OSSleep(100000); /* 100 ms */ + status = CKYCardConnection_Connect(conn, readerName); + if (status != CKYSUCCESS) { + continue; + } + status = trans.begin(conn); + } + + /* Can't get a transaction, give up */ + if (status != CKYSUCCESS) { + log->log("Transaction Failed 0x%x\n", status); + handleConnectionError(); + } // see if the applet is selectable log->log("time connnect: Begin transaction %d ms\n", OSTimeNow() - time); status = CKYApplet_SelectCoolKeyManager(conn, NULL); if (status != CKYSUCCESS) { + log->log("CoolKey Select failed 0x%x\n", status); status = CACApplet_SelectPKI(conn, 0, NULL); if (status != CKYSUCCESS) { + log->log("CAC Select failed 0x%x\n", status); if (status == CKYSCARDERR) { + log->log("CAC Card Failure 0x%x\n", + CKYCardConnection_GetLastError(conn)); disconnect(); } return; @@ -1121,6 +1146,8 @@ Slot::handleConnectionError() { long error = CKYCardConnection_GetLastError(conn); + log->log("Connection Error = 0x%x\n", error); + // Force a reconnect after a token operation fails. The most // common reason for it to fail is that it has been removed, but // it doesn't hurt to do it in other cases either (such as a reset). @@ -1966,7 +1993,7 @@ void Slot::loadCACCert(CKYByte instance) { CKYISOStatus apduRC; - CKYStatus status; + CKYStatus status = CKYSUCCESS; CKYBuffer cert; CKYBuffer rawCert; CKYBuffer shmCert; |