Blame SOURCES/esc-1.1.2-fix11.patch

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