本文整理匯總了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
}