Skip to content

Commit

Permalink
add comments to the Signer implementations
Browse files Browse the repository at this point in the history
Signed-off-by: Jake Sanders <jsand@google.com>
  • Loading branch information
Jake Sanders committed Nov 29, 2021
1 parent df3a2e6 commit 22d3366
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/pkg/cosign/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ type Signer interface {
Sign(context.Context, *SigningRequest) (*SigningResults, error)
}

// PayloadSigner implements `Signer`
type PayloadSigner struct {
PayloadSigner signature.Signer
PayloadSignerOpts []signature.SignOption
PublicKeyProviderOpts []signature.PublicKeyOption
}

// Sign uses the PayloadSigner to sign the requested payload, then returns the signature, the public key associated with it, the signed payload
func (ps *PayloadSigner) Sign(ctx context.Context, req *SigningRequest) (*SigningResults, error) {
sOpts := []signature.SignOption{signatureoptions.WithContext(ctx)}
sOpts = append(sOpts, ps.PayloadSignerOpts...)
Expand All @@ -80,6 +82,7 @@ func (ps *PayloadSigner) Sign(ctx context.Context, req *SigningRequest) (*Signin
}, nil
}

// FulcioSignerWrapper implements `Signer`
type FulcioSignerWrapper struct {
Inner Signer

Expand All @@ -100,10 +103,12 @@ func (fs *FulcioSignerWrapper) Sign(ctx context.Context, req *SigningRequest) (*
return results, nil
}

// OCISignatureBuilder implements `Signer`
type OCISignatureBuilder struct {
Inner Signer
}

// Sign calls the Inner signer and then returns the `oci.Signature` corresponding to the Signature, Cert, Chain, and Bundle in the overall result
func (sb *OCISignatureBuilder) Sign(ctx context.Context, req *SigningRequest) (*SigningResults, error) {
results, err := sb.Inner.Sign(ctx, req)
if err != nil {
Expand All @@ -129,12 +134,14 @@ func (sb *OCISignatureBuilder) Sign(ctx context.Context, req *SigningRequest) (*
return results, nil
}

// OCISignatureAttacher implements `Signer`
type OCISignatureAttacher struct {
Inner Signer

DD mutate.DupeDetector
}

// Sign calls the Inner signer and then attaches the resulting `oci.Signature` to the resulting `oci.SignedEntity`
func (sa *OCISignatureAttacher) Sign(ctx context.Context, req *SigningRequest) (*SigningResults, error) {
results, err := sa.Inner.Sign(ctx, req)
if err != nil {
Expand All @@ -151,13 +158,15 @@ func (sa *OCISignatureAttacher) Sign(ctx context.Context, req *SigningRequest) (
return results, nil
}

// RemoteSignerWrapper implements `Signer`
type RemoteSignerWrapper struct {
Inner Signer

SignatureRepo name.Repository
RegOpts options.RegistryOptions
}

// Sign calls the Inner signer and then uploads the image signature artifacts to the specified remote OCI repository
func (rs *RemoteSignerWrapper) Sign(ctx context.Context, req *SigningRequest) (*SigningResults, error) {
results, err := rs.Inner.Sign(ctx, req)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions internal/pkg/cosign/tlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ func uploadToTlog(rekorBytes []byte, rekorURL string, upload tlogUploadFn) (*oci
return bundle(entry), nil
}

// RekorSignerWrapper implements `Signer`
type RekorSignerWrapper struct {
Inner Signer

RekorURL string
}

// Sign calls a wrapped, inner signer then uploads either the Cert or Pub(licKey) of the results to Rekor, then adds the resulting `Bundle`
func (rs *RekorSignerWrapper) Sign(ctx context.Context, req *SigningRequest) (*SigningResults, error) {
results, err := rs.Inner.Sign(ctx, req)
if err != nil {
Expand Down

0 comments on commit 22d3366

Please sign in to comment.