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

RE: [iaik-jce] RSA Keygeneration



ASN.1 integers are stored as the minimum length (in bytes) 2s complement
format. RSA keys are always positive integers. So if the key's most
significant bit is set, the integer representation needs to be padded with a
0 byte in the most significant byte. Otherwise, the value would be a
negative integer.

> -----Original Message-----
> From: iaik-jce-owner@iaik.tu-graz.ac.at
> [mailto:iaik-jce-owner@iaik.tu-graz.ac.at]On Behalf Of Gerhard Schagerl
> Sent: Thursday, June 15, 2000 5:25 AM
> To: iaik-jce@iaik.tu-graz.ac.at
> Subject: [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


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