Skip to content

Commit

Permalink
Merge pull request #168 from 9elements/txt-prov-aux-delete
Browse files Browse the repository at this point in the history
Fix Policy Control/2 parsing, add PS index aux delete check
  • Loading branch information
zaolin authored Feb 17, 2021
2 parents ac244aa + 9d4da68 commit 8373927
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 3 additions & 0 deletions pkg/provisioning/auxdelete.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import (

// DeleteAUXindexTPM20 deletes the AUX index on TPM 2.0
func DeleteAUXindexTPM20(rw io.ReadWriter, pol *tools.LCPPolicy2, passHash []byte) error {
if !pol.ParsePolicyControl2().AuxDelete {
return fmt.Errorf("AuxDelete not set in LCP Policy")
}
err := WritePSIndexTPM20(rw, pol, passHash)
if err != nil {
return err
Expand Down
16 changes: 8 additions & 8 deletions pkg/tools/lcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,20 +378,20 @@ type LCPPolicyData struct {
// ParsePolicyControl TODO needs to be reverse engineered
func (p *LCPPolicy) ParsePolicyControl() PolicyControl {
var polCtrl PolicyControl
polCtrl.NPW = (p.PolicyControl>>1)&1 != 0
polCtrl.SinitCaps = (p.PolicyControl>>2)&1 != 0
polCtrl.AuxDelete = (p.PolicyControl>>15)&1 != 0
polCtrl.OwnerEnforced = (p.PolicyControl>>3)&1 != 0
polCtrl.NPW = (p.PolicyControl>>0)&1 != 0
polCtrl.SinitCaps = (p.PolicyControl>>1)&1 != 0
polCtrl.AuxDelete = (p.PolicyControl>>31)&1 != 0
polCtrl.OwnerEnforced = (p.PolicyControl>>2)&1 != 0
return polCtrl
}

// ParsePolicyControl2 TODO needs to be reverse engineered
func (p *LCPPolicy2) ParsePolicyControl2() PolicyControl {
var polCtrl PolicyControl
polCtrl.NPW = (p.PolicyControl>>1)&1 != 0
polCtrl.SinitCaps = (p.PolicyControl>>2)&1 != 0
polCtrl.AuxDelete = (p.PolicyControl>>15)&1 != 0
polCtrl.OwnerEnforced = (p.PolicyControl>>3)&1 != 0
polCtrl.NPW = (p.PolicyControl>>0)&1 != 0
polCtrl.SinitCaps = (p.PolicyControl>>1)&1 != 0
polCtrl.AuxDelete = (p.PolicyControl>>31)&1 != 0
polCtrl.OwnerEnforced = (p.PolicyControl>>2)&1 != 0
return polCtrl
}

Expand Down

0 comments on commit 8373927

Please sign in to comment.