rune/libenclave/intelsgx: add the IsProductEnclave method to check the enclave type
package intelsgx // import "github.com/inclavare-containers/rune/libenclave/intelsgx"
+import (
+ "fmt"
+ "unsafe"
+)
+
var (
sgx1Supported bool = false
sgx2Supported bool = false
@@ -204,3 +209,16 @@ func GetExtendedSGXFeatures() uint32 {
func GetMaxEnclaveSizeBits() uint32 {
return maxEnclaveSizeBits
}
+
+// Check whether the enclave is a product enclave or not
+func IsProductEnclave(reportBody ReportBody) (bool, error) {
+ if unsafe.Sizeof(reportBody) != ReportBodyLength {
+ return false, fmt.Errorf("len(report) is not %d, but %d", ReportBodyLength, unsafe.Sizeof(reportBody))
+ }
+
+ if reportBody.Attributes[0]&0x02 != 0x0 {
+ return false, nil
+ }
+
+ return false, nil
+}
