Skip to content

Commit

Permalink
build fix WIP(2)
Browse files Browse the repository at this point in the history
  • Loading branch information
valdok committed Apr 2, 2024
1 parent 972629c commit 58cfcbf
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions x/registration/remote_attestation/remote_attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,29 @@ import (
)

type CombinedHdr struct {
M_CombinedSizes [3]uint32
M_CombinedSizes [3]uint32
}

type DcapQuote struct {
M_Opaque1 [48]byte // sgx_quote_t up to report_body
M_Opaque2 [320]byte // sgx_report_body_t up to report_ata
M_PubKey [32]byte
M_Opaque3 [32]byte // remaining 32 bytes of report_data
M_SigLen uint32
M_Opaque1 [48]byte // sgx_quote_t up to report_body
M_Opaque2 [320]byte // sgx_report_body_t up to report_ata
M_PubKey [32]byte
M_Opaque3 [32]byte // remaining 32 bytes of report_data
M_SigLen uint32
}

func VerifyCombinedCert(blob []byte) ([]byte, error) {

var hdr CombinedHdr

if uintptr(len(blob)) < unsafe.Sizeof(hdr) {
return nil, errors.New("Combined hdr too small");
return nil, errors.New("Combined hdr too small")
}

{
buf := bytes.NewReader(blob)
err := binary.Read(buf, binary.LittleEndian, &hdr)
if err != nil {
return nil, err;
return nil, err
}
}

Expand All @@ -48,13 +47,13 @@ func VerifyCombinedCert(blob []byte) ([]byte, error) {
idx3 := idx2 + uintptr(hdr.M_CombinedSizes[2])

if uintptr(len(blob)) < idx3 {
return nil, errors.New("combined hdr invalid");
return nil, errors.New("combined hdr invalid")
}

if idx1 > idx0 {
ret_pk, ret_err := VerifyRaCert(blob[idx0:idx1]);
ret_pk, ret_err := VerifyRaCert(blob[idx0:idx1])
if ret_pk != nil {
fmt.Println("EPID quote Extracted pk: ", hex.EncodeToString(ret_pk[:]))
fmt.Println("EPID quote Extracted pk: ", hex.EncodeToString(ret_pk))
}
return ret_pk, ret_err
}
Expand All @@ -64,7 +63,6 @@ func VerifyCombinedCert(blob []byte) ([]byte, error) {

buf := bytes.NewReader(blob[idx1:idx2])
err := binary.Read(buf, binary.LittleEndian, &quote)

if err != nil {
return nil, err
}
Expand All @@ -76,7 +74,6 @@ func VerifyCombinedCert(blob []byte) ([]byte, error) {
return nil, errors.New("No valid attestatoin found")
}


/*
Verifies the remote attestation certificate, which is comprised of a the attestation report, intel signature, and enclave signature
Expand Down

0 comments on commit 58cfcbf

Please sign in to comment.