Blame SOURCES/esc-1.1.2-fix10.patch

f477a5
diff -up ./esc/esc-1.1.2/esc/src/app/esc.js.fix10 ./esc/esc-1.1.2/esc/src/app/esc.js
f477a5
--- ./esc/src/app/esc.js.fix10	2020-12-02 15:47:00.688951279 -0800
f477a5
+++ ./esc/src/app/esc.js	2020-12-02 15:47:00.690951273 -0800
f477a5
@@ -370,12 +370,20 @@ class ESC {
f477a5
          let nick = "";
f477a5
          if(certObj.token == null) 
f477a5
              token = "internal"; 
f477a5
-         else
f477a5
+         else  {
f477a5
              token = certObj.token;
f477a5
+	}
f477a5
 
f477a5
          nick = certObj.nick;
f477a5
- 
f477a5
-         certDetail = this._execProgram(['/usr/bin/certutil','-L','-d', this._getConfigPath(), '-h', token, '-f' , pFileName, '-n', token + ":" + nick]);
f477a5
+
f477a5
+	 let tokenNick = '"' + token + ":" + nick + '"' ;
f477a5
+	 token = '"' + token + '"';
f477a5
+	 let argv1 = ['/usr/bin/certutil','-L','-d', this._getConfigPath(), '-h', token, '-f' , pFileName, '-n', tokenNick];
f477a5
+	  
f477a5
+         print("argv1: " + argv1);
f477a5
+	 
f477a5
+
f477a5
+	 certDetail = this._execProgram(argv1);
f477a5
 
f477a5
          return certDetail;
f477a5
      }
f477a5
@@ -475,7 +483,7 @@ class ESC {
f477a5
                result = -1;
f477a5
                return result;
f477a5
             }
f477a5
-
f477a5
+		
f477a5
             result = stdoutb.toString();
f477a5
 
f477a5
         } catch (e) {
f477a5
@@ -792,19 +800,18 @@ class ESC {
f477a5
         let status = this._selectedTokenInfo.status;
f477a5
 
f477a5
         if(status == 4 /* enrolled */) {
f477a5
-            this._pinMgr = new PinDialog.pinDialog(this);
f477a5
-            this._pinMgr.launchPinPrompt(this._promptPinDone.bind(this));
f477a5
+	    let coolkey_token = this._selectedTokenInfo;
f477a5
+
f477a5
+            this._tokenInfoBuffer.text +=
f477a5
+                this.mgr.get_certs_info(coolkey_token);
f477a5
+
f477a5
         }
f477a5
       
f477a5
     }
f477a5
-    _promptPinDone(tempFileName) {
f477a5
-
f477a5
-        let coolkey_token = this._selectedTokenInfo;
f477a5
-
f477a5
-        this._tokenInfoBuffer.text += 
f477a5
-              this._getCertList(coolkey_token,tempFileName)  + "\n";
f477a5
 
f477a5
+    _promptPinDone(tempFileName) {
f477a5
      }
f477a5
+
f477a5
     _response_cb() {
f477a5
         if(this._messageDialog) {
f477a5
             this._messageDialog.destroy();
f477a5
diff -up ./esc/src/app/opensc.esc.conf.fix10 ./esc/src/app/opensc.esc.conf
f477a5
--- ./esc/src/app/opensc.esc.conf.fix10	2020-12-02 15:51:05.812283690 -0800
f477a5
+++ ./esc/src/app/opensc.esc.conf	2020-12-02 15:51:30.835215539 -0800
f477a5
@@ -94,6 +94,7 @@ app default {
f477a5
         module_path = /usr/lib64;
f477a5
     }
f477a5
     framework pkcs15 {
f477a5
+        use_file_caching = true;
f477a5
         builtin_emulators = coolkey, cac, cac1, PIV-II;
f477a5
     }
f477a5
 }
f477a5
diff -up ./esc/src/app/pinDialog.js.fix10 ./esc/src/app/pinDialog.js
f477a5
--- ./esc/src/app/pinDialog.js.fix10	2020-12-02 15:47:00.683951293 -0800
f477a5
+++ ./esc/src/app/pinDialog.js	2020-12-02 15:47:00.691951271 -0800
f477a5
@@ -94,7 +94,6 @@ pinDialog.prototype = {
f477a5
             if(this.notify) {
f477a5
                 this.notify(this.tempFileName);
f477a5
             }
f477a5
-
f477a5
             this.clearTempFile();
f477a5
             this.dialog.destroy();
f477a5
             this.dialog = null;
f477a5
diff -up ./esc/src/lib/coolkey/CoolKeyHandler.cpp.fix10 ./esc/src/lib/coolkey/CoolKeyHandler.cpp
f477a5
--- ./esc/src/lib/coolkey/CoolKeyHandler.cpp.fix10	2020-12-02 16:25:29.075670723 -0800
f477a5
+++ ./esc/src/lib/coolkey/CoolKeyHandler.cpp	2020-12-02 16:30:53.310789119 -0800
f477a5
@@ -46,6 +46,7 @@
f477a5
 
f477a5
 static const char *cac_manu_id= "Common Access Card";
f477a5
 static const char *piv_manu_id= "piv II ";
f477a5
+static const char *piv_manu_id_1=  "piv_II";
f477a5
 
f477a5
 //static  char *test_extended_login = "s=325&msg_type=13&invalid_login=0&blocked=0&error=&required_parameter0=id%3DUSER%5FID%26name%3DUser+ID%26desc%3DUser+ID%26type%3Dstring%26option%3Doption1%2Coption2%2Coption3&required_parameter1=id%3DUSER%5FPWD%26name%3DUser+Password%26desc%3DUser+Password%26type%3Dpassword%26option%3D&required_parameter2=id%3DUSER%5FPIN%26name%3DPIN%26desc%3DOne+time+PIN+received+via+mail%26type%3Dpassword%26option%3D";
f477a5
 
f477a5
@@ -2300,7 +2301,9 @@ CKHGetCoolKeyInfo(PK11SlotInfo *aSlot,Co
f477a5
     if(!memcmp( tokenInfo.manufacturerID,cac_manu_id,strlen(cac_manu_id ))) {
f477a5
         isACAC = 1;
f477a5
     } else if(!memcmp(tokenInfo.manufacturerID, piv_manu_id, strlen(piv_manu_id))) {
f477a5
-        isAPIV = 1;
f477a5
+        isAPIV = 1; 
f477a5
+    } else if(!memcmp(tokenInfo.manufacturerID, piv_manu_id_1, strlen(piv_manu_id_1))) {
f477a5
+	isAPIV = 1;
f477a5
     } else {
f477a5
         isACOOLKey = 1;
f477a5
     }
f477a5
diff -up ./esc/src/lib/coolkey-mgr/coolkey-api.cpp.fix10 ./esc/src/lib/coolkey-mgr/coolkey-api.cpp
f477a5
--- ./esc/src/lib/coolkey-mgr/coolkey-api.cpp.fix10	2020-12-02 15:47:00.673951320 -0800
f477a5
+++ ./esc/src/lib/coolkey-mgr/coolkey-api.cpp	2020-12-02 15:47:00.691951271 -0800
f477a5
@@ -17,6 +17,8 @@
f477a5
 
f477a5
 #include "coolkey-api.h"
f477a5
 #include "rhCoolKey.h"
f477a5
+#include <string>
f477a5
+
f477a5
 
f477a5
 static rhCoolKey *coolkey = NULL;
f477a5
 static const char * coolkeyDbusName = NULL;
f477a5
@@ -79,6 +81,54 @@ char *coolkey_get_phone_home(char *url)
f477a5
    } 
f477a5
 }
f477a5
 
f477a5
+/* get a string with all the certs detail for a token */
f477a5
+
f477a5
+char *coolkey_get_certs_info(int keyType, const char *keyID) {
f477a5
+
f477a5
+    string str_result;
f477a5
+    if (coolkey == NULL) {
f477a5
+	    return NULL;
f477a5
+    }
f477a5
+
f477a5
+    char *result = NULL;
f477a5
+    char **names = NULL;
f477a5
+    PRUint32 count = 0;
f477a5
+    HRESULT res =  coolkey->GetCoolKeyCertNicknames(keyType, keyID, &count, &names);
f477a5
+
f477a5
+    if(count > 0 && res == S_OK) {
f477a5
+        for(int i = 0 ; i < count ; i++) {
f477a5
+	    char *curName = names[i];
f477a5
+
f477a5
+	    if(curName) {
f477a5
+	        char *certDetail = NULL;
f477a5
+		str_result = str_result + curName + "\n" ;
f477a5
+	        res = coolkey->GetCoolKeyCertInfo(keyType, keyID, curName, &certDetail);
f477a5
+	        if(res == S_OK && certDetail != NULL) {
f477a5
+		    str_result = str_result + certDetail + "\n";
f477a5
+		    PL_strfree(certDetail);
f477a5
+		    certDetail = NULL;
f477a5
+	        }
f477a5
+	    }
f477a5
+	}
f477a5
+    }
f477a5
+
f477a5
+    if(str_result.c_str()) {
f477a5
+        result = PL_strdup((char *) str_result.c_str());
f477a5
+    }
f477a5
+
f477a5
+    for(int i = 0 ; i < count ; i++) {
f477a5
+        if(names[i]) {
f477a5
+	    PL_strfree(names[i]);
f477a5
+	    names[i] = NULL;
f477a5
+	}
f477a5
+    }
f477a5
+
f477a5
+    PR_Free(names);
f477a5
+    names = NULL;
f477a5
+
f477a5
+    return result;
f477a5
+}
f477a5
+
f477a5
 
f477a5
 /* get a block of data about a token in a structure format */
f477a5
 tokenInfo *coolkey_get_token_info(int keyType, const char *keyID) {
f477a5
diff -up ./esc/src/lib/coolkey-mgr/coolkey-api.h.fix10 ./esc/src/lib/coolkey-mgr/coolkey-api.h
f477a5
--- ./esc/src/lib/coolkey-mgr/coolkey-api.h.fix10	2020-12-02 15:47:00.673951320 -0800
f477a5
+++ ./esc/src/lib/coolkey-mgr/coolkey-api.h	2020-12-02 15:47:00.691951271 -0800
f477a5
@@ -43,6 +43,8 @@ void coolkey_init(const char *db_dir, co
f477a5
 void coolkey_destroy();
f477a5
 
f477a5
 char *coolkey_get_phone_home(char *url);
f477a5
+char *coolkey_get_certs_info(int keyType, const char *keyID);
f477a5
+
f477a5
 tokenInfo *coolkey_get_token_info(int keyType,const char *keyID);
f477a5
 void coolkey_free_token_info(tokenInfo *tInfo);
f477a5
 
f477a5
diff -up ./esc/src/lib/coolkey-mgr/coolkey-mgr.c.fix10 ./esc/src/lib/coolkey-mgr/coolkey-mgr.c
f477a5
--- ./esc/src/lib/coolkey-mgr/coolkey-mgr.c.fix10	2020-12-02 15:47:00.673951320 -0800
f477a5
+++ ./esc/src/lib/coolkey-mgr/coolkey-mgr.c	2020-12-02 15:47:00.691951271 -0800
f477a5
@@ -346,6 +346,36 @@ cleanup:
f477a5
 }
f477a5
 
f477a5
 
f477a5
+gchar*
f477a5
+coolkey_mgr_get_certs_info(CoolkeyMgr *self, CoolkeyToken* token) {
f477a5
+
f477a5
+    gchar *cuid = NULL;
f477a5
+    gchar *keyType = NULL;
f477a5
+    int keyTypeInt = 0;
f477a5
+    gchar *certInfo = NULL;
f477a5
+
f477a5
+    g_object_get(token,"key_type", &keyType,NULL);
f477a5
+    g_object_get(token,"cuid", &cuid, NULL);
f477a5
+
f477a5
+    if(keyType == NULL || cuid == NULL) {
f477a5
+       goto cleanup;
f477a5
+    }
f477a5
+
f477a5
+    keyTypeInt = atoi(keyType);
f477a5
+
f477a5
+    if(keyType == NULL || cuid == NULL) {
f477a5
+       goto cleanup;
f477a5
+    }
f477a5
+
f477a5
+    certInfo = coolkey_get_certs_info(keyTypeInt, cuid); 
f477a5
+
f477a5
+cleanup:
f477a5
+
f477a5
+    g_free (keyType);
f477a5
+    g_free (cuid);
f477a5
+    
f477a5
+    return  certInfo;
f477a5
+}
f477a5
 
f477a5
 void 
f477a5
 coolkey_mgr_get_token_info(CoolkeyMgr* self, CoolkeyToken* token) {
f477a5
diff -up ./esc/src/lib/coolkey-mgr/coolkey-mgr.h.fix10 ./esc/src/lib/coolkey-mgr/coolkey-mgr.h
f477a5
--- ./esc/src/lib/coolkey-mgr/coolkey-mgr.h.fix10	2020-12-02 15:47:00.673951320 -0800
f477a5
+++ ./esc/src/lib/coolkey-mgr/coolkey-mgr.h	2020-12-02 15:47:00.691951271 -0800
f477a5
@@ -46,6 +46,8 @@ int coolkey_mgr_cancel_token_operation(C
f477a5
 
f477a5
 void  coolkey_mgr_get_token_info(CoolkeyMgr* self, CoolkeyToken* token);
f477a5
 
f477a5
+gchar * coolkey_mgr_get_certs_info(CoolkeyMgr*self, CoolkeyToken* token);
f477a5
+
f477a5
 gchar * coolkey_mgr_phone_home(CoolkeyMgr* self, gchar *url);
f477a5
 
f477a5
 gchar * coolkey_mgr_speak (CoolkeyMgr* self, gchar *words);
f477a5
diff -up ./esc/src/lib/coolkey/NSSManager.cpp.fix10 ./esc/src/lib/coolkey/NSSManager.cpp
f477a5
--- ./esc/src/lib/coolkey/NSSManager.cpp.fix10	2020-12-02 15:47:00.680951301 -0800
f477a5
+++ ./esc/src/lib/coolkey/NSSManager.cpp	2020-12-02 15:47:00.691951271 -0800
f477a5
@@ -41,7 +41,7 @@
f477a5
 
f477a5
 #include <iostream>
f477a5
 #include <sstream>
f477a5
-
f477a5
+#include <algorithm>
f477a5
 #include "SlotUtils.h"
f477a5
 
f477a5
 static PRLogModuleInfo *coolKeyLogNSS = PR_NewLogModule("coolKeyNSS");
f477a5
@@ -314,7 +314,10 @@ NSSManager::GetKeyCertNicknames( const C
f477a5
             CERTCertificate *cert = node->cert;
f477a5
             if(cert)
f477a5
             {
f477a5
-                if(cert->slot != slot)
f477a5
+		char *certSlotName = PK11_GetSlotName(cert->slot);
f477a5
+		char *slotName = PK11_GetSlotName(slot);
f477a5
+
f477a5
+                if(strcmp(certSlotName, slotName))
f477a5
                 {
f477a5
                     CERT_RemoveCertListNode(node);
f477a5
                 }
f477a5
@@ -346,7 +349,10 @@ NSSManager::GetKeyCertNicknames( const C
f477a5
             PR_LOG( coolKeyLogNSS, PR_LOG_DEBUG, ("%s NSSManager::GetCertKeyNicknames name %s \n",GetTStamp(tBuff,56),curName));
f477a5
 
f477a5
             string str = curName;
f477a5
-            aStrings.push_back (str);
f477a5
+
f477a5
+	    if (find(aStrings.begin(), aStrings.end(), str) == aStrings.end()) {
f477a5
+                aStrings.push_back (str);
f477a5
+	    }
f477a5
         } 
f477a5
 
f477a5
         CERT_FreeNicknames(nicknames);
f477a5
@@ -691,6 +697,16 @@ HRESULT NSSManager::GetKeyCertInfo(const
f477a5
                         aCertInfo = issuedToCNStr + "\n" + issuerCNStr + "\n"
f477a5
                             + notBeforeStr + "\n" + notAfterStr + "\n" + serialStr ;
f477a5
                         PR_LOG( coolKeyLogNSS, PR_LOG_DEBUG, ("%s NSSManager::GetKeyCertInfo issuerCN %s issuedToCN %s \n",GetTStamp(tBuff,56),issuerCN, issuedToCN)); 
f477a5
+			
f477a5
+			if(nBefore) {
f477a5
+			    PORT_Free(nBefore);
f477a5
+			    nBefore  = NULL;
f477a5
+			}
f477a5
+
f477a5
+			if(nAfter) {
f477a5
+			    PORT_Free(nAfter);
f477a5
+			    nAfter = NULL;
f477a5
+			}
f477a5
 
f477a5
                         break;
f477a5
                     }