首页 > 其他分享 >【Android R】manualTests#com.android.cts.verifier.security.FingerprintBoundKeysTest fail

【Android R】manualTests#com.android.cts.verifier.security.FingerprintBoundKeysTest fail

时间:2023-11-23 11:23:10浏览次数:28  
标签:24 11 12 5387 19 cts manualTests security AndroidRuntime

异常日志:

11-12 19:24:47.649 5387 5387 D AndroidRuntime: Shutting down VM
11-12 19:24:47.671 5387 5387 E AndroidRuntime: FATAL EXCEPTION: main
11-12 19:24:47.671 5387 5387 E AndroidRuntime: Process: com.android.cts.verifier, PID: 5387
11-12 19:24:47.671 5387 5387 E AndroidRuntime: java.lang.RuntimeException: Failed to create a symmetric key
11-12 19:24:47.671 5387 5387 E AndroidRuntime: at com.android.cts.verifier.security.FingerprintBoundKeysTest.createKey(FingerprintBoundKeysTest.java:181)
11-12 19:24:47.671 5387 5387 E AndroidRuntime: at com.android.cts.verifier.security.FingerprintBoundKeysTest.startTest(FingerprintBoundKeysTest.java:138)
11-12 19:24:47.671 5387 5387 E AndroidRuntime: at com.android.cts.verifier.security.FingerprintBoundKeysTest$1.onClick(FingerprintBoundKeysTest.java:118)
11-12 19:24:47.671 5387 5387 E AndroidRuntime: at android.view.View.performClick(View.java:7448)
11-12 19:24:47.671 5387 5387 E AndroidRuntime: at android.view.View.performClickInternal(View.java:7425)
11-12 19:24:47.671 5387 5387 E AndroidRuntime: at android.view.View.access$3600(View.java:810)
11-12 19:24:47.671 5387 5387 E AndroidRuntime: at android.view.View$PerformClick.run(View.java:28305)
11-12 19:24:47.671 5387 5387 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:938)
11-12 19:24:47.671 5387 5387 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
11-12 19:24:47.671 5387 5387 E AndroidRuntime: at android.os.Looper.loop(Looper.java:223)
11-12 19:24:47.671 5387 5387 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7664)
11-12 19:24:47.671 5387 5387 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
11-12 19:24:47.671 5387 5387 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
11-12 19:24:47.671 5387 5387 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:948)
11-12 19:24:47.671 5387 5387 E AndroidRuntime: Caused by: java.security.InvalidAlgorithmParameterException: java.lang.IllegalStateException: At least one biometric must be enrolled to create keys requiring user authentication for every use
11-12 19:24:47.671 5387 5387 E AndroidRuntime: at android.security.keystore.AndroidKeyStoreKeyGeneratorSpi.engineInit(AndroidKeyStoreKeyGeneratorSpi.java:252)
11-12 19:24:47.671 5387 5387 E AndroidRuntime: at android.security.keystore.AndroidKeyStoreKeyGeneratorSpi$AES.engineInit(AndroidKeyStoreKeyGeneratorSpi.java:53)
11-12 19:24:47.671 5387 5387 E AndroidRuntime: at javax.crypto.KeyGenerator.init(KeyGenerator.java:519)
11-12 19:24:47.671 5387 5387 E AndroidRuntime: at javax.crypto.KeyGenerator.init(KeyGenerator.java:502)
11-12 19:24:47.671 5387 5387 E AndroidRuntime: at com.android.cts.verifier.security.FingerprintBoundKeysTest.createKey(FingerprintBoundKeysTest.java:162)
11-12 19:24:47.671 5387 5387 E AndroidRuntime: ... 13 more
11-12 19:24:47.671 5387 5387 E AndroidRuntime: Caused by: java.lang.IllegalStateException: At least one biometric must be enrolled to create keys requiring user authentication for every use
11-12 19:24:47.671 5387 5387 E AndroidRuntime: at android.security.keystore.KeymasterUtils.addSids(KeymasterUtils.java:110)
11-12 19:24:47.671 5387 5387 E AndroidRuntime: at android.security.keystore.KeymasterUtils.addUserAuthArgs(KeymasterUtils.java:174)
11-12 19:24:47.671 5387 5387 E AndroidRuntime: at android.security.keystore.AndroidKeyStoreKeyGeneratorSpi.engineInit(AndroidKeyStoreKeyGeneratorSpi.java:250)
11-12 19:24:47.671 5387 5387 E AndroidRuntime: ... 17 more

看下addSids这个函数:

private static void addSids(KeymasterArguments args, UserAuthArgs spec) {
    // If both biometric and credential are accepted, then just use the root sid from gatekeeper
    if (spec.getUserAuthenticationType() == (KeyProperties.AUTH_BIOMETRIC_STRONG
                                             | KeyProperties.AUTH_DEVICE_CREDENTIAL)) {
        if (spec.getBoundToSpecificSecureUserId() != GateKeeper.INVALID_SECURE_USER_ID) {
            args.addUnsignedLong(KeymasterDefs.KM_TAG_USER_SECURE_ID,
                    KeymasterArguments.toUint64(spec.getBoundToSpecificSecureUserId()));
        } else {
            // The key is authorized for use for the specified amount of time after the user has
            // authenticated. Whatever unlocks the secure lock screen should authorize this key.
            args.addUnsignedLong(KeymasterDefs.KM_TAG_USER_SECURE_ID,
                    KeymasterArguments.toUint64(getRootSid()));
        }
    } else {
        List<Long> sids = new ArrayList<>();
         if ((spec.getUserAuthenticationType() & KeyProperties.AUTH_BIOMETRIC_STRONG) != 0) {
             final BiometricManager bm = KeyStore.getApplicationContext()
                     .getSystemService(BiometricManager.class);

             // TODO: Restore permission check in getAuthenticatorIds once the ID is no longer
             // needed here.

             final long[] biometricSids = bm.getAuthenticatorIds();

             if (biometricSids.length == 0) {
                 throw new IllegalStateException(
                         "At least one biometric must be enrolled to create keys requiring user"
                         + " authentication for every use");
             }

             if (spec.getBoundToSpecificSecureUserId() != GateKeeper.INVALID_SECURE_USER_ID) {
                 sids.add(spec.getBoundToSpecificSecureUserId());
             } else if (spec.isInvalidatedByBiometricEnrollment()) {
                 // The biometric-only SIDs will change on biometric enrollment or removal of all
                 // enrolled templates, invalidating the key.
                 for (long sid : biometricSids) {
                     sids.add(sid);
                 }
             } else {
                 // The root SID will *not* change on fingerprint enrollment, or removal of all
                 // enrolled fingerprints, allowing the key to remain valid.
                 sids.add(getRootSid());
             }
         } else if ((spec.getUserAuthenticationType() & KeyProperties.AUTH_DEVICE_CREDENTIAL)
                         != 0) {
             sids.add(getRootSid());
         } else {
             throw new IllegalStateException("Invalid or no authentication type specified.");
         }

         for (int i = 0; i < sids.size(); i++) {
             args.addUnsignedLong(KeymasterDefs.KM_TAG_USER_SECURE_ID,
                     KeymasterArguments.toUint64(sids.get(i)));
         }
     }
 }

经过对BiometricService.java的getAuthenticatorIds函数和调用关系进一步分析,发现与frameworks/base/services/core/java/com/android/server/biometrics/AuthService.java中的getConfiguration方法有关,该方法会读取R.array.config_biometric_sensors的值来生成相关的配置和参数信息,android默认没有配置该值:

/**
 * Allows to test with various device sensor configurations.
 * @param context System Server context
 * @return the sensor configuration from core/res/res/values/config.xml
 */
@VisibleForTesting
public String[] getConfiguration(Context context) {
    return context.getResources().getStringArray(R.array.config_biometric_sensors);
}

默认配置:

frameworks/base/core/res/res/values/config.xml
<!-- List of biometric sensors on the device, in decreasing strength. Consumed by AuthService
     when registering authenticators with BiometricService. Format must be ID:Modality:Strength,
     where: IDs are unique per device, Modality as defined in BiometricAuthenticator.java,
     and Strength as defined in Authenticators.java -->
<string-array name="config_biometric_sensors" translatable="false" >
    <!-- <item>0:2:15</item>  ID0:Fingerprint:Strong -->
</string-array>

修改方法:在板极overlay的config.xml中增加该配置项即可

 

标签:24,11,12,5387,19,cts,manualTests,security,AndroidRuntime
From: https://www.cnblogs.com/xiululu/p/17851146.html

相关文章

  • PASETO - Platform-Agnostic SEcurity TOkens
       ......
  • CSP: Content-Security-Policy详解应对XSS攻击
    https://www.jianshu.com/p/74ea9f0860d2 CSP:Content-Security-Policy详解 前言跨域脚本攻击(XSS)是最常见、危害最大的网页安全漏洞。为了防止它,要采取很多编程措施(比如大多数人都知道的转义、过滤HTML)。很多人提出,能不能根本上解决问题,即浏览器自动禁止外部注入恶意脚......
  • 比较Spring Security6.X 和 Spring Security 5.X的不同
      项目使用了SpringBoot3,因此SpringSecurity也相应进行了升级版本由5.4.5升级到了6.1.5写法上发生了很大的变化,最显著的变化之一就是对WebSecurityConfigurerAdapter类的使用方式的改变。这个类在SpringSecurity中被广泛用于自定义安全配置。以下是主要的差异和写法上......
  • HUAWEI SECURITY 2023 山东大学专场 WP
    CryptobySmera1d01.ezrsa题干如下:fromCrypto.Util.numberimportgetPrimefromsecretimportflagp=getPrime(512)print(p,pow(flag,2,p))给出了\(p\)和\({flag}^2modp\)即我们需要解一个已知\(n\)和\(p\),求解\(x^2=n(modp)\)中\(x\)的值上网查阅发现\(Tonelli......
  • 第二章 ObjectScript 语法的基本规则
    大小写规则ObjectScript的某些部分区分大小写,而其他部分则不区分大小写。一般来说,ObjectScript的用户可定义部分区分大小写,而关键字则不区分大小写:区分大小写:变量名(局部、全局和进程私有全局)和变量下标、类名、方法名、属性名、属性的实例变量的i%前言、例程名称、宏名......
  • After Effects 2024:打造引人入胜的视觉效果 mac/win版
    AfterEffects2024是一款由Adobe公司开发的视频特效和动画制作软件,是专业影视制作领域的必备工具之一。它可以帮助用户在Windows或Mac操作系统上创建各种类型的视频动画和特效,包括2D和3D合成、动画、色彩校正、音频合成等等。点击获取AfterEffects2023AfterEffects2024具......
  • ObjectScript 语法学习一
    简介ObjectScript是一种对象编程语言,专为在InterSystemsIRIS®上快速开发复杂的业务应用程序而设计.作用ObjectScript源代码被编译为在InterSystemsIRIS虚拟机内执行的目标代码。该目标代码针对业务应用程序中常见的操作进行了高度优化,包括字符串操作和数据库访问。......
  • Adobe AfterEffects CC 2021 Mac Intel芯片 中文版
    软件介绍AfterEffects2021是Adobe推出的一款专业非线性视频编辑软件,经常需要编辑视频的人士对这款软件应该都不陌生吧。通过AfterEffects2021可以轻松制作火焰、冰雪、下雨等等视频后期特效,且效果都非常真实酷炫。软件自带丰富的动画资源库,满足用户的使用需求。神秘文件获......
  • Adobe AfterEffects CC 2021 Mac M1芯片 中文版
    软件介绍AfterEffects2021是Adobe推出的一款专业非线性视频编辑软件,经常需要编辑视频的人士对这款软件应该都不陌生吧。通过AfterEffects2021可以轻松制作火焰、冰雪、下雨等等视频后期特效,且效果都非常真实酷炫。软件自带丰富的动画资源库,满足用户的使用需求。神秘文件获......
  • 无涯教程-RSpec - Subjects主题
    RSpecsubjets提供了编写简写测试用例的快捷方式。考虑以下代码-classPersonattr_reader:first_name,:last_namedefinitialize(first_name,last_name)@first_name=first_name@last_name=last_nameendenddescribePersondo......