mirror of
https://github.com/google/go-attestation.git
synced 2024-12-20 21:43:16 +00:00
wrappedTPM20.ekTemplate() never returns an error. (#327)
This commit is contained in:
parent
a4b579bcf0
commit
b474b712d4
@ -37,9 +37,9 @@ type wrappedTPM20 struct {
|
|||||||
tpmEkTemplate *tpm2.Public
|
tpmEkTemplate *tpm2.Public
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *wrappedTPM20) ekTemplate() (tpm2.Public, error) {
|
func (t *wrappedTPM20) ekTemplate() tpm2.Public {
|
||||||
if t.tpmEkTemplate != nil {
|
if t.tpmEkTemplate != nil {
|
||||||
return *t.tpmEkTemplate, nil
|
return *t.tpmEkTemplate
|
||||||
}
|
}
|
||||||
|
|
||||||
nonce, err := tpm2.NVReadEx(t.rwc, nvramEkNonceIndex, tpm2.HandleOwner, "", 0)
|
nonce, err := tpm2.NVReadEx(t.rwc, nvramEkNonceIndex, tpm2.HandleOwner, "", 0)
|
||||||
@ -51,7 +51,7 @@ func (t *wrappedTPM20) ekTemplate() (tpm2.Public, error) {
|
|||||||
t.tpmEkTemplate = &template
|
t.tpmEkTemplate = &template
|
||||||
}
|
}
|
||||||
|
|
||||||
return *t.tpmEkTemplate, nil
|
return *t.tpmEkTemplate
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *wrappedTPM20) tpmVersion() TPMVersion {
|
func (t *wrappedTPM20) tpmVersion() TPMVersion {
|
||||||
@ -97,11 +97,7 @@ func (t *wrappedTPM20) getPrimaryKeyHandle(pHnd tpmutil.Handle) (tpmutil.Handle,
|
|||||||
case commonSrkEquivalentHandle:
|
case commonSrkEquivalentHandle:
|
||||||
keyHnd, _, err = tpm2.CreatePrimary(t.rwc, tpm2.HandleOwner, tpm2.PCRSelection{}, "", "", defaultSRKTemplate)
|
keyHnd, _, err = tpm2.CreatePrimary(t.rwc, tpm2.HandleOwner, tpm2.PCRSelection{}, "", "", defaultSRKTemplate)
|
||||||
case commonEkEquivalentHandle:
|
case commonEkEquivalentHandle:
|
||||||
var tmpl tpm2.Public
|
keyHnd, _, err = tpm2.CreatePrimary(t.rwc, tpm2.HandleEndorsement, tpm2.PCRSelection{}, "", "", t.ekTemplate())
|
||||||
if tmpl, err = t.ekTemplate(); err != nil {
|
|
||||||
return 0, false, fmt.Errorf("ek template: %v", err)
|
|
||||||
}
|
|
||||||
keyHnd, _, err = tpm2.CreatePrimary(t.rwc, tpm2.HandleEndorsement, tpm2.PCRSelection{}, "", "", tmpl)
|
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, false, fmt.Errorf("ReadPublic failed (%v), and then CreatePrimary failed: %v", rerr, err)
|
return 0, false, fmt.Errorf("ReadPublic failed (%v), and then CreatePrimary failed: %v", rerr, err)
|
||||||
@ -124,12 +120,7 @@ func (t *wrappedTPM20) eks() ([]EK, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Attempt to create an EK.
|
// Attempt to create an EK.
|
||||||
tmpl, err := t.ekTemplate()
|
ekHnd, _, err := tpm2.CreatePrimary(t.rwc, tpm2.HandleEndorsement, tpm2.PCRSelection{}, "", "", t.ekTemplate())
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("ek template: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
ekHnd, _, err := tpm2.CreatePrimary(t.rwc, tpm2.HandleEndorsement, tpm2.PCRSelection{}, "", "", tmpl)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("EK CreatePrimary failed: %v", err)
|
return nil, fmt.Errorf("EK CreatePrimary failed: %v", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user