Closed Bug 102966 Opened 24 years ago Closed 24 years ago

fromRaw() does not set correct KeyType

Categories

(JSS Graveyard :: Library, defect, P1)

3.1.1
Sun
Solaris
defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 95666

People

(Reporter: mzhao, Assigned: jamie-bugzilla)

Details

Attachments

(1 file)

The PK11Pubkey created using fromRaw doe not setup KeyType PrivateKey.Type keyType = null; String alg = signKey.getAlgorithm(); if(alg.equals("RSA")) { Debug.trace("RSA"); keyType = PrivateKey.RSA; } else if( alg.equals("DSA")) { Debug.trace("DSA"); keyType = PrivateKey.DSA; } else { Assert.NotReached("Unknown key type"); } try{ FileOutputStream fo = new FileOutputStream("/tmp/cert"); fo.write(((X509Key)signKey).getKey()); fo.close(); }catch (Exception e) { FileOutputStream fo = new FileOutputStream("/tmp/ex"); PrintStream ps = new PrintStream(fo); e.printStackTrace(ps); fo.close(); ps.close(); } PK11PubKey pubK = PK11PubKey.fromRaw(keyType,((X509Key)signKey).getKey()); si.verify(digest, id, pubK); The above code failed in CMS because the pubK does not have KeyType. (dbx) pathmap /u/mzhao/jss/mozilla/security/jss/org/mozilla/jss/pkcs11 (dbx) list 88 jobject pubKey=NULL; 89 jclass keyClass; 90 KeyType keyType; 91 jmethodID constructor; 92 jbyteArray ptr; 93 char *keyClassName; 94 95 PR_ASSERT(env!=NULL && pKey!=NULL); 96 97 /* What kind of public key? */ (dbx) next t@28 (l@20) stopped in JSS_PK11_wrapPubKey at line 95 in file "PK11PubKey.c" 95 PR_ASSERT(env!=NULL && pKey!=NULL); (dbx) next t@28 (l@20) stopped in JSS_PK11_wrapPubKey at line 98 in file "PK11PubKey.c" 98 keyType = (*pKey)->keyType; (dbx) next t@28 (l@20) stopped in JSS_PK11_wrapPubKey at line 99 in file "PK11PubKey.c" 99 switch(keyType) { (dbx) print keyType keyType = nullKey /tmp ->dumpasn1 cert 0 30 72: SEQUENCE { 2 02 65: INTEGER : 00 C8 B2 75 0E 26 5C 33 A5 C7 27 D1 1A E8 C3 CD : 1A 16 8E 5F C5 DE 89 40 98 0D 9D 50 3F 8E E0 49 : A1 27 4E 66 2D E8 5D CC 00 76 8F 14 C1 96 E6 01 : 82 73 C1 10 B8 29 49 6F 97 08 71 21 46 93 D3 F6 : DF 69 02 3: INTEGER 65537 : }
This is the RSA key I passed into fromRaw. You can test it out with simple test programs if you prefer. MEgCQQDIsnUOJlwzpccn0Rrow80aFo5fxd6JQJgNnVA/juBJoSdOZi3oXcwAdo8UwZbmAYJzwRC4 KUlvlwhxIUaT0/bfAgMBAAE=
*** This bug has been marked as a duplicate of 95666 ***
Status: UNCONFIRMED → RESOLVED
Closed: 24 years ago
Resolution: --- → DUPLICATE
The fix for NSS bug 95666 did not make it into NSS 3.3.1, so we need to work around it in JSS 3.1.1, if possible. Michelle reported that my patch (attachment 52085 [details] [diff] [review]) fixed the problem, so I went ahead and checked it in on the JSS_3_1_BRANCH. I would still appreciate a code review.
Priority: -- → P1
Target Milestone: --- → 3.1.1
This patch looks correct. It is checked in only on the JSS_3_1_BRANCH, which is good because the bug has been fixed in the NSS trunk.
The NSS bug (bug 95666) is also fixed on NSS_3_3_BRANCH and will be in NSS 3.3.2. We could back out the workaround from JSS_3_1_BRANCH when it switches to NSS 3.3.2, but I think it is not worth the trouble.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: