Skip to content

Commit 417daab

Browse files
committed
cmd/cosign: set default ko.SigningAlgorithm 2
Signed-off-by: Riccardo Schirone <[email protected]>
1 parent f5a6c54 commit 417daab

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

cmd/cosign/cli/sign/sign.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import (
5555
"github.com/sigstore/cosign/v2/pkg/oci/walk"
5656
sigs "github.com/sigstore/cosign/v2/pkg/signature"
5757
"github.com/sigstore/cosign/v2/pkg/types"
58+
pb_go_v1 "github.com/sigstore/protobuf-specs/gen/pb-go/common/v1"
5859
"github.com/sigstore/rekor/pkg/generated/models"
5960
"github.com/sigstore/sigstore/pkg/cryptoutils"
6061
"github.com/sigstore/sigstore/pkg/signature"
@@ -603,6 +604,13 @@ func signerFromKeyRef(ctx context.Context, certPath, certChainPath, keyRef strin
603604
}
604605

605606
func signerFromNewKey(signingAlgorithm string, defaultLoadOptions *[]signature.LoadOption) (*SignerVerifier, error) {
607+
if signingAlgorithm == "" {
608+
var err error
609+
signingAlgorithm, err = signature.FormatSignatureAlgorithmFlag(pb_go_v1.PublicKeyDetails_PKIX_ECDSA_P256_SHA_256)
610+
if err != nil {
611+
return nil, fmt.Errorf("formatting signature algorithm: %w", err)
612+
}
613+
}
606614
keyDetails, err := signature.ParseSignatureAlgorithmFlag(signingAlgorithm)
607615
if err != nil {
608616
return nil, fmt.Errorf("parsing signature algorithm: %w", err)

cmd/cosign/cli/sign/sign_blob.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import (
4040
cbundle "github.com/sigstore/cosign/v2/pkg/cosign/bundle"
4141
protobundle "github.com/sigstore/protobuf-specs/gen/pb-go/bundle/v1"
4242
protocommon "github.com/sigstore/protobuf-specs/gen/pb-go/common/v1"
43-
v1 "github.com/sigstore/protobuf-specs/gen/pb-go/common/v1"
4443
"github.com/sigstore/rekor/pkg/generated/models"
4544
"github.com/sigstore/sigstore-go/pkg/sign"
4645
"github.com/sigstore/sigstore/pkg/cryptoutils"
@@ -67,13 +66,6 @@ func SignBlobCmd(ro *options.RootOptions, ko options.KeyOpts, payloadPath string
6766
ctx, cancel := context.WithTimeout(context.Background(), ro.Timeout)
6867
defer cancel()
6968

70-
if ko.SigningAlgorithm == "" {
71-
ko.SigningAlgorithm, err = signature.FormatSignatureAlgorithmFlag(v1.PublicKeyDetails_PKIX_ECDSA_P256_SHA_256)
72-
if err != nil {
73-
return nil, fmt.Errorf("formatting signature algorithm: %w", err)
74-
}
75-
}
76-
7769
shouldUpload, err := ShouldUploadToTlog(ctx, ko, nil, tlogUpload)
7870
if err != nil {
7971
return nil, fmt.Errorf("upload to tlog: %w", err)

0 commit comments

Comments
 (0)