[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [iaik-jce] JDK1.2 vs JDK1.3



Hello,

JDK1.3 supports RSA. They made a provider com.sun.rsajca.* which
seems to be the one that does the getPublicKey() operation
and returns a com.sun.rsajca.JSA_RSAPublicKey instead
of the iaik.security.rsa.RSAPublicKey you need.

Guess you can solve it in the following ways:

- int keylen = (java.security.interfaces.RSAPublicKey)
    certreq.getPublicKey()).getModulus().bitLength();
OR
- install the IAIK provider _before_ the RSAJCA provider,
either in the java.security file or in your code.

I don't think they changed their
java.security.interfaces.RSAPublicKey interface.

Cheers, Stef





The following code segment executes perfectly with JDK1.2:

iaik.x509.NetscapeCertRequest certreq = new
iaik.x509.NetscapeCertRequest(req.getBytes());
int keylen =
((iaik.security.rsa.RSAPublicKey)certreq.getPublicKey()).getModulus().bitLe
ngth();

However, with JDK1.3 I get the following exception:
"java.lang.ClassCastException: com.sun.rsajca.JSA_RSAPublicKey"


I can fix the exception by modifying my code to read:

iaik.x509.NetscapeCertRequest certreq = new
iaik.x509.NetscapeCertRequest(req.getBytes());
java.security.PublicKey x =
(java.security.PublicKey)certreq.getPublicKey();
iaik.security.rsa.RSAPublicKey y = new
iaik.security.rsa.RSAPublicKey(x.getEncoded());
int keylen = y.getModulus().bitLength();


I guess this email serves mostly as information to those out there who
may be migrating from JDK1.2 to JDK1.3 unless somebody has a better
solution for me. Perhaps I am overlooking something (my guess is that
Sun changed something under the hood of their
java.security.interfaces.RSAPublicKey class). I'd prefer not to have to
change code if at all possible.


Thanks for any response,

Keith Wiseman
Digital Signature Trust co.

--
Mailinglist-archive at
http://jcewww.iaik.at/mailarchive/iaik-jce/jcethreads.html

To unsubscribe send an email to listserv@iaik.at with the folowing content:
UNSUBSCRIBE iaik-jce







--
Mailinglist-archive at
http://jcewww.iaik.at/mailarchive/iaik-jce/jcethreads.html

To unsubscribe send an email to listserv@iaik.at with the folowing content:
UNSUBSCRIBE iaik-jce