Android IdentityCredential (アイデンティティ証明書) 2

IC TAコードデバッグ

static const uint8_t hbkTest[16] = {0};
// hbkReal需要对接到具体系统中的API,该密钥需要具备每台设备唯一的特性,而且每次开机都需要保持不变
static const uint8_t hbkReal[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};***

const uint8_t* eicOpsGetHardwareBoundKey(bool testCredential) {
    if (testCredential) {
        return hbkTest;
    }
    return hbkReal;
}
//challenge: gatekeeper的token传入的;
//secureUserId: gatekeeper的token传入的;
//authenticatorId: gatekeeper的token传入的;没有被反序
//timeStamp: gatekeeper的token传入的;没有反序
//mac: gatekeeper的token传入的;
//注意计算与对比mac的时候,需要保证gatekeeper模块的hmac key与此模块相同,
//并保证timeStap,authenticatorId,authenticatorType是否反序与gatekeeper模块保持一致;

//verificationTokenChallenge: IC模块产生,传入keymaster,
//verificationTokenTimeStamp, keymaster模块产生;
//verificationTokenSecurityLevel: keymaster模块产生;
// verificationTokenMac: keymaster模块产生;

//注意:这里边的时间戳都是boot time,是开机时间,单位是ms
//此函数的实现需要验证两个token中的mac,并比较challenge
// 这个地方要不要比较两个token中的timestap,目前不确定?
bool eicOpsValidateAuthToken(uint64_t challenge, uint64_t secureUserId, uint64_t authenticatorId,
                             int hardwareAuthenticatorType, uint64_t timeStamp, const uint8_t* mac,
                             size_t macSize, uint64_t verificationTokenChallenge,
                             uint64_t verificationTokenTimeStamp,
                             int verificationTokenSecurityLevel,
                             const uint8_t* verificationTokenMac, size_t verificationTokenMacSize);

IC CA コードのデバッグ

次の静的クラス メンバー関数が FakeSecureHardwareProxy.h ファイルで定義されています:
static EicPresentation ctx_;
static EicSession ctx_;
static EicProvisioning ctx_;
重要な機密情報は ctx に保存されており、この部分の実装は、機密情報の漏洩、
そしてここに REE を実装すると同時実行の問題も発生し、複数の CA 呼び出しを行うと ctx 情報が混乱して保存できなくなるため、ここを TEE に置き換える場合は、配列または動的メモリの使用を検討してください。

おすすめ

転載: blog.csdn.net/weixin_47139576/article/details/128780979