From: Jeroen C. v. G. <je...@va...> - 2002-10-30 17:15:16
|
Faveh, On which line does the exception occur? -J On Wednesday, Oct 30, 2002, at 11:50 US/Eastern, Faveh Khosravi wrote: > Hi, > > I am using Cryptix 3 and I get the followoing error: > > java.lang.ClassCastException: > com.sun.rsajca.JSA_RSAPublicKey > > when I run the following code: > > public void computeKeys(int size) { > try { > KeyPairGenerator kpg = > KeyPairGenerator.getInstance("RSA"); > Cipher cipher = Cipher.getInstance("RSA"); > > kpg.initialize(size, prng); > System.out.print(". "); > KeyPair pair = kpg.generateKeyPair(); > System.out.print(". "); > PrivateKey sk = pair.getPrivate(); > System.out.print(". "); > PublicKey pk = pair.getPublic(); > System.out.println(". Done!\n"); > > System.out.println("Getting simple key > components..."); > > BigInteger m = ((CryptixRSAPublicKey) > pk).getModulus(); > BigInteger e = ((CryptixRSAPublicKey) > pk).getExponent(); > System.out.println(" Public key > material:"); > System.out.println(" n: " + > BI.dumpString(m)); > System.out.println(" e: " + > BI.dumpString(e)); > > BigInteger n = ((CryptixRSAPrivateKey) > sk).getModulus(); > BigInteger d = ((CryptixRSAPrivateKey) > sk).getExponent(); > BigInteger p = ((RSAFactors) sk).getP(); > BigInteger q = ((RSAFactors) sk).getQ(); > BigInteger u = ((RSAFactors) > sk).getInverseOfQModP(); > System.out.println(" Private key > material:"); > System.out.println(" n: " + > BI.dumpString(n)); > System.out.println(" d: " + > BI.dumpString(d)); > System.out.println(" p: " + > BI.dumpString(p)); > System.out.println(" q: " + > BI.dumpString(q)); > System.out.println(" u: " + > BI.dumpString(u)); > > > } catch (Exception e) { > System.out.println(e); > } > return; > } > > Your help will be very much appreciated. Thanks in > advance. > > > > __________________________________________________ > Do you Yahoo!? > HotJobs - Search new jobs daily now > http://hotjobs.yahoo.com/ > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Cryptix-Users mailing list > Cry...@li... > https://lists.sourceforge.net/lists/listinfo/cryptix-users > -- Jeroen C. van Gelderen - je...@va... - +1 242 357 5115 "All that is necessary for evil to triumph is for good men to do nothing." -- Edmund Burke |