[Fedora-directory-commits] esc/src/lib/coolkey CoolKey.cpp, 1.3, 1.4 CoolKey.h, 1.2, 1.3

Jack Magne (jmagne) fedora-directory-commits at redhat.com
Fri Feb 9 22:00:39 UTC 2007


Author: jmagne

Update of /cvs/dirsec/esc/src/lib/coolkey
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1983

Modified Files:
	CoolKey.cpp CoolKey.h 
Log Message:
Add support to get card ATR.


Index: CoolKey.cpp
===================================================================
RCS file: /cvs/dirsec/esc/src/lib/coolkey/CoolKey.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CoolKey.cpp	17 Jan 2007 19:11:59 -0000	1.3
+++ CoolKey.cpp	9 Feb 2007 22:00:37 -0000	1.4
@@ -51,7 +51,8 @@
 COOLKEY_API HRESULT CoolKeyInit(const char *aAppDir)
 {
 
-  PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyInit:\n appDir %s",aAppDir));
+  PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyInit: appDir %s \n",aAppDir));
+
   if (g_NSSManager) 
   {
     PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyInit:g_NSSManager already exists. \n"));
@@ -80,6 +81,7 @@
 
 COOLKEY_API HRESULT CoolKeyShutdown()
 { 
+
   PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyShutdown:\n"));
 
   DestroyCoolKeyList();
@@ -112,7 +114,14 @@
    g_SetConfigValue = setconfigvalue;
 
 
-   PK11_SetPasswordFunc( CoolKeyVerifyPassword);
+
+   char * suppressPINPrompt =(char*) CoolKeyGetConfig("esc.disable.password.prompt");
+
+
+   if(suppressPINPrompt && !strcmp(suppressPINPrompt,"yes"))
+   {
+       PK11_SetPasswordFunc( CoolKeyVerifyPassword);
+   }
    // Set the verify password callback here, no params needed we know what it is
    return 0;
 }
@@ -840,8 +849,35 @@
     return NSSManager::GetKeyIssuedTo(aKey,aBuf,aBufLength);
 
 }
+
+HRESULT CoolKeyGetATR(const CoolKey *aKey, char *aBuf, int aBufLen)
+{
+
+    if (!aKey || !aKey->mKeyID || !aBuf || aBufLen < 1)
+         return E_FAIL;
+    aBuf[0] = 0;
+    PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyGetATR::\n"));
+
+    HRESULT result = S_OK;
+
+    const char *atr = GetATRForKeyID(aKey);
+
+    if(!atr)
+        return result;
+
+    if((int) strlen(atr) < aBufLen)
+    {
+
+        sprintf(aBuf,"%s",(char *) atr);
+    }
+
+    return result;
+
+}
+
 HRESULT CoolKeyGetIssuerInfo(const CoolKey *aKey, char *aBuf, int aBufLen)
 {
+
      if (!aKey || !aKey->mKeyID || !aBuf || aBufLen < 1)
          return E_FAIL;
 
@@ -860,11 +896,9 @@
 
     HRESULT result = S_OK;
 
-    PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyGetIssuerInfo:: Before CKYCardCreate_Context.\n"));
 
     CKYCardContext *cardCtxt = CKYCardContext_Create(SCARD_SCOPE_USER);
 
-     PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyGetIssuerInfo:: After CKYCardCreate_Context. \n"));
      assert(cardCtxt);
     if (!cardCtxt) {
       PR_LOG( coolKeyLog, PR_LOG_ERROR, ("Attempting to get key issuer info. Can't create Card Context !.\n"));
@@ -872,9 +906,7 @@
       goto done;
     }
 
-    PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyGetIssuerInfo:: Before CKYCardConnection_Create.\n"));
     conn = CKYCardConnection_Create(cardCtxt);
-    PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyGetIssuerInfo:: After CKYCardConnection_Create.\n"));
     assert(conn);
     if (!conn) {
       PR_LOG( coolKeyLog, PR_LOG_ERROR, ("Attempting to get key issuer info.  Can't create Card Connection!\n"));
@@ -882,9 +914,7 @@
       goto done;
     }
 
-    PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyGetIssuerInfo:: Before GetReaderNameForKeyID.\n"));
     readerName = GetReaderNameForKeyID(aKey);
-    PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyGetIssuerInfo:: After GetReaderNameForKeyID.\n"));
     assert(readerName);
     if (!readerName) {
       PR_LOG( coolKeyLog, PR_LOG_ERROR, ("Attempting to get key issuer info.  Can't get reader name!\n"));
@@ -892,9 +922,7 @@
       goto done;
     }
 
-    PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyGetIssuerInfo:: Before CKYCardConnection_Connect.\n"));
     status = CKYCardConnection_Connect(conn, readerName);
-    PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyGetIssuerInfo:: After CKYCardConnection_Connect.\n"));
     if (status != CKYSUCCESS) {
       PR_LOG( coolKeyLog, PR_LOG_ERROR, ("Attempting to get key issuer info. Can't connect to Card!\n"));
 
@@ -902,25 +930,20 @@
       goto done;
     }
 
-    #ifndef DARWIN
-    CKYCardConnection_BeginTransaction(conn);
-    #endif
+#ifndef DARWIN
+CKYCardConnection_BeginTransaction(conn);
+#endif
     apduRC = 0;
-    PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyGetIssuerInfo:: Before CKYApplet_SelectCoolKeyManager.\n"));
     status = CKYApplet_SelectCoolKeyManager(conn, &apduRC);
-    PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyGetIssuerInfo:: After CKYApplet_SelectCoolKeyManager.\n"));
     if (status != CKYSUCCESS) {
 
       PR_LOG( coolKeyLog, PR_LOG_ERROR, ("Attempting to get key issuer info.  Can't select CoolKey manager!\n"));
       goto done;
     }
 
-    PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyGetIssuerInfo:: Before CKYApplet_GetIssuerInfo.\n"));
     status = CKYApplet_GetIssuerInfo(conn, &ISSUER_INFO,
                         &apduRC);
 
-    PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyGetIssuerInfo:: After CKYApplet_GetIssuerInfo.\n"));
-
     if(status != CKYSUCCESS)
     {
         PR_LOG( coolKeyLog, PR_LOG_ERROR, ("Attempting to get key issuer info.  Error actually getting IssuerInfo!\n"));
@@ -956,9 +979,9 @@
     done:
 
     if (conn) {
-      #ifndef DARWIN
+#ifndef DARWIN
       CKYCardConnection_EndTransaction(conn);
-      #endif
+#endif
       CKYCardConnection_Disconnect(conn);
       CKYCardConnection_Destroy(conn);
     }


Index: CoolKey.h
===================================================================
RCS file: /cvs/dirsec/esc/src/lib/coolkey/CoolKey.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CoolKey.h	27 Sep 2006 17:47:46 -0000	1.2
+++ CoolKey.h	9 Feb 2007 22:00:37 -0000	1.3
@@ -26,10 +26,8 @@
 // platforms (coreconf will do the appropriate processing.
 #define COOLKEY_API
 
-
 #include <string.h>
 #include <stdlib.h>
-
 #include <vector>
 #include <string>
 
@@ -172,6 +170,9 @@
 
 COOLKEY_API HRESULT CoolKeyGetIssuerInfo(const CoolKey *aKey, char *aBuf, int aBufLen);
 
+COOLKEY_API HRESULT CoolKeyGetATR(const CoolKey *aKey, char *aBuf, int aBufLen);
+
+
 COOLKEY_API int CoolKeyGetAppletVer(const CoolKey *aKey, const bool isMajor);
 
 }




More information about the Fedora-directory-commits mailing list