Merge pull request #189 from 9elements/fix/bpmStitchAndCut
Fix BPM --cut option and BPM Stitching
This commit is contained in:
commit
2b028cc0e3
|
@ -455,7 +455,7 @@ func (g *generateBPMCmd) Run(ctx *context) error {
|
|||
return err
|
||||
}
|
||||
if g.Cut {
|
||||
bBPM = bBPM[:bpm.PMSEOffset()]
|
||||
bBPM = bBPM[:bpm.KeySignatureOffset]
|
||||
}
|
||||
if err = ioutil.WriteFile(g.BPM, bBPM, 0600); err != nil {
|
||||
return fmt.Errorf("unable to write BPM to file: %w", err)
|
||||
|
|
|
@ -40,9 +40,15 @@ func StitchKM(km *key.Manifest, pubKey crypto.PublicKey, signature []byte) ([]by
|
|||
|
||||
// StitchBPM returns a boot policy manifest as byte slice
|
||||
func StitchBPM(bpm *bootpolicy.Manifest, pubKey crypto.PublicKey, signature []byte) ([]byte, error) {
|
||||
PMSEString := [8]byte{0x5f, 0x5f, 0x50, 0x4d, 0x53, 0x47, 0x5f, 0x5f}
|
||||
bpm.PMSE.StructInfo = bootpolicy.StructInfo{}
|
||||
bpm.PMSE.StructInfo.ID = PMSEString
|
||||
bpm.PMSE.StructInfo.Version = 0x20
|
||||
|
||||
if err := bpm.PMSE.KeySignature.FillSignature(0, pubKey, signature, manifest.AlgNull); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bpm.RehashRecursive()
|
||||
if err := bpm.Validate(); err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Reference in New Issue