Last Comment Bug 102966 - fromRaw() does not set correct KeyType
: fromRaw() does not set correct KeyType
Status: RESOLVED DUPLICATE of bug 95666
:
Product: JSS
Classification: Components
Component: Library (show other bugs)
: 3.1.1
: Sun Solaris
: P1 normal (vote)
: 3.1.1
Assigned To: Jamie Nicolson
: somni
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2001-10-03 14:10 PDT by michelle
Modified: 2001-11-01 13:32 PST (History)
3 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
Proposed patch for JSS to work around NSS bug 95666. (616 bytes, patch)
2001-10-04 13:21 PDT, Wan-Teh Chang
no flags Details | Diff | Review

Description michelle 2001-10-03 14:10:59 PDT
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
            :   }
Comment 1 michelle 2001-10-03 14:13:54 PDT
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=
Comment 2 Jamie Nicolson 2001-10-03 16:35:34 PDT

*** This bug has been marked as a duplicate of 95666 ***
Comment 3 Wan-Teh Chang 2001-10-04 13:21:39 PDT
Created attachment 52085 [details] [diff] [review]
Proposed patch for JSS to work around NSS bug 95666.
Comment 4 Wan-Teh Chang 2001-10-04 13:29:05 PDT
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.
Comment 5 Jamie Nicolson 2001-11-01 11:47:46 PST
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.
Comment 6 Wan-Teh Chang 2001-11-01 13:32:08 PST
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.

Note You need to log in before you can comment on or make changes to this bug.