代码拉取完成,页面将自动刷新
// Copyright 2021 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"
)
// ComputeQualifiedName can compute the qualified name of an object with
// the specified name that is protected by a parent with the specified
// qualified name.
func ComputeQualifiedName(name, parentQn tpm2.Name) (tpm2.Name, error) {
if name.Algorithm() == tpm2.HashAlgorithmNull {
return nil, errors.New("invalid name")
}
if !name.Algorithm().Available() {
return nil, errors.New("name algorithm is not available")
}
h := name.Algorithm().NewHash()
h.Write(parentQn)
h.Write(name)
return mu.MarshalToBytes(name.Algorithm(), mu.RawBytes(h.Sum(nil)))
}
// ComputeQualifiedNameFull can compute the qualified name of an object with
// the specified name that is protected in the specified hierarchy by the chain
// of parent objects with the specified names. The ancestor names are ordered
// from the primary key towards the immediate parent.
func ComputeQualifiedNameFull(name tpm2.Name, hierarchy tpm2.Handle, ancestors ...tpm2.Name) (tpm2.Name, error) {
lastQn := tpm2.Name(mu.MustMarshalToBytes(hierarchy))
for len(ancestors) > 0 {
current := ancestors[0]
ancestors = ancestors[1:]
var err error
lastQn, err = ComputeQualifiedName(current, lastQn)
if err != nil {
return nil, err
}
}
return ComputeQualifiedName(name, lastQn)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。