MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / SignMessage

Method SignMessage

pkg/attestation/signer/timestamp.go:34–56  ·  view source on GitHub ↗
(ctx context.Context, payload []byte)

Source from the content-addressed store, hash-verified

32}
33
34func (ts *TimestampSigner) SignMessage(ctx context.Context, payload []byte) ([]byte, error) {
35 // TSA signature
36 tsa := sign.NewTimestampAuthority(&sign.TimestampAuthorityOptions{
37 URL: ts.tsaURL,
38 })
39
40 // See bug: https://github.com/chainloop-dev/chainloop/issues/1832
41 // signature might be encoded twice. Let's try to fix it first.
42 // TODO: remove this once the bug is fixed
43 toSign := payload
44 dst := make([]byte, base64.RawURLEncoding.DecodedLen(len(payload)))
45 i, err := base64.StdEncoding.Decode(dst, payload)
46 if err == nil {
47 // get the decoded
48 toSign = dst[:i]
49 }
50
51 tsaSig, err := tsa.GetTimestamp(ctx, toSign)
52 if err != nil {
53 return nil, fmt.Errorf("getting timestamp signature: %w", err)
54 }
55 return tsaSig, nil
56}

Callers 1

RenderMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected