Blame SOURCES/jss-HSM-manufacturerID.patch

b93447
diff -up jss-4.2.6/mozilla/security/jss/org/mozilla/jss/pkcs11/PK11KeyPairGenerator.c.cfu jss-4.2.6/mozilla/security/jss/org/mozilla/jss/pkcs11/PK11KeyPairGenerator.c
b93447
--- jss-4.2.6/mozilla/security/jss/org/mozilla/jss/pkcs11/PK11KeyPairGenerator.c.cfu	2011-11-10 17:18:02.706421000 -0800
b93447
+++ jss-4.2.6/mozilla/security/jss/org/mozilla/jss/pkcs11/PK11KeyPairGenerator.c	2011-11-10 17:18:23.370442000 -0800
b93447
@@ -195,7 +195,8 @@ JSS_PK11_generateKeyPairWithOpFlags(JNIE
b93447
             }
b93447
             PR_GetErrorText(errBuf);
b93447
         }
b93447
-        msgBuf = PR_smprintf("Keypair Generation failed on token: %s",
b93447
+        msgBuf = PR_smprintf("Keypair Generation failed on token with error: %d : %s",
b93447
+            PR_GetError(),
b93447
             errLength>0? errBuf : "");
b93447
         if(errLength>0) {
b93447
             PR_Free(errBuf);
b93447
diff -up jss-4.2.6/mozilla/security/jss/org/mozilla/jss/pkcs11/PK11KeyWrapper.c.cfu jss-4.2.6/mozilla/security/jss/org/mozilla/jss/pkcs11/PK11KeyWrapper.c
b93447
--- jss-4.2.6/mozilla/security/jss/org/mozilla/jss/pkcs11/PK11KeyWrapper.c.cfu	2011-11-10 17:18:10.767429000 -0800
b93447
+++ jss-4.2.6/mozilla/security/jss/org/mozilla/jss/pkcs11/PK11KeyWrapper.c	2011-11-10 17:52:34.703491000 -0800
b93447
@@ -334,32 +334,36 @@ Java_org_mozilla_jss_pkcs11_PK11KeyWrapp
b93447
     PRBool isExtractable = PR_FALSE;
b93447
 
b93447
     /* special case nethsm and lunasa*/
b93447
-    CK_UTF8CHAR nethsmLabel[4] = {'N','H','S','M'};
b93447
-    CK_UTF8CHAR lunasaLabel[4] = {'l','u','n','a'};
b93447
+    const int numManufacturerIDchars = 7;
b93447
+    CK_UTF8CHAR nethsmManufacturerID[] = {'n','C','i','p','h','e','r'};
b93447
+    CK_UTF8CHAR lunasaManufacturerID[] = {'S','a','f','e','n','e','t'};
b93447
     PRBool isNethsm = PR_TRUE;
b93447
     PRBool isLunasa = PR_TRUE;
b93447
 
b93447
+    tokenInfo.manufacturerID[0] = 0;
b93447
+
b93447
     if( JSS_PK11_getTokenSlotPtr(env, tokenObj, &slot) != PR_SUCCESS) {
b93447
         /* exception was thrown */
b93447
         goto finish;
b93447
     }
b93447
 
b93447
-    if ( PK11_GetTokenInfo(slot, &tokenInfo) == PR_SUCCESS) {
b93447
+    if ( (PK11_GetTokenInfo(slot, &tokenInfo) == PR_SUCCESS) &&
b93447
+       (tokenInfo.manufacturerID[0] != 0)) {
b93447
         int ix = 0;
b93447
-        for(ix=0; ix < 4; ix++) {
b93447
-            if (tokenInfo.label[ix] != nethsmLabel[ix]) {
b93447
+
b93447
+        for(ix=0; ix < numManufacturerIDchars; ix++) {
b93447
+            if (tokenInfo.manufacturerID[ix] != nethsmManufacturerID[ix]) {
b93447
                isNethsm = PR_FALSE;
b93447
                break;
b93447
             }
b93447
         }
b93447
-        ix = 0;
b93447
-        for(ix=0; ix < 4; ix++) {
b93447
-            if (tokenInfo.label[ix] != lunasaLabel[ix]) {
b93447
+
b93447
+        for(ix=0; ix < numManufacturerIDchars; ix++) {
b93447
+            if (tokenInfo.manufacturerID[ix] != lunasaManufacturerID[ix]) {
b93447
                isLunasa = PR_FALSE;
b93447
                break;
b93447
             }
b93447
         }
b93447
-
b93447
     } else {
b93447
         isNethsm = PR_FALSE;
b93447
         isLunasa = PR_FALSE;