Debian Codegraph @

verifier/oci/cosign/fakesignature.go

raw
1 package cosign
2
3 import (
4 "encoding/base64"
5 "fmt"
6
7 "github.com/google/go-tpm-tools/verifier/oci"
8 )
9
10 type fakeSig struct {
11 data string
12 sigAlg oci.SigningAlgorithm
13 }
14
15 // NewFakeSignature constructs a new fake oci.Signature given data and signature algorithm.
16 func NewFakeSignature(data string, sigAlg oci.SigningAlgorithm) oci.Signature {
17 return &fakeSig{data, sigAlg}
18 }
19
20 // Payload returns a fake payload.
21 func (f fakeSig) Payload() ([]byte, error) {
22 return []byte(f.data + "," + string(f.sigAlg)), nil
23 }
24
25 // Base64Encoded returns a fake base64 encoded signature.
26 func (f fakeSig) Base64Encoded() (string, error) {
27 return base64.StdEncoding.EncodeToString([]byte(f.data)), nil
28 }
29
30 // PublicKey returns a fake public key.
31 func (f fakeSig) PublicKey() ([]byte, error) {
32 return nil, fmt.Errorf("not implemented")
33 }
34
35 // SigningAlgorithm returns a fake signature algorithm.
36 func (f fakeSig) SigningAlgorithm() (oci.SigningAlgorithm, error) {
37 return "", fmt.Errorf("not implemented")
38 }