image: reimplement and adapt measurement generation in Go

This commit is contained in:
Malte Poll 2023-09-21 14:50:18 +02:00 committed by Malte Poll
parent 8e706d6de3
commit f6d9f91877
31 changed files with 1343 additions and 286 deletions

View file

@ -0,0 +1,24 @@
/*
Copyright (c) Edgeless Systems GmbH
SPDX-License-Identifier: AGPL-3.0-only
*/
package pesection
// PESection describes a PE section.
type PESection struct {
Name string
Size uint32
Digest [32]byte
Measure bool
MeasureOrder int
}
// NullTerminatedName returns the name of the section with a null terminator.
func (u PESection) NullTerminatedName() []byte {
if len(u.Name) > 0 && u.Name[len(u.Name)-1] == 0x00 {
return []byte(u.Name)
}
return append([]byte(u.Name), 0x00)
}