github.com/epfl-dcsl/gotee@v0.0.0-20200909122901-014b35f5e5e9/src/gosec/types.go (about)

     1  package gosec
     2  
     3  const (
     4  	_PROT_NONE     = 0x0
     5  	_PROT_READ     = 0x1
     6  	_PROT_WRITE    = 0x2
     7  	_PROT_EXEC     = 0x4
     8  	_MAP_SHARED    = 0x01
     9  	_MAP_PRIVATE   = 0x02
    10  	_MAP_FIXED     = 0x10
    11  	_MAP_ANON      = 0x20
    12  	_MAP_NORESERVE = 0x4000
    13  	SGX_MAGIC      = 0xA4
    14  
    15  	ERR_SGX_INVALID_EINIT_TOKEN = 16
    16  	ERR_SGX_INVALID_CPUSVN      = 32
    17  	ERR_SGX_INVALID_ISVSVN      = 64
    18  	//TODO(aghosn) for the moment I hardcode it, but should be more resilient.
    19  	SGX_IOC_ENCLAVE_CREATE   = ((1 << 30) | (SGX_MAGIC << 8) | (0) | (8 << 16))
    20  	SGX_IOC_ENCLAVE_ADD_PAGE = ((1 << 30) | (SGX_MAGIC << 8) | (0x01) | (26 << 16))
    21  	SGX_IOC_ENCLAVE_INIT     = ((1 << 30) | (SGX_MAGIC << 8) | (0x02) | (24 << 16))
    22  
    23  	SGX_ATTR_MODE64BIT = 0x04
    24  	TCS_DBGOPTION      = 1
    25  )
    26  
    27  type einittoken_t struct {
    28  	valid              uint32
    29  	reserved           [44]uint8
    30  	attributes         attributes_t
    31  	mrEnclave          [32]uint8
    32  	reserved2          [32]uint8
    33  	mrSigner           [32]uint8
    34  	reserved3          [32]uint8
    35  	cpuSvnLE           [16]uint8
    36  	isvprodIDLE        uint16
    37  	isvsvnLE           uint16
    38  	reserved4          [24]uint8
    39  	maskedmiscSelectLE miscselect_t
    40  	maskedAttributesLE attributes_t
    41  	keyid              [32]uint8
    42  	mac                [16]uint8
    43  }
    44  
    45  type sigstruct_t struct {
    46  	header        [16]uint8
    47  	vendor        uint32
    48  	date          uint32
    49  	header2       [16]uint8
    50  	swdefined     uint32
    51  	reserved1     [84]uint8
    52  	modulus       [384]uint8
    53  	exponent      uint32
    54  	signature     [384]uint8
    55  	miscselect    miscselect_t
    56  	miscmask      miscselect_t
    57  	reserved2     [20]uint8
    58  	attributes    attributes_t
    59  	attributeMask attributes_t
    60  	enclaveHash   [32]uint8
    61  	reserved3     [32]uint8
    62  	isvProdID     uint16
    63  	isvSvn        uint16
    64  	reserved4     [12]uint8
    65  	q1            [384]uint8
    66  	q2            [384]uint8
    67  }
    68  
    69  type tcs_t struct {
    70  	reserved1 uint64 // 0
    71  	flags     uint64 /* (8)bit 0: DBGOPTION */
    72  	ossa      uint64 /* (16)State Save Area */
    73  	cssa      uint32 /* (24)Current SSA slot */
    74  	nssa      uint32 /* (28)Number of SSA slots */
    75  	oentry    uint64 /* (32)Offset in enclave to which control is transferred on EENTER if enclave INACTIVE state */
    76  	reserved2 uint64 /* (40) */
    77  	ofsbasgx  uint64 /* (48)When added to the base address of the enclave, produces the base address FS segment inside the enclave */
    78  	ogsbasgx  uint64 /* (56)When added to the base address of the enclave, produces the base address GS segment inside the enclave */
    79  	fslimit   uint32 /* (64)Size to become the new FS limit in 32-bit mode */
    80  	gslimit   uint32 /* (68)Size to become the new GS limit in 32-bit mode */
    81  	reserved3 [503]uint64
    82  }
    83  
    84  type secs_t struct {
    85  	size                   uint64 //!< Size of enclave in bytes; must be power of 2
    86  	baseAddr               uint64 //!< Enclave base linear address must be naturally aligned to size
    87  	ssaFrameSize           uint32 //!< Size of 1 SSA frame in pages(incl. XSAVE)
    88  	miscselect             miscselect_t
    89  	reserved1              [24]uint8
    90  	attributes             uint64 //!< Attributes of Enclave: (pg 2-4)
    91  	xfrm                   uint64
    92  	mrEnclave              [32]uint8 //!< Measurement Reg of encl. build process
    93  	reserved2              [32]uint8
    94  	mrSigner               [32]uint8 //!< Measurement Reg extended with pub key that verified the enclave
    95  	reserved3              [96]uint8
    96  	isvprodID              uint16 //!< Product ID of enclave
    97  	isvsvn                 uint16 //!< Security Version Number (SVN) of enclave
    98  	mrEnclaveUpdateCounter uint64 //!< Hack: place update counter here
    99  	eid_reserved           secs_eid_reserved_t
   100  }
   101  
   102  type miscselect_t struct {
   103  	Value     uint8
   104  	Reversed2 [3]uint8
   105  }
   106  
   107  type attributes_t struct {
   108  	value     uint8
   109  	reserved4 [7]uint8
   110  	xfrm      uint64
   111  }
   112  
   113  // TODO(aghosn) fix this: reserved and eid/pad should overlap according to the sgx reference
   114  type secs_eid_reserved_t struct {
   115  	eid_pad  secs_eid_pad_t
   116  	reserved [3836]uint8 //!< Reserve 8 bytes for update counter.
   117  }
   118  
   119  // (ref 2.7, table 2-2)
   120  type secs_eid_pad_t struct {
   121  	eid     uint64     //!< Enclave Identifier
   122  	padding [352]uint8 //!< Padding pattern from Signature
   123  }