16
16
package options
17
17
18
18
import (
19
+ "fmt"
20
+ "strings"
21
+
19
22
"github.com/spf13/cobra"
20
23
21
24
"github.com/sigstore/cosign/v2/internal/pkg/cosign"
25
+ cosign_v2 "github.com/sigstore/cosign/v2/pkg/cosign"
26
+ v1 "github.com/sigstore/protobuf-specs/gen/pb-go/common/v1"
27
+ "github.com/sigstore/sigstore/pkg/signature"
22
28
)
23
29
24
30
type CommonVerifyOptions struct {
@@ -56,13 +62,14 @@ func (o *CommonVerifyOptions) AddFlags(cmd *cobra.Command) {
56
62
57
63
// VerifyOptions is the top level wrapper for the `verify` command.
58
64
type VerifyOptions struct {
59
- Key string
60
- CheckClaims bool
61
- Attachment string
62
- Output string
63
- SignatureRef string
64
- PayloadRef string
65
- LocalImage bool
65
+ Key string
66
+ SigningAlgorithm string
67
+ CheckClaims bool
68
+ Attachment string
69
+ Output string
70
+ SignatureRef string
71
+ PayloadRef string
72
+ LocalImage bool
66
73
67
74
CommonVerifyOptions CommonVerifyOptions
68
75
SecurityKey SecurityKeyOptions
@@ -90,6 +97,11 @@ func (o *VerifyOptions) AddFlags(cmd *cobra.Command) {
90
97
"path to the public key file, KMS URI or Kubernetes Secret" )
91
98
_ = cmd .Flags ().SetAnnotation ("key" , cobra .BashCompFilenameExt , []string {})
92
99
100
+ keyAlgorithmTypes := cosign_v2 .GetSupportedAlgorithms ()
101
+ keyAlgorithmHelp := fmt .Sprintf ("accepted signing algorithm to use for verifying the signature (allowed %s)" , strings .Join (keyAlgorithmTypes , ", " ))
102
+ defaultKeyFlag , _ := signature .FormatSignatureAlgorithmFlag (v1 .KnownSignatureAlgorithm_ECDSA_SHA2_256_NISTP256 )
103
+ cmd .Flags ().StringVar (& o .SigningAlgorithm , "signing-algorithm" , defaultKeyFlag , keyAlgorithmHelp )
104
+
93
105
cmd .Flags ().BoolVar (& o .CheckClaims , "check-claims" , true ,
94
106
"whether to check the claims found" )
95
107
@@ -154,9 +166,10 @@ func (o *VerifyAttestationOptions) AddFlags(cmd *cobra.Command) {
154
166
155
167
// VerifyBlobOptions is the top level wrapper for the `verify blob` command.
156
168
type VerifyBlobOptions struct {
157
- Key string
158
- Signature string
159
- BundlePath string
169
+ Key string
170
+ SigningAlgorithm string
171
+ Signature string
172
+ BundlePath string
160
173
161
174
SecurityKey SecurityKeyOptions
162
175
CertVerify CertVerifyOptions
@@ -178,6 +191,11 @@ func (o *VerifyBlobOptions) AddFlags(cmd *cobra.Command) {
178
191
cmd .Flags ().StringVar (& o .Key , "key" , "" ,
179
192
"path to the public key file, KMS URI or Kubernetes Secret" )
180
193
194
+ keyAlgorithmTypes := cosign_v2 .GetSupportedAlgorithms ()
195
+ keyAlgorithmHelp := fmt .Sprintf ("accepted signing algorithm to use for verifying the signature (allowed %s)" , strings .Join (keyAlgorithmTypes , ", " ))
196
+ defaultKeyFlag , _ := signature .FormatSignatureAlgorithmFlag (v1 .KnownSignatureAlgorithm_ECDSA_SHA2_256_NISTP256 )
197
+ cmd .Flags ().StringVar (& o .SigningAlgorithm , "signing-algorithm" , defaultKeyFlag , keyAlgorithmHelp )
198
+
181
199
cmd .Flags ().StringVar (& o .Signature , "signature" , "" ,
182
200
"signature content or path or remote URL" )
183
201
0 commit comments