I am building an android system.
I have an existing key pair, with a public exponent F4 (65537).
I try to use it as platform.key (I have the pk8 and the x509).
During the build process, DumpPublicKey is called on my key pair.
At this point, the key is rejected because the public exponent is not 3. (I checked in the code of DumpPublicKey, it is exactly what it does: compare with 3 and reject otherwise)
Here is the stacktrace for this :
java.lang.Exception: Public exponent should be 3 but is 65537.
at com.android.dumpkey.DumpPublicKey.check(DumpPublicKey.java:75)
at com.android.dumpkey.DumpPublicKey.main(DumpPublicKey.java:151)
Does this means I have to generate a new key pair using
openssl genrsa -3 ...
or is there any way I can still use my key?
Also, why is it so important that the public exponent is 3 and not F4?
Thanks in advance
Looks like a bug in com.android.dumpkey.DumpPublicKey to me.
Restricting the the public exponent of an RSA key to 3 is just plain silly.
Doing so just makes it more likely that implementation errors have desastrous effects,
if the underlying library is not implemented correctly.
As far as I know Android uses Bouncycastle, which is a crypto library that is
not carefully implemented.
Using the standard exponent 2^16+1 as you do, is very reasonable and avoids many potential
problems with small exponents.