github.com/yogeshkumararora/slsa-github-generator@v1.10.1-0.20240520161934-11278bd5afb4/signing/signer.go (about)

     1  // Copyright 2023 SLSA Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package signing
    16  
    17  import (
    18  	"context"
    19  
    20  	intoto "github.com/in-toto/in-toto-golang/in_toto"
    21  )
    22  
    23  // Attestation is a signed attestation.
    24  type Attestation interface {
    25  	// Cert returns the certificate used to sign the attestation.
    26  	Cert() []byte
    27  
    28  	// Bytes returns the signed attestation as an encoded DSSE JSON envelope.
    29  	Bytes() []byte
    30  }
    31  
    32  // Signer is used to sign provenance statements.
    33  type Signer interface {
    34  	// Sign signs the given provenance statement and returns the signed
    35  	// attestation.
    36  	Sign(context.Context, *intoto.Statement) (Attestation, error)
    37  }
    38  
    39  // LogEntry represents a transparency log entry.
    40  type LogEntry interface {
    41  	// ID returns the ID of the transparency log.
    42  	ID() string
    43  
    44  	// LogIndex return the index of the transparency log entry.
    45  	LogIndex() int64
    46  
    47  	// UUID return the uuid of the transparency log entry.
    48  	UUID() string
    49  }
    50  
    51  // TransparencyLog allows interaction with a transparency log.
    52  type TransparencyLog interface {
    53  	// Upload uploads the signed attestation to the transparency log.
    54  	Upload(context.Context, Attestation) (LogEntry, error)
    55  }