Skip to content

Commit

Permalink
refactor: use nitrite
Browse files Browse the repository at this point in the history
  • Loading branch information
natesales committed Dec 8, 2024
1 parent 176cf44 commit 82d4f61
Show file tree
Hide file tree
Showing 32 changed files with 516 additions and 3,905 deletions.
5 changes: 3 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"os"
"strings"

"github.com/blocky/nitrite"
"github.com/tinfoilanalytics/verifier/pkg/models"
"github.com/tinfoilanalytics/verifier/pkg/nitro"
"github.com/tinfoilanalytics/verifier/pkg/sigstore"
)

Expand Down Expand Up @@ -108,10 +108,11 @@ func main() {
}
}

nitroMeasurements, err = nitro.VerifyAttestation(attDocBytes)
att, err := nitrite.Verify(attDocBytes, nitrite.VerifyOptions{})
if err != nil {
panic(err)
}
nitroMeasurements = models.MeasurementFromDoc(att.Document)
log.Println("Nitro", nitroMeasurements)
}

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ module github.com/tinfoilanalytics/verifier
go 1.23.2

require (
github.com/fxamacker/cbor/v2 v2.7.0
github.com/blocky/nitrite v0.0.1
github.com/sigstore/protobuf-specs v0.3.2
github.com/sigstore/sigstore-go v0.6.2
github.com/veraison/go-cose v1.2.1
)

require (
Expand All @@ -16,6 +15,7 @@ require (
github.com/digitorus/pkcs7 v0.0.0-20230818184609-3a137a874352 // indirect
github.com/digitorus/timestamp v0.0.0-20231217203849-220c5c2851b7 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-chi/chi v4.1.2+incompatible // indirect
github.com/go-jose/go-jose/v4 v4.0.2 // indirect
github.com/go-logr/logr v1.4.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/blocky/nitrite v0.0.1 h1:pw3sZWFu5ADubW5JOUI5WM1JJSZZqyGTwn/nMR12DEM=
github.com/blocky/nitrite v0.0.1/go.mod h1:Ava0jYckAHUqLIeROgFXzqlWJFdf/SdknIDrgmwOhB4=
github.com/cenkalti/backoff/v3 v3.2.2 h1:cfUAAO3yvKMYKPrvhDuHSwQnhZNk/RMHKdZqKTxfm6M=
github.com/cenkalti/backoff/v3 v3.2.2/go.mod h1:cIeZDE3IrqwwJl6VUwCN6trj1oXrTS4rc0ij+ULvLYs=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
Expand Down Expand Up @@ -308,8 +310,6 @@ github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 h1:e/5i7d4oYZ+C
github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399/go.mod h1:LdwHTNJT99C5fTAzDz0ud328OgXz+gierycbcIx2fRs=
github.com/transparency-dev/merkle v0.0.2 h1:Q9nBoQcZcgPamMkGn7ghV8XiTZ/kRxn1yCG81+twTK4=
github.com/transparency-dev/merkle v0.0.2/go.mod h1:pqSy+OXefQ1EDUVmAJ8MUhHB9TXGuzVAT58PqBoHz1A=
github.com/veraison/go-cose v1.2.1 h1:Gj4x20D0YP79J2+cK3anjGEMwIkg2xX+TKVVGUXwNAc=
github.com/veraison/go-cose v1.2.1/go.mod h1:t6V8WJzHm1PD5HNsuDjW3KLv577uWb6UTzbZGvdQHD8=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
github.com/zalando/go-keyring v0.2.3 h1:v9CUu9phlABObO4LPWycf+zwMG7nlbb3t/B5wa97yms=
Expand Down
15 changes: 14 additions & 1 deletion pkg/models/models.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package models

import "fmt"
import (
"encoding/hex"
"fmt"

"github.com/blocky/nitrite"
)

type Measurements struct {
PCR0 string
Expand All @@ -15,3 +20,11 @@ func (m *Measurements) Equals(other *Measurements) bool {
func (m *Measurements) String() string {
return fmt.Sprintf(`{"PCR0":"%s", "PCR1":"%s", "PCR2":"%s"}`, m.PCR0, m.PCR1, m.PCR2)
}

func MeasurementFromDoc(doc *nitrite.Document) *Measurements {
return &Measurements{
PCR0: hex.EncodeToString(doc.PCRs[0]),
PCR1: hex.EncodeToString(doc.PCRs[1]),
PCR2: hex.EncodeToString(doc.PCRs[2]),
}
}
14 changes: 0 additions & 14 deletions pkg/nitro/aws-nitro-root-g1.pem

This file was deleted.

101 changes: 0 additions & 101 deletions pkg/nitro/nitro.go

This file was deleted.

9 changes: 9 additions & 0 deletions vendor/github.com/blocky/nitrite/.editorconfig

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions vendor/github.com/blocky/nitrite/.vimrc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions vendor/github.com/blocky/nitrite/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions vendor/github.com/blocky/nitrite/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 82d4f61

Please sign in to comment.