如何在 API 18 上设置 KeyPairGeneratorSpec 的密钥大小?
How to set key size for KeyPairGeneratorSpec on API 18?
Android Keystore (with KeyPairGeneratorSpec
etc) was introduced in API level 18. However, the method KeyPairGeneratorSpec.Builder.setKeySize()
仅在 API 级别 19 中引入。
虽然支持API level 18 (Android 4.3),但是否可以设置密钥大小?
根据documentation, it would seem as though API level 18 does support different RSA Key
sizes. But according to another source(参考API 18级):
There is currently no way to specify key size or type and generated
keys default to 2048 bit RSA.
不过,我想您应该 能够使用自 API 级别 1 以来可用的不同 AlgorithmParameterSpec
, such as the old RSAKeyGenParameterSpec
;它将密钥大小作为构造函数参数:
keyPairGenerator.initialize(new RSAKeyGenParameterSpec(keySize, publicExponent));
Android Keystore (with KeyPairGeneratorSpec
etc) was introduced in API level 18. However, the method KeyPairGeneratorSpec.Builder.setKeySize()
仅在 API 级别 19 中引入。
虽然支持API level 18 (Android 4.3),但是否可以设置密钥大小?
根据documentation, it would seem as though API level 18 does support different RSA Key
sizes. But according to another source(参考API 18级):
There is currently no way to specify key size or type and generated keys default to 2048 bit RSA.
不过,我想您应该 能够使用自 API 级别 1 以来可用的不同 AlgorithmParameterSpec
, such as the old RSAKeyGenParameterSpec
;它将密钥大小作为构造函数参数:
keyPairGenerator.initialize(new RSAKeyGenParameterSpec(keySize, publicExponent));