abh*_*pet 3 android androidx android-biometric-prompt android-biometric
我正在使用 android Biometricx 库进行面部和指纹认证。当仅注册 FaceID 并且我尝试创建密钥时,我收到“ IllegalStatException:必须至少注册一个生物识别才能创建需要用户身份验证的密钥”
我正在尝试像这样创建secretKey
try {
mKeyGenerator.init(new KeyGenParameterSpec.Builder(KEY_NAME,
KeyProperties.PURPOSE_ENCRYPT |
KeyProperties.PURPOSE_DECRYPT)
.setBlockModes(KeyProperties.BLOCK_MODE_CBC)
// Require the user to authenticate with a fingerprint to authorize every use
// of the key
.setUserAuthenticationRequired(true)
.setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_PKCS7)
.build());
secretKey = mKeyGenerator.generateKey();
} catch (NoSuchAlgorithmException | InvalidAlgorithmParameterException
| CertificateException | IOException e) {
Toast.makeText(this,"Create Key "+ e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
}
Run Code Online (Sandbox Code Playgroud)
注册指纹后,代码工作正常。只有在注册 FaceId 时才会发生这种情况。我在这里缺少什么?
在这里得到了问题。这一切都与设置有关.setUserAuthenticationRequired(true)
如果true在生成密钥时将此密钥设置为,则意味着必须至少注册一个安全的生物识别/解锁密码/模式。由于密钥设置为true并且仅存在不安全的身份验证方法,At least one biometric must be enrolled to create keys that require user authentication因此引发了错误
注意:目前,三星的 Face ID 被认为是不安全的。这就是上述问题的原因
| 归档时间: |
|
| 查看次数: |
559 次 |
| 最近记录: |