Skip to content

Commit

Permalink
refactor: simplify attestation manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
natesales committed Jan 15, 2025
1 parent e36b77c commit a00fcf4
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 23 deletions.
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func main() {
panic(err)
}

enclaveMeasurements, err = attestation.ParseAttestation(attDocJSON)
enclaveMeasurements, err = attestation.VerifyAttestation(attDocJSON)
if err != nil {
log.Fatalf("Failed to parse enclave attestation doc: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ func (c *Client) CheckAttestation() error {
}
}`

att, err := attestation.ParseAttestation(respBody)
att, err := attestation.VerifyAttestation([]byte(respBody))
if err != nil {
return err
}
log.Println(att.Measurements)
log.Println(att.Registers)

// "https://api.github.com/repos/" + repo + "/attestations/sha256:" + digest;

Expand Down
21 changes: 10 additions & 11 deletions pkg/attestation/attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"slices"
)

type MeasurementType string
type PredicateType string

const (
AWSNitroEnclaveV1 MeasurementType = "https://tinfoil.sh/predicate/aws-nitro-enclave/v1"
AWSNitroEnclaveV1 PredicateType = "https://tinfoil.sh/predicate/aws-nitro-enclave/v1"
)

var (
Expand All @@ -19,7 +19,7 @@ var (
)

type Measurement struct {
Type MeasurementType
Type PredicateType
Registers []string
}

Expand All @@ -36,22 +36,21 @@ func (m *Measurement) Equals(other *Measurement) error {

// Document represents an attestation document
type Document struct {
Version string `json:"version"` // Enclave's self-reported release version
Attestation struct {
Format MeasurementType `json:"format"`
Body string `json:"body"`
} `json:"attestation"`
Version string `json:"version"` // Enclave's self-reported release version
Format PredicateType `json:"format"`
Body string `json:"body"`
}

func ParseAttestation(attestationDocJSON []byte) (*Measurement, error) {
// VerifyAttestation validates the attestation document and returns the inner measurement
func VerifyAttestation(attestationDocJSON []byte) (*Measurement, error) {
var d Document
if err := json.Unmarshal(attestationDocJSON, &d); err != nil {
return nil, err
}

switch d.Attestation.Format {
switch d.Format {
case AWSNitroEnclaveV1:
return parseAWSNitroAttestation(d.Attestation.Body)
return verifyNitroAttestation(d.Body)
default:
return nil, ErrUnsupportedAttestationFormat
}
Expand Down
8 changes: 3 additions & 5 deletions pkg/attestation/attestation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ import (
func TestMainNitroVerifier(t *testing.T) {
payload := `{
"version": "v0.0.1",
"attestation": {
"format": "https://tinfoil.sh/predicate/aws-nitro-enclave/v1",
"body": "hEShATgioFkQ/6lpbW9kdWxlX2lkeCdpLTA4NGVlNTIxZDVmOTIxMDk2LWVuYzAxOTM2OTdkZjhlNDcwNjNmZGlnZXN0ZlNIQTM4NGl0aW1lc3RhbXAbAAABlE5MLItkcGNyc7AAWDBEBqggqpahA/zWQPqijfY4TjNZPThn2EzFnat6rM6oiXR01AWKMXRm6vEjSlbMII4BWDBLTVs2YbPvwSkgkAyA4Sbkzng8Ui3mwCoqW/evOiuTJ7hndvGI5L4cHEBKEp29pJMCWDDBHp3xYXzzMFM+Rcdcr8LaJLBN9OsKhmhIGxZp0x30ppDor2h4VTGPszX7K71Zb/sDWDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEWDDM5N5yesCUnVB1HrTnLihT3IzVWB8CbCUa7Zb7u2461AdTQ9WN6naoGN2rWMuzlRYFWDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGWDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHWDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIWDAAAAAAAAAAAAAAAAAA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IxMDk2LnVzLWVhc3QtMi5hd3Mubml0cm8tZW5jbGF2ZXMwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAASm6jRWRmZsKWV3gz8w99hrO0C0tyCKIri+4duo37r/r8Y/ODJf54sbvVU3o1BO9EcM/iOtPmre57qlYziMMorSl1NC/isUA3694XLRg3rBG5F1DfBIibhHk+OuY0SCShWjZjBkMBIGA1UdEwEB/wQIMAYBAf8CAQAwDgYDVR0PAQH/BAQDAgIEMB0GA1UdDgQWBBQVeqBm82IKX6mNBq8eEsqYX4lPmzAfBgNVHSMEGDAWgBQ1x9fEA2r0+s7OwmXOgAEKMa5fszAKBggqhkjOPQQDAwNoADBlAjAUUr7SWXmsYpuh4u9HsEnj9jXiIzQsEiKp5TUirDMAMD+EzZDEq2g7hWhkhqxj/5wCMQC/EoFi7JoD70rrf8hr50W+gul+QcGShsIDQ6GMbMOMXC0oIncopLINc5DVcPKhXwFqcHVibGljX2tlefZpdXNlcl9kYXRh9mVub25jZfZYYKyfchEsQ43Iq5aEasXCc5MvGGZ2aiWgWacnaT7CbG4Ac+Z/05zHjJemTGHd4U46Ms7LZO7+M2Mt04vxWs9F153/g4bZgjBjYqZpirp4NyI+mbDW0OAa5t9BldElnx6DVg=="
}`

undo := mockNitroVerifier()
defer undo()

attestation, err := ParseAttestation([]byte(payload))
attestation, err := VerifyAttestation([]byte(payload))
assert.Nil(t, err)
assert.Equal(t, 3, len(attestation.Registers))
}
4 changes: 2 additions & 2 deletions pkg/attestation/nitro.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ var (
NitroEnclaveVerifierOpts = nitrite.VerifyOptions{}
)

// parseAWSNitroAttestation decodes a base64 encoded attestation document,
// verifyNitroAttestation decodes a base64 encoded attestation document,
// verifies it against the AWS root, and returns the inner measurements
func parseAWSNitroAttestation(attestationDoc string) (*Measurement, error) {
func verifyNitroAttestation(attestationDoc string) (*Measurement, error) {
attDocBytes, err := base64.StdEncoding.DecodeString(attestationDoc)
if err != nil {
return nil, err
Expand Down
Loading

0 comments on commit a00fcf4

Please sign in to comment.