Android Keystore (with KeyPairGeneratorSpec etc) was introduced in API level 18. However, the method KeyPairGeneratorSpec.Builder.setKeySize() was only introduced in API level 19.
While supporting API level 18 (Android 4.3), is it possible to set the key size?
According to the documentation, it would seem as though API level 18 does support different RSA
Keysizes. But according to another source (referencing API level 18):Though, I suppose you should be able to use a different
AlgorithmParameterSpec, such as the oldRSAKeyGenParameterSpecavailable since API level 1; which takes a key size as a constructor argument: