当前位置: 首页>>代码示例>>Golang>>正文


Golang Context.CreatePolicy方法代码示例

本文整理汇总了Golang中github.com/coreos/go-tspi/tspi.Context.CreatePolicy方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.CreatePolicy方法的具体用法?Golang Context.CreatePolicy怎么用?Golang Context.CreatePolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/coreos/go-tspi/tspi.Context的用法示例。


在下文中一共展示了Context.CreatePolicy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: AIKChallengeResponse

// AIKChallengeResponse takes the output from GenerateChallenge along with the
// encrypted AIK key blob. The TPM then decrypts the asymmetric challenge with
// its EK in order to obtain the AES key, and uses the AES key to decrypt the
// symmetrically encrypted data. It verifies that this data blob corresponds
// to the AIK it was given, and if so hands back the secret contained within
// the symmetrically encrypted data.
func AIKChallengeResponse(context *tspi.Context, aikblob []byte, asymchallenge []byte, symchallenge []byte) (secret []byte, err error) {
	var wellKnown [20]byte

	srk, err := context.LoadKeyByUUID(tspi.TSS_PS_TYPE_SYSTEM, tspi.TSS_UUID_SRK)
	if err != nil {
		return nil, err
	}
	srkpolicy, err := srk.GetPolicy(tspi.TSS_POLICY_USAGE)
	if err != nil {
		return nil, err
	}
	srkpolicy.SetSecret(tspi.TSS_SECRET_MODE_SHA1, wellKnown[:])

	tpm := context.GetTPM()
	tpmpolicy, err := context.CreatePolicy(tspi.TSS_POLICY_USAGE)
	if err != nil {
		return nil, err
	}
	tpm.AssignPolicy(tpmpolicy)
	tpmpolicy.SetSecret(tspi.TSS_SECRET_MODE_SHA1, wellKnown[:])

	aik, err := context.LoadKeyByBlob(srk, aikblob)
	if err != nil {
		return nil, err
	}
	secret, err = tpm.ActivateIdentity(aik, asymchallenge, symchallenge)

	return secret, err
}
开发者ID:sinfomicien,项目名称:rkt,代码行数:35,代码来源:attestation.go


注:本文中的github.com/coreos/go-tspi/tspi.Context.CreatePolicy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。