3

我正在使用 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();
            }

注册指纹时代码工作正常。这仅在注册 FaceId 时发生。我在这里想念什么?

4

1 回答 1

5

这里有问题。这一切都与设置有关.setUserAuthenticationRequired(true)

如果在生成密钥时将此密钥设置为true,则意味着必须注册至少一个安全的生物识别/解锁密码/图案。由于密钥设置为true并且仅存在不安全的身份验证方法,At least one biometric must be enrolled to create keys that require user authentication因此引发了错误

注意:三星的面容 ID 目前被认为是不安全的。这就是上述问题的原因

于 2020-07-24T08:59:00.440 回答