Hello, this is somewhat a newbie question probably. I'm generating keypairs with Java:
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
SecureRandom random = SecureRandom.getInstance("SHA1PRNG", "SUN");
keyGen.initialize(512, random);
KeyPair keyPair = keyGen.genKeyPair();
RSAPrivateKey privateKey = (RSAPrivateKey)keyPair.getPrivate();
Now I always thought that privateKey.getModulus() and privateKey.getPrivateExponent() form the "private key" and that they are as big as the keysize (512 bits) passed to the Key Generator.
However, privateKey.getPrivateExponent().toByteArray() returns sometimes a 64 byte (as I expected), sometimes a 65 byte array.
Why sometimes 65 bytes? Am I missing something here?