From: Faveh K. <kav...@ya...> - 2002-10-30 16:57:51
|
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/ |