gnu-crypto-discuss
[Top][All Lists]
Advanced

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

[GNU Crypto] RSAKeyPairGenerator exception


From: WU,I-HSUAN
Subject: [GNU Crypto] RSAKeyPairGenerator exception
Date: Fri, 25 Feb 2005 00:31:07 -0800
User-agent: Internet Messaging Program (IMP) 3.2.4

Hi.

I'm trying to creat a RSA Keypair of a public and private key.  I tried
using the example from the bottom of the page of:
http://www.gnu.org/software/gnu-crypto/manual/api/gnu/crypto/key/package-summary.html

I compiled without any error using the binaries.
%javac -classpath .:/gnu-crypto.jar Test.java

But when I run it, I get the following exception:

Exception in thread "main" java.lang.NoClassDefFoundError:
gnu/crypto/key/rsa/RSAKeyPairGenerator
        at Test.main(Test.java:14)

Can anyone help me with this?  I have no idea what the problem could be. 
Is there a better way to create RSA KeyPairs?  Thanks!!

Sandy

Test.java
--------------------------------------------------------------------------
import gnu.crypto.sig.rsa.RSA;
import gnu.crypto.key.rsa.RSAKeyPairGenerator;

import java.math.BigInteger;
import java.security.KeyPair;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPrivateCrtKey;
import java.security.interfaces.RSAPublicKey;
import java.util.HashMap;
import java.util.Random;

class Test {
public static void main(String[] args) {
RSAKeyPairGenerator kpg = new RSAKeyPairGenerator();
HashMap map = new HashMap();
map.put(RSAKeyPairGenerator.MODULUS_LENGTH, new Integer(1024));
kpg.setup(map);

KeyPair kp = kpg.generate();

BigInteger n1 = ((RSAPublicKey) kp.getPublic()).getModulus();
BigInteger e =  ((RSAPublicKey) kp.getPublic()).getPublicExponent();
BigInteger n2 = ((RSAPrivateKey) kp.getPrivate()).getModulus();
BigInteger d =  ((RSAPrivateKey) kp.getPrivate()).getPrivateExponent();
}
}
-----------------------------------------------------------------------








reply via email to

[Prev in Thread] Current Thread [Next in Thread]