gpt4 book ai didi

android - 展示如何使用 Android ID 认证的示例代码

转载 作者:行者123 更新时间:2023-12-03 14:33:53 42 4
gpt4 key购买 nike

Android 8 添加了“ID 证明”(根据 https://source.android.com/security/keystore/attestation#id-attestation)。

有没有人想出如何使用这个功能?我找到的最接近的是 AttestationUtils.java ( https://android.googlesource.com/platform/frameworks/base/+/master/keystore/java/android/security/keystore/AttestationUtils.java ),但我没有任何这些 API 随 Android SDK 一起提供。使用 P 时,它们不会出现在我的 IDE 中开发者预览版( compileSdkVersion 'android-P'targetSdkVersion 'P' )。

最佳答案

我能够破解并想出了一个进行 key /ID 证明的演示代码。见 https://github.com/monkey-jsun/android-id-attestation/tree/master

在程序运行时,我现在有两个问题,

  • 所有硬件 ID 都显示为“NOT PRESENT”。见下文。显然他们在那里。如何让它们出现?
  • 目前我们一步生成 key 及其证明(keyPairGenerator.generateKeyPair()),因为我们必须在初始化 keyPairGenerator 时请求证明。这是非常不自然的。有没有办法在创建 key 后请求 key /ID 证明?

  • 这是我的演示代码的快速回顾,仅供快速引用:
  • 在 keystore 中生成带有质询短语的 key 对
  • 获取 key 对及其证书链
  • 使用充气城堡库显示证书 [0] 扩展数据

  • 我还附上了程序的输出以方便引用。
     Getting key 'key1' ...
    found the key with alias 'key1' ...
    private key : android.security.keystore.AndroidKeyStoreECPrivateKey@3467522e
    public key : MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEOfYzvOETzK0NGmlkk3vnuDb9FilG7iiRYGJX2pQy
    Syuyt2XZow5M3aseZEfD64iasieuumWx3Tn6/aiopre0cw==
    what is happening ...
    number certificates in the chain is 4
    Attestation version: 3
    Attestation Security Level: TRUSTED_ENVIRONMENT
    Keymaster Version: 4
    Keymaster Security Level: TRUSTED_ENVIRONMENT
    Attestation Challenge: hello, this is challenge phrase [jsun]
    Unique ID: []
    =========
    Software Enforced Authorization List:
    Purpose(s): NOT PRESENT
    Algorithm: NOT PRESENT
    Key Size: NOT PRESENT
    Digest: NOT PRESENT
    Padding: NOT PRESENT
    EC Curve: NOT PRESENT
    RSA Public Exponent: NOT PRESENT
    Rollback Resistance: false
    Active DateTime: NOT PRESENT
    Origination Expire DateTime: NOT PRESENT
    Usage Expire DateTime: NOT PRESENT
    No Auth Required: false
    User Auth Type: NOT PRESENT
    Auth Timeout: NOT PRESENT
    Allow While On Body: false
    Trusted User Presence Required: false
    Trusted Confirmation Required: false
    Unlocked Device Required: false
    All Applications: false
    Application ID: NOT PRESENT
    Creation DateTime: 2020-03-07T17:58:57.143Z
    Origin: NOT PRESENT
    Rollback Resistant: false
    OS Version: NOT PRESENT
    OS Patch Level: NOT PRESENT
    Attestation Application ID:
    Package Infos (<package name>, <version>):
    net.junsun.idattestation, 1
    Signature Digests:
    GGv7HVeENa6GZO4irSicN64Wz38NJ7QHsmC0Z2G7s4g=
    Attestation Application ID Bytes: MEUxHzAdBBhuZXQuanVuc3VuLmlkYXR0ZXN0YXRpb24CAQExIgQgGGv7HVeENa6GZO4irSicN64Wz38NJ7QHsmC0Z2G7s4g=
    Attestation ID Brand: NOT PRESENT
    Attestation ID Device: NOT PRESENT
    Attestation ID Product: NOT PRESENT
    Attestation ID Serial: NOT PRESENT
    Attestation ID IMEI: NOT PRESENT
    Attestation ID MEID: NOT PRESENT
    Attestation ID Manufacturer: NOT PRESENT
    Attestation ID Model: NOT PRESENT
    Vendor Patch Level: NOT PRESENT
    Boot Patch Level: NOT PRESENT
    =========
    TEE Enforced Authorization List:
    Purpose(s): [2, 3]
    Algorithm: 3
    Key Size: 256
    Digest: NOT PRESENT
    Padding: NOT PRESENT
    EC Curve: 1
    RSA Public Exponent: NOT PRESENT
    Rollback Resistance: false
    Active DateTime: NOT PRESENT
    Origination Expire DateTime: NOT PRESENT
    Usage Expire DateTime: NOT PRESENT
    No Auth Required: true
    User Auth Type: NOT PRESENT
    Auth Timeout: NOT PRESENT
    Allow While On Body: false
    Trusted User Presence Required: false
    Trusted Confirmation Required: false
    Unlocked Device Required: false
    All Applications: false
    Application ID: NOT PRESENT
    Creation DateTime: NOT PRESENT
    Origin: 0
    Rollback Resistant: false
    OS Version: 100000
    OS Patch Level: 202002
    Attestation Application ID Bytes: NOT PRESENT
    Attestation ID Brand: NOT PRESENT
    Attestation ID Device: NOT PRESENT
    Attestation ID Product: NOT PRESENT
    Attestation ID Serial: NOT PRESENT
    Attestation ID IMEI: NOT PRESENT
    Attestation ID MEID: NOT PRESENT
    Attestation ID Manufacturer: NOT PRESENT
    Attestation ID Model: NOT PRESENT
    Vendor Patch Level: 20200205
    Boot Patch Level: 20200205

    关于android - 展示如何使用 Android ID 认证的示例代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49184356/

    42 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com