1 Star 0 Fork 0

mysnapcore/mygo-tpm2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cphash.go 1.15 KB
一键复制 编辑 原始数据 按行查看 历史
// Copyright 2019 Canonical Ltd.
// Licensed under the LGPLv3 with static-linking exception.
// See LICENCE file for details.
package util
import (
"errors"
"gitee.com/mysnapcore/mygo-tpm2"
"gitee.com/mysnapcore/mygo-tpm2/mu"
)
// ComputeCpHash computes a command parameter digest from the specified command code, the supplied
// handles (identified by their names) and parameters using the specified digest algorithm.
//
// The required parameters is defined in part 3 of the TPM 2.0 Library Specification for the
// specific command.
//
// The result of this is useful for extended authorization commands that bind an authorization to
// a command and set of command parameters, such as TPMContext.PolicySigned, TPMContext.PolicySecret,
// TPMContext.PolicyTicket and TPMContext.PolicyCpHash.
func ComputeCpHash(alg tpm2.HashAlgorithmId, command tpm2.CommandCode, handles []tpm2.Name, params ...interface{}) (tpm2.Digest, error) {
if !alg.Available() {
return nil, errors.New("algorithm is not available")
}
cpBytes, err := mu.MarshalToBytes(params...)
if err != nil {
return nil, err
}
return tpm2.ComputeCpHash(alg, command, handles, cpBytes), nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/mysnapcore/mygo-tpm2.git
git@gitee.com:mysnapcore/mygo-tpm2.git
mysnapcore
mygo-tpm2
mygo-tpm2
v0.0.6

搜索帮助