本文整理匯總了Golang中github.com/coreos/go-tspi/tspi.Context.LoadKeyByBlob方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.LoadKeyByBlob方法的具體用法?Golang Context.LoadKeyByBlob怎麽用?Golang Context.LoadKeyByBlob使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/coreos/go-tspi/tspi.Context
的用法示例。
在下文中一共展示了Context.LoadKeyByBlob方法的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
}