xref: /openbmc/linux/tools/testing/selftests/sgx/main.h (revision 25b892b5)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright(c) 2016-20 Intel Corporation.
4  */
5 
6 #ifndef MAIN_H
7 #define MAIN_H
8 
9 struct encl_segment {
10 	off_t offset;
11 	size_t size;
12 	unsigned int prot;
13 	unsigned int flags;
14 };
15 
16 struct encl {
17 	int fd;
18 	void *bin;
19 	off_t bin_size;
20 	void *src;
21 	size_t src_size;
22 	size_t encl_size;
23 	off_t encl_base;
24 	unsigned int nr_segments;
25 	struct encl_segment *segment_tbl;
26 	struct sgx_secs secs;
27 	struct sgx_sigstruct sigstruct;
28 };
29 
30 extern unsigned char sign_key[];
31 extern unsigned char sign_key_end[];
32 
33 void encl_delete(struct encl *ctx);
34 bool encl_load(const char *path, struct encl *encl);
35 bool encl_measure(struct encl *encl);
36 bool encl_build(struct encl *encl);
37 
38 int sgx_enter_enclave(void *rdi, void *rsi, long rdx, u32 function, void *r8, void *r9,
39 		      struct sgx_enclave_run *run);
40 
41 #endif /* MAIN_H */
42