Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pcs/pcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const (
pckCertExtensionSize = 6
sgxExtensionMinSize = 4
tcbExtensionSize = 18
piidSize = 16
ppidSize = 16
cpuSvnSize = 16
fmspcSize = 6
Expand Down Expand Up @@ -77,6 +78,8 @@ var (
OidFMSPC = asn1.ObjectIdentifier([]int{1, 2, 840, 113741, 1, 13, 1, 4})
// OidSGXType is the x509v3 extension for PCK certificate's SGX Extensions SGX Type value.
OidSGXType = asn1.ObjectIdentifier([]int{1, 2, 840, 113741, 1, 13, 1, 5})
// OidPIID is the x509v3 extension for PCK certificate's SGX Extensions PIID value.
OidPIID = asn1.ObjectIdentifier([]int{1, 2, 840, 113741, 1, 13, 1, 6})

// ErrPckExtInvalid error returned when parsing PCK certificate's extension returns leftover bytes
ErrPckExtInvalid = errors.New("unexpected leftover bytes for PCK certificate's extension")
Expand Down Expand Up @@ -185,6 +188,7 @@ type PckExtensions struct {
PCEID string
FMSPC string
SGXType SGXType
PIID string
}

// SGXType represents the type of the platform for which the PCK certificate was created
Expand Down Expand Up @@ -466,6 +470,12 @@ func extractSgxExtensions(extensions []asn1.RawValue) (*PckExtensions, error) {
}
pckExtension.SGXType = SGXType(sExtension.Value)
}
if sExtension.Type.Equal(OidPIID) {
pckExtension.PIID, err = extractAsn1OctetStringExtension("PIID", extensions[i], piidSize)
if err != nil {
return nil, err
}
}
}
return pckExtension, nil
}
Expand Down
2 changes: 2 additions & 0 deletions verify/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ func TestPckCertificateExtensions(t *testing.T) {
}
pckExt := &pcs.PckExtensions{}
ppidBytes := []byte{8, 157, 223, 219, 156, 3, 89, 200, 42, 59, 199, 113, 146, 57, 87, 78}
piidBytes := []byte{0x8c, 0x31, 0x4d, 0x17, 0xd2, 0x5, 0xdf, 0xaf, 0xcb, 0xec, 0xbb, 0x0, 0xfc, 0x87, 0xef, 0xf7}
fmspcBytes := []byte{80, 128, 111, 0, 0, 0}
pceIDBytes := []byte{0, 0}
pckExt.PPID = hex.EncodeToString(ppidBytes)
pckExt.PIID = hex.EncodeToString(piidBytes)
pckExt.FMSPC = hex.EncodeToString(fmspcBytes)
pckExt.PCEID = hex.EncodeToString(pceIDBytes)
pckExt.SGXType = pcs.SGXTypeScalable
Expand Down
Loading