Blame SOURCES/coolkey-1.1.0-more-keys.patch

ed074c
diff -up ./src/coolkey/slot.cpp.more_keys ./src/coolkey/slot.cpp
ed074c
--- ./src/coolkey/slot.cpp.more_keys	2016-06-16 11:50:01.027432856 -0700
ed074c
+++ ./src/coolkey/slot.cpp	2016-06-16 11:50:13.267224824 -0700
ed074c
@@ -32,7 +32,8 @@
ed074c
 
ed074c
 #define MIN(x, y) ((x) < (y) ? (x) : (y))
ed074c
 
ed074c
-
ed074c
+#define MAX_NUM_KEYS  32
ed074c
+#define MAX_NUM_CERTS 32
ed074c
 
ed074c
 #ifdef DEBUG
ed074c
 #define PRINTF(args) printf args
ed074c
@@ -3458,7 +3459,7 @@ Slot::loadObjects()
ed074c
         } else if( type == 'c' ) {
ed074c
             // cert attribute object. find the DER encoding
ed074c
             unsigned short certnum = getObjectIndex(iter->obj.objectID);
ed074c
-            if( certnum > 9 ) {
ed074c
+            if( certnum > MAX_NUM_CERTS ) {
ed074c
                 //invalid object id
ed074c
                 throw PKCS11Exception(CKR_DEVICE_ERROR,
ed074c
                     "Invalid object id %08x",iter->obj.objectID);
ed074c
@@ -4154,7 +4155,7 @@ Slot::objectToKeyNum(const PKCS11Object
ed074c
         throw PKCS11Exception(CKR_KEY_HANDLE_INVALID);
ed074c
     }
ed074c
     unsigned short keyNum = getObjectIndex(id);
ed074c
-    if( keyNum > 9 ) {
ed074c
+    if( keyNum > MAX_NUM_KEYS ) {
ed074c
         throw PKCS11Exception(CKR_KEY_HANDLE_INVALID);
ed074c
     }
ed074c
     return keyNum & 0xFF;
ed074c
@@ -4911,7 +4912,6 @@ Slot::generateRandom(SessionHandleSuffix
ed074c
     }
ed074c
 }
ed074c
 
ed074c
-#define MAX_NUM_KEYS 8
ed074c
 unsigned int
ed074c
 Slot::getRSAKeySize(PKCS11Object *key)
ed074c
 {
ed074c
diff -up ./src/coolkey/slot.h.more_keys ./src/coolkey/slot.h
ed074c
--- ./src/coolkey/slot.h.more_keys	2016-06-16 11:50:08.627303984 -0700
ed074c
+++ ./src/coolkey/slot.h	2016-06-16 11:54:08.872153180 -0700
ed074c
@@ -512,7 +512,17 @@ class Slot {
ed074c
         return (char) (objectID >> 24) & 0xff;
ed074c
     }
ed074c
     unsigned short getObjectIndex(unsigned long objectID) const {
ed074c
-        return (char )((objectID >> 16) & 0xff) - '0';
ed074c
+       char char_index = (char) ((objectID >> 16) & 0xff);
ed074c
+       if (char_index >= '0' && char_index <= '9') {
ed074c
+           return char_index - '0';
ed074c
+       }
ed074c
+       if (char_index >= 'A' && char_index <= 'Z') {
ed074c
+           return char_index - 'A' + 10;
ed074c
+       }
ed074c
+       if (char_index >= 'a' && char_index <= 'z') {
ed074c
+           return char_index - 'a' + 26 + 10;
ed074c
+       }
ed074c
+       return 0x0100 + char_index;
ed074c
     }
ed074c
 
ed074c
     // actually get the size of a key in bits from the card