Hi everybody!
I'm facing a strange error when i try to generate Key-Pair to be used for encryption purposes.
Either in linux or in windows, it is working perfectly with SUN JDK.
But in RedHat GNUClASS+jamvm, it's wrong as follow.what should I to do ?
Thanks and waiting your replies!
-------------------------------------The error showing is:
genKeyPair failed: java.lang.ArithmeticException: negative exponent
java.lang.ArithmeticException: negative exponent
at java.math.BigInteger.pow(BigInteger.java:1001)
at gnu.java.security.key.dss.FIPS186.generateParameters(FIPS186.java:200)
at gnu.java.security.key.dss.DSSKeyPairGenerator.generate(DSSKeyPairGenerator.java:305)
at gnu.java.security.jce.sig.KeyPairGeneratorAdapter.generateKeyPair(KeyPairGeneratorAdapter.java:93)
at java.security.KeyPairGenerator.genKeyPair(KeyPairGenerator.java:289)
at cn.com.webinfo.security.RSA.generateKey(RSA.java:100)
at cn.com.webinfo.stest.MainRSA.main(MainRSA.java:23)
java.lang.NullPointerException
at cn.com.webinfo.security.RSA.generateKey(RSA.java:102)
at cn.com.webinfo.stest.MainRSA.main(MainRSA.java:23)
Generating private key is failure!
----------------------------------------my code:
MainRSA.java:23 RSA.generateKey("001","prikeyRSA.dat", "pubkeyRSA.dat");
public static boolean generateKey(String id, String priFileName, String pubFileName) {
try {
KeyPairGenerator keygen = KeyPairGenerator.getInstance("RSA");
SecureRandom secrand = new SecureRandom();
secrand.setSeed(id.getBytes());
keygen.initialize(1024, secrand);
RSA.java:100 KeyPair keys = keygen.genKeyPair();
RSA.java:102 PrivateKey prikey = keys.getPrivate();
PublicKey pubkey = keys.getPublic();
.........