本文整理汇总了Golang中github.com/jlmucb/cloudproxy/go/tao/auth.Prin.Parent方法的典型用法代码示例。如果您正苦于以下问题:Golang Prin.Parent方法的具体用法?Golang Prin.Parent怎么用?Golang Prin.Parent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jlmucb/cloudproxy/go/tao/auth.Prin
的用法示例。
在下文中一共展示了Prin.Parent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: DeriveManifest
// Derive returns a manifest for a principal based on previously published info
// and/or the principal name itself.
func DeriveManifest(p *auth.Prin) Manifest {
m := Manifest{}
parent := p.Parent()
if parent == nil {
if p.Type == "tpm" {
pcr := Manifest{}
nums, vals, err := ExtractPCRs(*p)
if err != nil {
pcr["Status"] = "Unknown"
} else {
for i := 0; i < len(nums) && i < len(vals); i++ {
pcr[fmt.Sprintf("PCR %d", nums[i])] = vals[i]
}
}
aik := Manifest{}
k, err := ExtractAIK(*p)
if err != nil {
aik["Status"] = "Unknown"
} else {
aik["Type"] = "RSA"
aik["Size"] = k.N.BitLen()
aik["Exponent"] = k.E
aik["Modulus"] = k.N.Bytes()
}
m["Type"] = "Trusted Platform Module"
m["TPM"] = Manifest{
"Platform Configuration Registers": pcr,
"Public Attestation Identity Key": aik,
}
} else if p.Type == "key" {
key := Manifest{}
v, err := FromPrincipal(*p)
if err != nil {
key["Status"] = "Unknown"
} else {
switch v := v.PublicKey().(type) {
case *ecdsa.PublicKey:
key["Algorithm"] = "ECDSA"
key["Curve"] = ecdsaCurveName[v.Curve]
key["X"] = v.X.Bytes()
key["Y"] = v.Y.Bytes()
}
}
m["Type"] = "Public Key Principal"
m["Key"] = key
} else {
m["Type"] = "Unrecognized"
}
return m
} else {
m["Subprincipal Extension"] = p.Ext.String()
}
for _, f := range filenames(p) {
b, err := ioutil.ReadFile(f)
// TODO(kwalsh) reap expired and malformed files
if err != nil {
continue
}
var a Attestation
if err = proto.Unmarshal(b, &a); err != nil {
glog.Errorf("Ignoring malformed manifest %s\n", f)
continue
}
says, err := a.Validate()
if err != nil {
glog.Errorf("Ignoring invalid manifest %s\n", f)
continue
}
if !says.Speaker.Identical(parent) {
glog.Errorf("Ignoring misplaced manifest %s\n", f)
continue
}
if !says.Active(time.Now().UnixNano()) {
glog.Errorf("Ignoring expired manifest %s\n", f)
continue
}
m.Extend(p, says.Message)
}
m["Parent"] = DeriveManifest(parent)
return m
}