简体   繁体   English

如何在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() 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.

相关问题 使用KeyPairGeneratorSpec的Android API级别&lt;18? - Use KeyPairGeneratorSpec for Android API level < 18? 为什么KeyPairGeneratorSpec在API &lt;24上抛出InvalidAlgorithmParameterException - Why is KeyPairGeneratorSpec throwing InvalidAlgorithmParameterException on API < 24 如何使用加密领域与API级别18中存储在KeyStore中的密钥 - how to use Encrypting Realm with key stored in KeyStore in API level 18 如何为Android API 10-18视图设置位图背景? - how to set a Bitmap to background for a view Android API 10-18? KeyPairGeneratorSpec 已弃用 - KeyPairGeneratorSpec deprecated 如何以编程方式设置Google Analytics(分析)API密钥? - How to set Google Analytics api key programmatically? 如何读取API级别&lt;18的通知(NotificationListenerService要求API&gt; = 18) - How to read notifications for API Level < 18 (NotificationListenerService requires API >= 18) 如何在API 18中使用Android KeyStore API? - How to use Android KeyStore API with API 18? 使用API​​ 18及更高版本在Android KeyStore中存储密钥 - Storing a secret key in Android KeyStore using API 18 and Above 如何修复“java.security.InvalidKeyException:不支持的密钥算法:EC。 只有RSA支持“在api 18中使用Keystore时” - How to fix “java.security.InvalidKeyException: Unsupported key algorithm: EC. Only RSA supported” while using Keystore in api 18
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM