Skip to content

Commit

Permalink
Switch DSSE provider to go-securesystemslib (#111)
Browse files Browse the repository at this point in the history
Signed-off-by: Aditya Sirish <aditya@saky.in>
  • Loading branch information
adityasaky committed Sep 30, 2021
1 parent 56a91f5 commit 866281b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ require (
github.com/google/go-cmp v0.5.6
github.com/google/go-containerregistry v0.5.1
github.com/hashicorp/vault/api v1.1.1
github.com/in-toto/in-toto-golang v0.2.1-0.20210627200632-886210ae2ab9
github.com/mitchellh/go-homedir v1.1.0
github.com/pkg/errors v0.9.1
github.com/secure-systems-lab/go-securesystemslib v0.1.0
github.com/segmentio/ksuid v1.0.4
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
github.com/stretchr/testify v1.7.0
Expand All @@ -28,5 +29,4 @@ require (
google.golang.org/genproto v0.0.0-20210722135532-667f2b7c528f
google.golang.org/protobuf v1.27.1
gopkg.in/square/go-jose.v2 v2.6.0
github.com/mitchellh/go-homedir v1.1.0
)
5 changes: 2 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,6 @@ github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKe
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/in-toto/in-toto-golang v0.2.1-0.20210627200632-886210ae2ab9 h1:j7klXz5kh0ydPmHkBtJ/Al27G1/au4sH7OkGhkgRJWg=
github.com/in-toto/in-toto-golang v0.2.1-0.20210627200632-886210ae2ab9/go.mod h1:Skbg04kmfB7IAnEIsspKPg/ny1eiFt/TgPr9SDCHusA=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik=
Expand Down Expand Up @@ -475,9 +473,10 @@ github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFo
github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk=
github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc=
github.com/sclevine/spec v1.2.0/go.mod h1:W4J29eT/Kzv7/b9IWLB055Z+qvVC9vt0Arko24q7p+U=
github.com/secure-systems-lab/go-securesystemslib v0.1.0 h1:wZNQ7t1UTOQtDL/+PBPzxI52gLQGyC7qfXyJh6Lgf1Y=
github.com/secure-systems-lab/go-securesystemslib v0.1.0/go.mod h1:eIjBmIP8LD2MLBL/DkQWayLiz006Q4p+hCu79rvWleY=
github.com/segmentio/ksuid v1.0.4 h1:sBo2BdShXjmcugAMwjugoGUdUV0pcxY5mW4xKRn3v4c=
github.com/segmentio/ksuid v1.0.4/go.mod h1:/XUiZBD3kVx5SmUOl55voK5yeAbBNNIed+2O73XgrPE=
github.com/shibumi/go-pathspec v1.2.0/go.mod h1:bDxCftD0fST3qXIlHoQ/fChsU4mWMVklXp1yPErQaaY=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.0.4-0.20170822132746-89742aefa4b2/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
Expand Down
12 changes: 6 additions & 6 deletions pkg/signature/dsse/dsse.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"io"
"io/ioutil"

"github.com/in-toto/in-toto-golang/pkg/ssl"
"github.com/secure-systems-lab/go-securesystemslib/dsse"
"github.com/sigstore/sigstore/pkg/signature"
)

Expand All @@ -48,16 +48,16 @@ func (w *wrappedSigner) SignMessage(r io.Reader, opts ...signature.SignOption) (
if err != nil {
return nil, err
}
pae := ssl.PAE(w.payloadType, string(p))
pae := dsse.PAE(w.payloadType, string(p))
sig, err := w.s.SignMessage(bytes.NewReader(pae), opts...)
if err != nil {
return nil, err
}

env := ssl.Envelope{
env := dsse.Envelope{
PayloadType: w.payloadType,
Payload: base64.StdEncoding.EncodeToString(p),
Signatures: []ssl.Signature{
Signatures: []dsse.Signature{
{
Sig: base64.StdEncoding.EncodeToString(sig),
},
Expand Down Expand Up @@ -86,12 +86,12 @@ func (w *wrappedVerifier) VerifySignature(s io.Reader, _ io.Reader, opts ...sign
return err
}

env := ssl.Envelope{}
env := dsse.Envelope{}
if err := json.Unmarshal(sig, &env); err != nil {
return nil
}

verifier := ssl.NewEnvelopeVerifier(&innerWrapper{v: w.v})
verifier := dsse.NewEnvelopeVerifier(&innerWrapper{v: w.v})
return verifier.Verify(&env)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/signature/dsse/dsse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"strings"
"testing"

"github.com/in-toto/in-toto-golang/pkg/ssl"
"github.com/secure-systems-lab/go-securesystemslib/dsse"
"github.com/sigstore/sigstore/pkg/signature"
)

Expand Down Expand Up @@ -55,7 +55,7 @@ func TestRoundTrip(t *testing.T) {
t.Fatal(err)
}

env := ssl.Envelope{}
env := dsse.Envelope{}
if err := json.Unmarshal(sig, &env); err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 866281b

Please sign in to comment.