TSSMain-ek

使用的模板数据:

对应代码

 void ek() {
        // This policy is a "standard" policy that is used with vendor-provided
        // EKs
        byte[] standardEKPolicy = new byte[] { (byte) 0x83, 0x71, (byte) 0x97, 0x67, 0x44, (byte) 0x84, (byte) 0xb3,
                (byte) 0xf8, 0x1a, (byte) 0x90, (byte) 0xcc, (byte) 0x8d, 0x46, (byte) 0xa5, (byte) 0xd7, 0x24,
                (byte) 0xfd, 0x52, (byte) 0xd7, 0x6e, 0x06, 0x52, 0x0b, 0x64, (byte) 0xf2, (byte) 0xa1, (byte) 0xda,
                0x1b, 0x33, 0x14, 0x69, (byte) 0xaa };

        // Note: this sample allows userWithAuth - a "standard" EK does not (see
        // the other EK sample)
        TPMT_PUBLIC rsaEkTemplate = new TPMT_PUBLIC(TPM_ALG_ID.SHA256,
                new TPMA_OBJECT(TPMA_OBJECT.fixedTPM, TPMA_OBJECT.fixedParent, TPMA_OBJECT.sensitiveDataOrigin,
                        TPMA_OBJECT.userWithAuth,
                        /* TPMA_OBJECT.adminWithPolicy, */ TPMA_OBJECT.restricted, TPMA_OBJECT.decrypt),
                standardEKPolicy,
                new TPMS_RSA_PARMS(new TPMT_SYM_DEF_OBJECT(TPM_ALG_ID.AES,  128, TPM_ALG_ID.CFB),
                        new TPMS_NULL_ASYM_SCHEME(),  2048, 0),
                new TPM2B_PUBLIC_KEY_RSA());

        CreatePrimaryResponse rsaEk = tpm.CreatePrimary(TPM_HANDLE.from(TPM_RH.OWNER),
                new TPMS_SENSITIVE_CREATE(), rsaEkTemplate, new byte[0], new TPMS_PCR_SELECTION[0]);

        System.out.println("RSA EK: " + rsaEk.outPublic.toString());

        byte[] activationData = Helpers.RandomBytes(16);
        // Use tss.java to create an activation credential
        Tss.ActivationCredential bundle = Tss.createActivationCredential(rsaEk.outPublic,
                rsaEk.name, activationData);
        byte[] recoveredSecret = tpm.ActivateCredential(rsaEk.handle, rsaEk.handle, bundle.CredentialBlob, bundle.Secret);

        System.out.println("Activation in:        " + Helpers.toHex(activationData));
        System.out.println("Activation recovered: " + Helpers.toHex(recoveredSecret));
        if (!Helpers.arraysAreEqual(activationData, recoveredSecret))
            throw new RuntimeException("Data decrypt error");

        tpm.FlushContext(rsaEk.handle);
        return;
    }

授权策略: 837197674484b3f81a90cc8d46a5d724fd52d76e06520b64f2a1da1b331469aa

运行日志

Connecting to TPM Simulator
No dangling TRANSIENT handles
No dangling LOADED_SESSION handles
RSA EK: TPMT_PUBLIC =
{
    TPM_ALG_ID nameAlg = {SHA256}
    TPMA_OBJECT objectAttributes = {fixedTPM | fixedParent | sensitiveDataOrigin | userWithAuth | restricted | decrypt}
    byte[][] authPolicy = 83719767 4484b3f8 1a90cc8d 46a5d724 fd52d76e 06520b64 f2a1da1b 331469aa (32 bytes)
    TPMU_PUBLIC_PARMS parameters = 
    {
        TPMT_SYM_DEF_OBJECT symmetric = 
        {
            TPM_ALG_ID algorithm = {AES}
            int keyBits = 128 (0x80)
            TPM_ALG_ID mode = {CFB}
        }
        TPMU_ASYM_SCHEME scheme = 
        {
        }
        int keyBits = 2048 (0x800)
        int exponent = 0 (0x0)
    }
    TPMU_PUBLIC_ID unique = 
    {
        byte[][] buffer = ab46a231 bd39c475 c15060d2 cbceb6f2 6ee1b723 99186177 ef20b20a 74fa57a1 adcbbeab 13d1173d fff70d73 306cd987 bd18ac00 c437e90d 4aae5f2f 40c2f4ba 56d8cc2f bb659871 f3ec4db0 3105238e 43a36ac9 ca604c65 1612a27a 67249edb cb407cc4 51bc77f3 f7eac452 8e0abb14 62116e09 c78502d5 19af0100 6361318d 9079eab8 e500608f 9a27074d b4b1cb92 5805d466 f13b69ec 9cd60492 8276bf88 6e15cad5 4c0f4f13 d4ce5a6f 4b201dcf a9f8e8db 3e01b4cd b6d34322 1e8680e5 03797100 83d5be96 23b2e659 97636dce afb4f84d 433eff75 04e57a42 0d178c1c e43d29e3 58c293df f2ecf85a 114e0219 40ccf821 69c34eda 9a7426e4 9f4d8d63 (256 bytes)
    }
}
Activation in:        406e175c 97ef1fab ae922f3b db7b0630 (16 bytes)
Activation recovered: 406e175c 97ef1fab ae922f3b db7b0630 (16 bytes)
TSSMain: finished!
 

数据跟踪

代码位置

tss.TpmBase#DispatchCommand

    tss.TpmDeviceTcp#dispatchCommand

数据

standardEKPolicy 授权策略数据:
837197674484b3f81a90cc8d46a5d724fd52d76e06520b64f2a1da1b331469aa(32bytes)

rawCmdBuf 命令数据:
800200000063000001314000000100000009400000090000010000000400000000003a0001000b000300720020837197674484b3f81a90cc8d46a5d724fd52d76e06520b64f2a1da1b331469aa00060080004300100800000000000000000000000000(99bytes)


rawRespBuf 返回数据:
80020000021a000000008000000000000203013a0001000b000300720020837197674484b3f81a90cc8d46a5d724fd52d76e06520b64f2a1da1b331469aa00060080004300100800000000000100ab46a231bd39c475c15060d2cbceb6f26ee1b72399186177ef20b20a74fa57a1adcbbeab13d1173dfff70d73306cd987bd18ac00c437e90d4aae5f2f40c2f4ba56d8cc2fbb659871f3ec4db03105238e43a36ac9ca604c651612a27a67249edbcb407cc451bc77f3f7eac4528e0abb1462116e09c78502d519af01006361318d9079eab8e500608f9a27074db4b1cb925805d466f13b69ec9cd604928276bf886e15cad54c0f4f13d4ce5a6f4b201dcfa9f8e8db3e01b4cdb6d343221e8680e50379710083d5be9623b2e65997636dceafb4f84d433eff7504e57a420d178c1ce43d29e358c293dff2ecf85a114e021940ccf82169c34eda9a7426e49f4d8d630037000000000020e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855010010000440000001000440000001000000205da041bac0ee3135aebb0cadfba497c6a1877fae832dd3d1f8f7a871b825e854802140000001004008eefbd184a4d047385b00fa847b7f8b526e2ef421614e99f62f1e4dd9a9b2cffa634b9a32738f5f34b08c2fcd86120e66d5e35b6364ee295041ef2c6601c4940022000b07265f24a416c92791af3080e155ec614c90a99a3e6fc6a753263c07812d321d0000010000(538bytes)
 

数据解析

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值