Hi all, I'm generating RSA key pair using openssl and then use the keys in Java program.
I can create a RSAPublicKey from the pem file generated by openssl fine if I just use X509Certificate class to read directly from the file and generate the RSAPublicKey. However, if I generate the RSAPublicKey by myself -- meaning I get the modulus and exponent of the public key into two byte arrays and then use key spec (something like RSAPublicKeySpec(new BigInterger(mod), new BigInteger(exp)) to generate the RSAPublicKey, then I encounter error when I try to use the RSAPublicKey to encrypt something. The Cipher.doFinal method would throw error saying "Modulus is negative". I assume that's because when I passed in the modulus in a byte array, I removed the extra zero at the front. But I just want to know, does this mean this zero is always needed? I thought it is only for DER encoding or something like that. One thing is that if I set up a RSAPublicKey on a Java Card, I don't need the zero at the front and the public key is still set up correctly. So does this mean the zero is not necessary for the key to work? I mean, if Java Card can figure out the modulus is not negative, why can't J2SE? Thanks! Michelle ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]
