-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
42 lines (34 loc) · 844 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
40
41
42
package main
import (
"fmt"
"log"
"os"
"github.com/edgelesssys/go-tdx-qpl/tdx"
)
func main() {
if err := testTDX(); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
}
func testTDX() error {
handle, err := os.Open(tdx.GuestDevice)
if err != nil {
return err
}
defer handle.Close()
extendData := "This machine is not backdoored :)"
if err := tdx.ExtendRTMR(handle, []byte(extendData), 2); err != nil {
return err
}
reportData := []byte{'H', 'e', 'l', 'l', 'o', ' ', 'f', 'r', 'o', 'm', ' ', 'E', 'd', 'g', 'e', 'l', 'e', 's', 's', ' ', 'S', 'y', 's', 't', 'e', 'm', 's', '!'}
quote, err := tdx.GenerateQuote(handle, reportData)
if err != nil {
return err
}
if err := os.WriteFile("quote", quote, 0o644); err != nil {
return err
}
log.Println("Successfully written quote")
return nil
}