Blame SOURCES/esc-1.1.2-fix10.patch

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