提交 28f51f18 编写于 作者: Y YiLin.Li 提交者: jia zhang

rune: Add GetSgxReport PAL API v3

Signed-off-by: NYilin Li <YiLin.Li@linux.alibaba.com>
上级 7b403451
......@@ -28,6 +28,7 @@ void *fptr_pal_exec;
void *fptr_pal_kill;
void *fptr_pal_destroy;
void *fptr_pal_create_process;
void *fptr_pal_get_local_report;
bool enclave_configured(void)
{
......@@ -78,6 +79,7 @@ int load_enclave_runtime(void)
DLSYM(exec);
DLSYM(kill);
DLSYM(destroy);
DLSYM(get_local_report);
#undef DLSYM
return 0;
......
......@@ -14,6 +14,7 @@ extern void *fptr_pal_exec;
extern void *fptr_pal_kill;
extern void *fptr_pal_destroy;
extern void *fptr_pal_create_process;
extern void *fptr_pal_get_local_report;
*/
import "C"
......@@ -41,6 +42,10 @@ func SymAddrPalDestroy() unsafe.Pointer {
return unsafe.Pointer(C.fptr_pal_destroy)
}
func SymAddrPalGetLocalReport() unsafe.Pointer {
return unsafe.Pointer(C.fptr_pal_get_local_report)
}
func SymAddrPalCreateProcess() unsafe.Pointer {
return unsafe.Pointer(C.fptr_pal_create_process)
}
......@@ -46,12 +46,11 @@ import "C"
import (
"fmt"
"github.com/opencontainers/runc/libcontainer/nsenter"
"github.com/sirupsen/logrus"
"os"
"strings"
"unsafe"
"github.com/opencontainers/runc/libcontainer/nsenter"
)
type enclaveRuntimePalApiV1 struct {
......
package enclave_runtime_pal // import "github.com/opencontainers/runc/libenclave/internal/runtime/pal"
/*
#include <stdlib.h>
#include <errno.h>
static int palGetLocalReport(void *sym, void *target_info, int target_info_len,
void *report, int* report_len)
{
return ((int (*)(void *, int, void*, int*))sym)(target_info, target_info_len,
report, report_len);
}
*/
import "C"
import (
"fmt"
"github.com/opencontainers/runc/libcontainer/nsenter"
"github.com/opencontainers/runc/libenclave/intelsgx"
"unsafe"
)
type enclaveRuntimePalApiV3 struct {
}
func (pal *enclaveRuntimePalApiV3) getLocalReport(targetInfo []byte) ([]byte, error) {
var ret C.int
reportBufSize := int32(intelsgx.ReportLength)
sym := nsenter.SymAddrPalGetLocalReport()
report := make([]byte, reportBufSize)
var pTargetInfo unsafe.Pointer = nil
if len(targetInfo) > 0 {
pTargetInfo = unsafe.Pointer(&targetInfo[0])
}
ret = C.palGetLocalReport(sym, pTargetInfo,
C.int(len(targetInfo)),
unsafe.Pointer(&report[0]),
(*C.int)(unsafe.Pointer(&reportBufSize)))
if ret == 0 {
return report, nil
}
return nil, fmt.Errorf("C.palGetLocalReport() failed, return %d.\n", ret)
}
......@@ -58,3 +58,12 @@ func (pal *enclaveRuntimePal) Destroy() error {
api := &enclaveRuntimePalApiV1{}
return api.destroy()
}
func (pal *enclaveRuntimePal) GetLocalReport(targetInfo []byte) ([]byte, error) {
if pal.version >= 3 {
api := &enclaveRuntimePalApiV3{}
return api.getLocalReport(targetInfo)
}
return nil, fmt.Errorf("unsupported pal api version %d", pal.version)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册