[英]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()
was only introduced in API level 19. 在API级别18中引入了Android Keystore (带有
KeyPairGeneratorSpec
等)。但是, KeyPairGeneratorSpec.Builder.setKeySize()
方法仅在API级别19中引入。
While supporting API level 18 (Android 4.3), is it possible to set the key size? 在支持API级别18(Android 4.3)时,是否可以设置密钥大小?
According to the documentation , it would seem as though API level 18 does support different RSA Key
sizes. 根据文档 ,似乎API级别18确实支持不同的RSA
Key
大小。 But according to another source (referencing API level 18): 但根据另一个来源 (参考API级别18):
There is currently no way to specify key size or type and generated keys default to 2048 bit RSA.
目前无法指定密钥大小或类型,生成的密钥默认为2048位RSA。
Though, I suppose you should be able to use a different AlgorithmParameterSpec
, such as the old RSAKeyGenParameterSpec
available since API level 1; 虽然,我想您应该能够使用不同的
AlgorithmParameterSpec
,例如自API级别1以来可用的旧RSAKeyGenParameterSpec
; which takes a key size as a constructor argument: 它将密钥大小作为构造函数参数:
keyPairGenerator.initialize(new RSAKeyGenParameterSpec(keySize, publicExponent));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.