提交 455c8d9d 编写于 作者: jia zhang's avatar jia zhang

rune & runectl: Refector aesm service

In order to involve more aesm services, prepare to place all request
and response messages into the corresponding main sections.
Signed-off-by: jia zhang's avatarJia Zhang <zhang.jia@linux.alibaba.com>
上级 a15e9b5a
...@@ -86,8 +86,8 @@ func GetToken(sig []byte) ([]byte, error) { ...@@ -86,8 +86,8 @@ func GetToken(sig []byte) ([]byte, error) {
} }
defer conn.Close() defer conn.Close()
req := pb.GetTokenRequestMessage{} req := pb.AesmServiceRequest{}
req.Req = &pb.GetTokenRequest{ req.GetLaunchToken = &pb.AesmServiceRequest_GetLaunchToken{
Enclavehash: mrenclave, Enclavehash: mrenclave,
Modulus: modulus, Modulus: modulus,
Attributes: attributes, Attributes: attributes,
...@@ -133,21 +133,21 @@ func GetToken(sig []byte) ([]byte, error) { ...@@ -133,21 +133,21 @@ func GetToken(sig []byte) ([]byte, error) {
msgSizeRead, msgSize) msgSizeRead, msgSize)
} }
resp := pb.GetTokenResponseMessage{} resp := pb.AesmServiceResponse{}
resp.Resp = &pb.GetTokenResponse{} resp.GetLaunchToken = &pb.AesmServiceResponse_GetLaunchToken{}
if err := proto.Unmarshal(rdata, &resp); err != nil { if err := proto.Unmarshal(rdata, &resp); err != nil {
return nil, err return nil, err
} }
if resp.Resp.GetError() != 0 { if resp.GetLaunchToken.GetError() != 0 {
return nil, fmt.Errorf("failed to get EINITTOKEN (error code = %d)", return nil, fmt.Errorf("failed to get EINITTOKEN (error code = %d)",
resp.Resp.GetError()) resp.GetLaunchToken.GetError())
} }
token := resp.Resp.GetToken() token := resp.GetLaunchToken.GetToken()
if len(token) != EinittokenLength { if len(token) != EinittokenLength {
return nil, fmt.Errorf("invalid length of token: (returned %d, expected %d)", return nil, fmt.Errorf("invalid length of token: (returned %d, expected %d)",
len(resp.Resp.GetToken()), EinittokenLength) len(token), EinittokenLength)
} }
tok := &Einittoken{} tok := &Einittoken{}
...@@ -179,5 +179,5 @@ func GetToken(sig []byte) ([]byte, error) { ...@@ -179,5 +179,5 @@ func GetToken(sig []byte) ([]byte, error) {
logrus.Debugf(" MAC: 0x%v\n", logrus.Debugf(" MAC: 0x%v\n",
hex.EncodeToString(tok.Mac[:])) hex.EncodeToString(tok.Mac[:]))
return resp.Resp.GetToken(), nil return resp.GetLaunchToken.GetToken(), nil
} }
...@@ -2,22 +2,26 @@ syntax = "proto3"; ...@@ -2,22 +2,26 @@ syntax = "proto3";
package aesm_service; // import "github.com/opencontainers/runc/libenclave/intelsgx/proto" package aesm_service; // import "github.com/opencontainers/runc/libenclave/intelsgx/proto"
message GetTokenRequest { // Refer to https://github.com/intel/linux-sgx/blob/master/psw/ae/aesm_service/source/core/ipc/messages.proto
message AesmServiceRequest {
message GetLaunchToken {
bytes enclavehash = 1; bytes enclavehash = 1;
bytes modulus = 2; bytes modulus = 2;
bytes attributes = 3; bytes attributes = 3;
uint32 timeout = 4; uint32 timeout = 9;
} }
message GetTokenRequestMessage { GetLaunchToken getLaunchToken = 3;
GetTokenRequest req = 3;
} }
message GetTokenResponse { message AesmServiceResponse {
int32 error = 1;
message GetLaunchToken {
uint32 error = 1;
bytes token = 2; bytes token = 2;
} }
message GetTokenResponseMessage { GetLaunchToken getLaunchToken = 3;
GetTokenResponse resp = 3;
} }
...@@ -86,8 +86,8 @@ func GetToken(sig []byte) ([]byte, error) { ...@@ -86,8 +86,8 @@ func GetToken(sig []byte) ([]byte, error) {
} }
defer conn.Close() defer conn.Close()
req := pb.GetTokenRequestMessage{} req := pb.AesmServiceRequest{}
req.Req = &pb.GetTokenRequest{ req.GetLaunchToken = &pb.AesmServiceRequest_GetLaunchToken{
Enclavehash: mrenclave, Enclavehash: mrenclave,
Modulus: modulus, Modulus: modulus,
Attributes: attributes, Attributes: attributes,
...@@ -133,21 +133,21 @@ func GetToken(sig []byte) ([]byte, error) { ...@@ -133,21 +133,21 @@ func GetToken(sig []byte) ([]byte, error) {
msgSizeRead, msgSize) msgSizeRead, msgSize)
} }
resp := pb.GetTokenResponseMessage{} resp := pb.AesmServiceResponse{}
resp.Resp = &pb.GetTokenResponse{} resp.GetLaunchToken = &pb.AesmServiceResponse_GetLaunchToken{}
if err := proto.Unmarshal(rdata, &resp); err != nil { if err := proto.Unmarshal(rdata, &resp); err != nil {
return nil, err return nil, err
} }
if resp.Resp.GetError() != 0 { if resp.GetLaunchToken.GetError() != 0 {
return nil, fmt.Errorf("failed to get EINITTOKEN (error code = %d)", return nil, fmt.Errorf("failed to get EINITTOKEN (error code = %d)",
resp.Resp.GetError()) resp.GetLaunchToken.GetError())
} }
token := resp.Resp.GetToken() token := resp.GetLaunchToken.GetToken()
if len(token) != EinittokenLength { if len(token) != EinittokenLength {
return nil, fmt.Errorf("invalid length of token: (returned %d, expected %d)", return nil, fmt.Errorf("invalid length of token: (returned %d, expected %d)",
len(resp.Resp.GetToken()), EinittokenLength) len(token), EinittokenLength)
} }
tok := &Einittoken{} tok := &Einittoken{}
...@@ -179,5 +179,5 @@ func GetToken(sig []byte) ([]byte, error) { ...@@ -179,5 +179,5 @@ func GetToken(sig []byte) ([]byte, error) {
logrus.Debugf(" MAC: 0x%v\n", logrus.Debugf(" MAC: 0x%v\n",
hex.EncodeToString(tok.Mac[:])) hex.EncodeToString(tok.Mac[:]))
return resp.Resp.GetToken(), nil return resp.GetLaunchToken.GetToken(), nil
} }
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: aesm-service.proto
package aesm_service
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
type AesmServiceRequest struct {
GetLaunchToken *AesmServiceRequest_GetLaunchToken `protobuf:"bytes,3,opt,name=getLaunchToken,proto3" json:"getLaunchToken,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *AesmServiceRequest) Reset() { *m = AesmServiceRequest{} }
func (m *AesmServiceRequest) String() string { return proto.CompactTextString(m) }
func (*AesmServiceRequest) ProtoMessage() {}
func (*AesmServiceRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_85fe23d8fdbcfe93, []int{0}
}
func (m *AesmServiceRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_AesmServiceRequest.Unmarshal(m, b)
}
func (m *AesmServiceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_AesmServiceRequest.Marshal(b, m, deterministic)
}
func (m *AesmServiceRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_AesmServiceRequest.Merge(m, src)
}
func (m *AesmServiceRequest) XXX_Size() int {
return xxx_messageInfo_AesmServiceRequest.Size(m)
}
func (m *AesmServiceRequest) XXX_DiscardUnknown() {
xxx_messageInfo_AesmServiceRequest.DiscardUnknown(m)
}
var xxx_messageInfo_AesmServiceRequest proto.InternalMessageInfo
func (m *AesmServiceRequest) GetGetLaunchToken() *AesmServiceRequest_GetLaunchToken {
if m != nil {
return m.GetLaunchToken
}
return nil
}
type AesmServiceRequest_GetLaunchToken struct {
Enclavehash []byte `protobuf:"bytes,1,opt,name=enclavehash,proto3" json:"enclavehash,omitempty"`
Modulus []byte `protobuf:"bytes,2,opt,name=modulus,proto3" json:"modulus,omitempty"`
Attributes []byte `protobuf:"bytes,3,opt,name=attributes,proto3" json:"attributes,omitempty"`
Timeout uint32 `protobuf:"varint,9,opt,name=timeout,proto3" json:"timeout,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *AesmServiceRequest_GetLaunchToken) Reset() { *m = AesmServiceRequest_GetLaunchToken{} }
func (m *AesmServiceRequest_GetLaunchToken) String() string { return proto.CompactTextString(m) }
func (*AesmServiceRequest_GetLaunchToken) ProtoMessage() {}
func (*AesmServiceRequest_GetLaunchToken) Descriptor() ([]byte, []int) {
return fileDescriptor_85fe23d8fdbcfe93, []int{0, 0}
}
func (m *AesmServiceRequest_GetLaunchToken) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_AesmServiceRequest_GetLaunchToken.Unmarshal(m, b)
}
func (m *AesmServiceRequest_GetLaunchToken) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_AesmServiceRequest_GetLaunchToken.Marshal(b, m, deterministic)
}
func (m *AesmServiceRequest_GetLaunchToken) XXX_Merge(src proto.Message) {
xxx_messageInfo_AesmServiceRequest_GetLaunchToken.Merge(m, src)
}
func (m *AesmServiceRequest_GetLaunchToken) XXX_Size() int {
return xxx_messageInfo_AesmServiceRequest_GetLaunchToken.Size(m)
}
func (m *AesmServiceRequest_GetLaunchToken) XXX_DiscardUnknown() {
xxx_messageInfo_AesmServiceRequest_GetLaunchToken.DiscardUnknown(m)
}
var xxx_messageInfo_AesmServiceRequest_GetLaunchToken proto.InternalMessageInfo
func (m *AesmServiceRequest_GetLaunchToken) GetEnclavehash() []byte {
if m != nil {
return m.Enclavehash
}
return nil
}
func (m *AesmServiceRequest_GetLaunchToken) GetModulus() []byte {
if m != nil {
return m.Modulus
}
return nil
}
func (m *AesmServiceRequest_GetLaunchToken) GetAttributes() []byte {
if m != nil {
return m.Attributes
}
return nil
}
func (m *AesmServiceRequest_GetLaunchToken) GetTimeout() uint32 {
if m != nil {
return m.Timeout
}
return 0
}
type AesmServiceResponse struct {
GetLaunchToken *AesmServiceResponse_GetLaunchToken `protobuf:"bytes,3,opt,name=getLaunchToken,proto3" json:"getLaunchToken,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *AesmServiceResponse) Reset() { *m = AesmServiceResponse{} }
func (m *AesmServiceResponse) String() string { return proto.CompactTextString(m) }
func (*AesmServiceResponse) ProtoMessage() {}
func (*AesmServiceResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_85fe23d8fdbcfe93, []int{1}
}
func (m *AesmServiceResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_AesmServiceResponse.Unmarshal(m, b)
}
func (m *AesmServiceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_AesmServiceResponse.Marshal(b, m, deterministic)
}
func (m *AesmServiceResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_AesmServiceResponse.Merge(m, src)
}
func (m *AesmServiceResponse) XXX_Size() int {
return xxx_messageInfo_AesmServiceResponse.Size(m)
}
func (m *AesmServiceResponse) XXX_DiscardUnknown() {
xxx_messageInfo_AesmServiceResponse.DiscardUnknown(m)
}
var xxx_messageInfo_AesmServiceResponse proto.InternalMessageInfo
func (m *AesmServiceResponse) GetGetLaunchToken() *AesmServiceResponse_GetLaunchToken {
if m != nil {
return m.GetLaunchToken
}
return nil
}
type AesmServiceResponse_GetLaunchToken struct {
Error uint32 `protobuf:"varint,1,opt,name=error,proto3" json:"error,omitempty"`
Token []byte `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *AesmServiceResponse_GetLaunchToken) Reset() { *m = AesmServiceResponse_GetLaunchToken{} }
func (m *AesmServiceResponse_GetLaunchToken) String() string { return proto.CompactTextString(m) }
func (*AesmServiceResponse_GetLaunchToken) ProtoMessage() {}
func (*AesmServiceResponse_GetLaunchToken) Descriptor() ([]byte, []int) {
return fileDescriptor_85fe23d8fdbcfe93, []int{1, 0}
}
func (m *AesmServiceResponse_GetLaunchToken) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_AesmServiceResponse_GetLaunchToken.Unmarshal(m, b)
}
func (m *AesmServiceResponse_GetLaunchToken) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_AesmServiceResponse_GetLaunchToken.Marshal(b, m, deterministic)
}
func (m *AesmServiceResponse_GetLaunchToken) XXX_Merge(src proto.Message) {
xxx_messageInfo_AesmServiceResponse_GetLaunchToken.Merge(m, src)
}
func (m *AesmServiceResponse_GetLaunchToken) XXX_Size() int {
return xxx_messageInfo_AesmServiceResponse_GetLaunchToken.Size(m)
}
func (m *AesmServiceResponse_GetLaunchToken) XXX_DiscardUnknown() {
xxx_messageInfo_AesmServiceResponse_GetLaunchToken.DiscardUnknown(m)
}
var xxx_messageInfo_AesmServiceResponse_GetLaunchToken proto.InternalMessageInfo
func (m *AesmServiceResponse_GetLaunchToken) GetError() uint32 {
if m != nil {
return m.Error
}
return 0
}
func (m *AesmServiceResponse_GetLaunchToken) GetToken() []byte {
if m != nil {
return m.Token
}
return nil
}
func init() {
proto.RegisterType((*AesmServiceRequest)(nil), "aesm_service.AesmServiceRequest")
proto.RegisterType((*AesmServiceRequest_GetLaunchToken)(nil), "aesm_service.AesmServiceRequest.GetLaunchToken")
proto.RegisterType((*AesmServiceResponse)(nil), "aesm_service.AesmServiceResponse")
proto.RegisterType((*AesmServiceResponse_GetLaunchToken)(nil), "aesm_service.AesmServiceResponse.GetLaunchToken")
}
func init() {
proto.RegisterFile("aesm-service.proto", fileDescriptor_85fe23d8fdbcfe93)
}
var fileDescriptor_85fe23d8fdbcfe93 = []byte{
// 250 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0xb1, 0x4e, 0xc3, 0x30,
0x10, 0x86, 0x65, 0x10, 0x20, 0xae, 0x69, 0x07, 0xc3, 0x60, 0x31, 0xa0, 0xa8, 0x53, 0x16, 0x02,
0x82, 0x95, 0x85, 0x89, 0x85, 0xc9, 0x20, 0xc1, 0x86, 0xdc, 0x70, 0x22, 0x11, 0x8d, 0x5d, 0x7c,
0xe7, 0x3e, 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xdc, 0xde, 0xd5, 0x77, 0x00, 0x00, 0x00,
0xff, 0xff, 0x3d, 0x84, 0x0e, 0xe1, 0xd3, 0x01, 0x00, 0x00,
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册