mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-06-01 20:52:10 -04:00
image: reimplement and adapt measurement generation in Go
This commit is contained in:
parent
8e706d6de3
commit
f6d9f91877
31 changed files with 1343 additions and 286 deletions
31
image/measured-boot/measure/authentihash.go
Normal file
31
image/measured-boot/measure/authentihash.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
Copyright (c) Edgeless Systems GmbH
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package measure
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"hash"
|
||||
"io"
|
||||
|
||||
"github.com/foxboron/go-uefi/efi/pecoff"
|
||||
)
|
||||
|
||||
// Authentihash returns the PE/COFF hash / Authentihash of a file.
|
||||
func Authentihash(r io.Reader, h hash.Hash) ([]byte, error) {
|
||||
buf := new(bytes.Buffer)
|
||||
if _, err := buf.ReadFrom(r); err != nil {
|
||||
return nil, fmt.Errorf("failed to read pe file: %v", err)
|
||||
}
|
||||
|
||||
signingCtx := pecoff.PECOFFChecksum(buf.Bytes())
|
||||
pecoff.PaddSigCtx(signingCtx)
|
||||
|
||||
h.Write(signingCtx.SigData.Bytes())
|
||||
|
||||
return h.Sum(nil), nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue