android – 不应该使用ECB模式的密码

我试图使用带有RSA密钥对的密码以及“ AndroidKeyStore”.在所有的Android文档中,我可以找到,示例显示 Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding")Cipher.getInstance("RSA/ECB/PKCS1Padding").这两个在Android Studio上都提出了相同的警告:

ECB Encryption should not be used

Cipher#getInstance should not be called with ECB as the cipher mode or without setting the cipher mode because the default mode on android is ECB,which is insecure.

显然我不能省略,或将模式设置为None,因为默认为ECB.如果ECB模式不安全,应该使用哪种模式?

如果我使用任何其他模式(我知道),我得到一个NoSuchAlgorithmException:找不到RSA / {mode} / OAEPWithSHA-256AndMGF1Padding的提供者.填充是否可以成为问题?

无论哪种方式,根据Android KeyStore System文档,ECB模式似乎是使用RSA时唯一支持的密码块模式.

解决方法

这看起来像Android Studio用于查找问题的Android Lint中的错误.该警告的意图是警告关于使用具有对称密码(例如AES)的ECB块模式.然而,由于RSA / ECB / … Cipher接受/处理一个输入块,RSA没有任何警告.

我建议你在https://code.google.com/p/android/针对Android Lint提交错误.

相关文章

Android 如何解决dialog弹出时无法捕捉Activity的back事件 在...
Android实现自定义带文字和图片的Button 在Android开发中经常...
Android 关于长按back键退出应用程序的实现最近在做一个Andr...
android自带的时间选择器只能精确到分,但是对于某些应用要求...