-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
39 lines (31 loc) · 877 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"bufio"
"fmt"
"os"
"github.com/anjuna-security/go-nitro-attestation/verifier"
)
func main() {
// Unmarshal the report into a SignedAttestationReport object
file, _ := os.Open("report.bin")
report, err := verifier.NewSignedAttestationReport(bufio.NewReader(file))
if err != nil {
panic(err)
}
// Validate the report's root of trust
if err = verifier.Validate(report, nil); err != nil {
panic(err)
}
// Access the PCR values as hex strings
hexPCRs := verifier.ConvertPCRsToHex(report.Document.PCRs)
// Validate the PCR values with any custom logic you want
if hexPCRs[0] != "000000" {
panic("PCR0 value is not as expected")
}
if hexPCRs[1] != "000001" {
panic("PCR1 value is not as expected")
}
fmt.Println("Report is valid!")
// Access the user data
fmt.Printf("Recovered user data: %s\n", report.Document.UserData)
}