Blame SOURCES/esc-1.1.2-fix11.patch

c1e356
diff -up ./esc/src/app/esc.js.fix11 ./esc/src/app/esc.js
c1e356
--- ./esc/src/app/esc.js.fix11	2022-06-15 19:12:43.974710780 -0400
c1e356
+++ ./esc/src/app/esc.js	2022-06-15 19:12:54.657664269 -0400
c1e356
@@ -581,7 +581,6 @@ class ESC {
c1e356
          this._configFile =  new GLib.KeyFile();
c1e356
 
c1e356
          this._configPath = GLib.get_user_config_dir() + "/esc";
c1e356
-
c1e356
          let configDir = Gio.File.new_for_path(this._configPath);
c1e356
 
c1e356
          try {
c1e356
@@ -606,6 +605,9 @@ class ESC {
c1e356
              this._configFile.save_to_file(this._configFileName); 
c1e356
          } 
c1e356
      }
c1e356
+     _initConfigTokenManuIDs() {
c1e356
+        this._setConfigValue("esc.token.manu_id.0","Volkswagen AG");
c1e356
+     }
c1e356
 
c1e356
     _buildUI() {
c1e356
         // Create the application window
c1e356
@@ -637,6 +639,7 @@ class ESC {
c1e356
 
c1e356
 
c1e356
             this._initConfig();
c1e356
+            this._initConfigTokenManuIDs();
c1e356
             this._initProperties();
c1e356
 
c1e356
             this._statusMessages = null; 
c1e356
diff -up ./esc/src/lib/coolkey/CoolKeyHandler.cpp.fix11 ./esc/src/lib/coolkey/CoolKeyHandler.cpp
c1e356
--- ./esc/src/lib/coolkey/CoolKeyHandler.cpp.fix11	2022-06-15 19:10:26.278310248 -0400
c1e356
+++ ./esc/src/lib/coolkey/CoolKeyHandler.cpp	2022-06-15 19:10:46.824220800 -0400
c1e356
@@ -63,6 +63,7 @@ static const char *piv_manu_id_1=  "piv_
c1e356
 static PRLogModuleInfo *coolKeyLogHN = PR_NewLogModule("coolKeyHandler");
c1e356
 
c1e356
 void NotifyEndResult(CoolKeyHandler* context, int operation, int result, int description);
c1e356
+bool isTokenTypeOtherKnownType(CK_TOKEN_INFO *tokenInfo);
c1e356
 
c1e356
 struct AutoCKYBuffer : public CKYBuffer
c1e356
 {
c1e356
@@ -2246,6 +2247,7 @@ CKHGetCoolKeyInfo(PK11SlotInfo *aSlot,Co
c1e356
     int isACOOLKey = 0;
c1e356
     int isACAC = 0;
c1e356
     int isAPIV = 0;
c1e356
+    bool isOtherKey = false;
c1e356
 
c1e356
     int hasApplet = 0;
c1e356
     int isPersonalized = 0;
c1e356
@@ -2306,6 +2308,12 @@ CKHGetCoolKeyInfo(PK11SlotInfo *aSlot,Co
c1e356
 	isAPIV = 1;
c1e356
     } else {
c1e356
         isACOOLKey = 1;
c1e356
+        isOtherKey = isTokenTypeOtherKnownType(&tokenInfo);
c1e356
+        if(isOtherKey == true && hasApplet == 0 && isPersonalized == 0) {
c1e356
+            isACOOLKey = 0;
c1e356
+        } else {
c1e356
+            isOtherKey = false;
c1e356
+        }
c1e356
     }
c1e356
 
c1e356
     // OK, we have everything we need, now build the COOLKEYInfo structure.
c1e356
@@ -2336,7 +2344,7 @@ CKHGetCoolKeyInfo(PK11SlotInfo *aSlot,Co
c1e356
         tokenInfo.firmwareVersion.major = 1;    
c1e356
     }
c1e356
 
c1e356
-    if(isPersonalized == 1 || isACAC == 1 || isAPIV == 1) {
c1e356
+    if(isPersonalized == 1 || isACAC == 1 || isAPIV == 1 || isOtherKey == true) {
c1e356
         tokenInfo.flags |= CKF_TOKEN_INITIALIZED;
c1e356
     }
c1e356
 
c1e356
@@ -2407,3 +2415,33 @@ failed:
c1e356
     
c1e356
     return NULL;
c1e356
 }
c1e356
+
c1e356
+bool isTokenTypeOtherKnownType(CK_TOKEN_INFO *tokenInfo)
c1e356
+{
c1e356
+    char tBuff[56];
c1e356
+    bool res = false;
c1e356
+
c1e356
+    if(tokenInfo == NULL) {
c1e356
+        return res;
c1e356
+    }
c1e356
+    string curManuCfg;
c1e356
+    string num;
c1e356
+    for(int i = 0;;i++) {
c1e356
+        num = to_string(i);
c1e356
+        curManuCfg = "esc.token.manu_id." + num;
c1e356
+        const char *curManu = CoolKeyGetConfig(curManuCfg.c_str());
c1e356
+
c1e356
+        if(curManu == NULL) {
c1e356
+            break;
c1e356
+        }
c1e356
+
c1e356
+        int match = memcmp(tokenInfo->manufacturerID, curManu, strlen(curManu));
c1e356
+        CoolKeyFreeConfig(curManu);
c1e356
+        if(match == 0) {
c1e356
+            res = true;
c1e356
+            break;
c1e356
+        }
c1e356
+    }
c1e356
+    PR_LOG( coolKeyLogHN, PR_LOG_DEBUG, ("%s CoolKeyHandler::isTokenTypeOtherKnownType:  result: %d .\n",GetTStamp(tBuff,56), res));
c1e356
+    return res;
c1e356
+}