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

[iaik-jce] RSA Keygeneration



Hi

I try to generate a pair of RSA Keys with the following
code, but I've got some troubles with it:

The modulus is alwaya 1 byte too long (mo[0] is always 0x00)
The privatekey seems OK but the public key always has
a length of 1 byte !!!!

can anyone help me ??

THX
Gerhard

============
iaik.java.security.SecureRandom
sec_random=iaik.security.random.SecRandom.getDefault();
RSAKeyPairGenerator key_gen=new RSAKeyPairGenerator();
key_gen.initialize(512, sec_random);
iaik.java.security.KeyPair key_pair = key_gen.generateKeyPair();

iaik.security.rsa.RSAPrivateKey rsaPrivateKey=new
iaik.security.rsa.RSAPrivateKey

((iaik.java.security.interfaces.RSAPrivateKey)key_pair.getPrivate());
iaik.security.rsa.RSAPublicKey rsaPublicKey=new
iaik.security.rsa.RSAPublicKey

((iaik.java.security.interfaces.RSAPublicKey)key_pair.getPublic());

byte pr[]=rsaPrivateKey.getPrivateExponent().toByteArray();
byte pu[]=rsaPrivateKey.getPublicExponent().toByteArray();
byte mo[]=rsaPrivateKey.getModulus().toByteArray();
===========




--
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