File tree 2 files changed +21
-3
lines changed
2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 9
9
10
10
var (
11
11
outputPath string
12
+ verifyFile bool
12
13
)
13
14
14
15
var signCmd = & cobra.Command {
@@ -26,7 +27,7 @@ func init() {
26
27
"output" ,
27
28
"o" ,
28
29
"" ,
29
- `Path to store metadata file to be signed ` ,
30
+ `Path to store metadata file after signing ` ,
30
31
)
31
32
32
33
signCmd .Flags ().StringVarP (
@@ -47,9 +48,15 @@ root layout's signature(s). Passing exactly one key using
47
48
'--key' is required.` ,
48
49
)
49
50
51
+ signCmd .Flags ().BoolVar (
52
+ & verifyFile ,
53
+ "verify" ,
54
+ false ,
55
+ "Verify signature of signed file" ,
56
+ )
57
+
50
58
signCmd .MarkFlagRequired ("file" )
51
59
signCmd .MarkFlagRequired ("key" )
52
- signCmd .MarkFlagRequired ("output" )
53
60
}
54
61
55
62
func sign (cmd * cobra.Command , args []string ) error {
@@ -64,6 +71,16 @@ func sign(cmd *cobra.Command, args []string) error {
64
71
return fmt .Errorf ("invalid key at %s: %w" , keyPath , err )
65
72
}
66
73
74
+ if verifyFile {
75
+ if err := layoutMb .VerifySignature (key ); err != nil {
76
+ return fmt .Errorf ("signature verification failed: %w" , err )
77
+ }
78
+ return nil
79
+ }
80
+
81
+ if len (outputPath ) == 0 {
82
+ outputPath = layoutPath
83
+ }
67
84
layoutMb .Sign (key )
68
85
layoutMb .Dump (outputPath )
69
86
Original file line number Diff line number Diff line change @@ -18,7 +18,8 @@ in-toto sign [flags]
18
18
-k, --key string Path to PEM formatted private key used to sign the passed
19
19
root layout's signature(s). Passing exactly one key using
20
20
'--key' is required.
21
- -o, --output string Path to store metadata file to be signed
21
+ -o, --output string Path to store metadata file after signing
22
+ --verify Verify signature of signed file
22
23
```
23
24
24
25
### SEE ALSO
You can’t perform that action at this time.
0 commit comments