KaP*_*aPa 6 security android android-keystore private-key
KeyInfo 的 isInsideSecureHardware-method 的返回值似乎取决于设备型号、操作系统版本和其他一些随机因素。
例如,当使用 Sony xperia z5 compact 和较旧的操作系统版本时,isInsideSecureHardware() 可能会在一段时间内返回 true,然后突然开始为相同的私钥返回 false。使用最新的操作系统版本 (32.2.A.0.224) 似乎只返回 false。华为 Nexus 6P 返回始终为真。
有没有办法确保密钥存储在安全硬件中?
这是我当前的代码:
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(KeyProperties.KEY_ALGORITHM_RSA, "AndroidKeyStore");
keyPairGenerator.initialize(new KeyGenParameterSpec.Builder(KEY_NAME, KeyProperties.PURPOSE_DECRYPT | KeyProperties.PURPOSE_ENCRYPT)
.setUserAuthenticationRequired(true)
.setBlockModes(KeyProperties.BLOCK_MODE_ECB)
.setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_RSA_PKCS1)
.build());
KeyPair keyPair = keyPairGenerator.generateKeyPair();
// Check that private key is inside secure hardware
KeyFactory factory = KeyFactory.getInstance(key.getAlgorithm(), "AndroidKeyStore");
KeyInfo keyInfo = factory.getKeySpec(key, KeyInfo.class);
boolean secure = keyInfo.isInsideSecureHardware(); // this usually returns false
Run Code Online (Sandbox Code Playgroud)
谢谢!
编辑:在索尼支持论坛上有一个关于同样问题的话题:https : //talk.sonymobile.com/t5/Android-development/hardware-backed-keystore/td-p/1154124
有人提到以下警告会打印到日志中:
W 密钥库:主 keymaster 设备无法生成密钥,回退到 SW。
小智 3
根据 Android API,验证它的唯一方法是首先创建密钥,然后查看信息以确保它是硬件支持的。
查看手机的规格,它最初是在 Lollipop 上发布的。那是在官方 Marshmallow Fingerprint API/硬件规格和制造商开始做自己的事情之前。本文提到了您具体使用的设备 ( http://blog.elcomsoft.com/2016/06/fingerprint-unlock-security-ios-vs-google-android-part-ii/ )。我想知道您返回的真实值是否不正确,然后由于您的操作系统升级,它修复了逻辑(或破坏了逻辑?)。您提到的操作系统升级版本包含“2016年4月1日Google安全补丁”
我有几个问题:
isUserAuthenticationRequirementEnforcedBySecureHardware() 现在在您的设备上返回什么?数值是否一致?如果为假,则可能会告诉您指纹读取器不被认为是安全的(或者存在操作系统缺陷)
旧操作系统版本到底意味着什么?棒糖?您是否尝试过重置为出厂默认设置?
| 归档时间: |
|
| 查看次数: |
2389 次 |
| 最近记录: |