...
1 package in_toto
2
3 import (
4 "fmt"
5 "os"
6 )
7
8
16
17 const LayoutPath = "demo.layout"
18 const LayoutKeyPath = "alice.pub"
19 const LinkDirectory = "."
20
21 func ExampleInTotoVerify() {
22
23
24
25 var pubKey Key
26 err := pubKey.LoadKey(LayoutKeyPath, "rsassa-pss-sha256", []string{"sha256", "sha512"})
27 if err != nil {
28 fmt.Printf("Unable to load public key: %s", err)
29 }
30 var layoutKeys = map[string]Key{
31 pubKey.KeyID: pubKey,
32 }
33
34
35
36 layoutMb, err := LoadMetadata(LayoutPath)
37 if err != nil {
38 fmt.Printf("Unable to load layout metadata: %s", err)
39 }
40 if err := validateLayout(layoutMb.GetPayload().(Layout)); err != nil {
41 fmt.Printf("Invalid metadata found: %s", err)
42 }
43 if _, err := InTotoVerify(layoutMb, layoutKeys, LinkDirectory, "",
44 make(map[string]string), [][]byte{}, testOSisWindows()); err != nil {
45 fmt.Printf("in-toto verification failed: %s", err)
46 } else {
47 fmt.Println("in-toto verification succeeded!")
48 }
49
50
51
52 err = os.Remove("untar.link")
53 if err != nil {
54 fmt.Printf("Unable to remove untar.link: %s", err)
55 }
56
57 }
58
View as plain text