未验证 提交 1da2e541 编写于 作者: H hustliyilin 提交者: GitHub

runectl: Sync up with the pb3 oneof fix from libenclave/intelsgx

1. using `oneof` to distinguish default value and missing value in pb3.
2. dropping invalid fields in Quote to avoid invalid Attestation Evidence
Payload error(ErrorCode: 400).
Signed-off-by: NYilin Li <YiLin.Li@linux.alibaba.com>
上级 45ab4396
......@@ -303,12 +303,12 @@ func GetQuote(report []byte, spid string, linkable bool) ([]byte, error) {
req := pb.AesmServiceRequest{}
req.GetQuote = &pb.AesmServiceRequest_GetQuote{
Report: report,
QuoteType: t,
Spid: s,
BufSize: SgxMaxQuoteLength,
QeReport: false,
Timeout: 10000,
Report: report,
QuoteTypePresent: &pb.AesmServiceRequest_GetQuote_QuoteType{QuoteType: t},
Spid: s,
BufSize: SgxMaxQuoteLength,
QeReportPresent: &pb.AesmServiceRequest_GetQuote_QeReport{QeReport: false},
Timeout: 10000,
}
rdata, err := transmitAesmd(conn, &req)
......@@ -328,7 +328,7 @@ func GetQuote(report []byte, spid string, linkable bool) ([]byte, error) {
}
quote := resp.GetQuote.GetQuote()
if len(quote) < QuoteLength || len(quote) != SgxMaxQuoteLength {
if len(quote) < QuoteLength || len(quote) > SgxMaxQuoteLength {
return nil, fmt.Errorf("invalid length of quote: (returned %d, expected %d)",
len(quote), QuoteLength)
}
......@@ -355,5 +355,6 @@ func GetQuote(report []byte, spid string, linkable bool) ([]byte, error) {
logrus.Debugf(" Signature Length: %d\n",
q.SigLen)
return resp.GetQuote.GetQuote(), nil
validQuote := quote[0 : q.SigLen+QuoteLength]
return validQuote, nil
}
......@@ -115,17 +115,21 @@ func (m *AesmServiceRequest_GetQeTargetInfo) GetTimeout() uint32 {
}
type AesmServiceRequest_GetQuote struct {
Report []byte `protobuf:"bytes,1,opt,name=report,proto3" json:"report,omitempty"`
QuoteType uint32 `protobuf:"varint,2,opt,name=quote_type,json=quoteType,proto3" json:"quote_type,omitempty"`
Spid []byte `protobuf:"bytes,3,opt,name=spid,proto3" json:"spid,omitempty"`
Nonce []byte `protobuf:"bytes,4,opt,name=nonce,proto3" json:"nonce,omitempty"`
SigRl []byte `protobuf:"bytes,5,opt,name=sig_rl,json=sigRl,proto3" json:"sig_rl,omitempty"`
BufSize uint32 `protobuf:"varint,6,opt,name=buf_size,json=bufSize,proto3" json:"buf_size,omitempty"`
QeReport bool `protobuf:"varint,7,opt,name=qe_report,json=qeReport,proto3" json:"qe_report,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:"-"`
Report []byte `protobuf:"bytes,1,opt,name=report,proto3" json:"report,omitempty"`
// Types that are valid to be assigned to QuoteTypePresent:
// *AesmServiceRequest_GetQuote_QuoteType
QuoteTypePresent isAesmServiceRequest_GetQuote_QuoteTypePresent `protobuf_oneof:"quote_type_present"`
Spid []byte `protobuf:"bytes,3,opt,name=spid,proto3" json:"spid,omitempty"`
Nonce []byte `protobuf:"bytes,4,opt,name=nonce,proto3" json:"nonce,omitempty"`
SigRl []byte `protobuf:"bytes,5,opt,name=sig_rl,json=sigRl,proto3" json:"sig_rl,omitempty"`
BufSize uint32 `protobuf:"varint,6,opt,name=buf_size,json=bufSize,proto3" json:"buf_size,omitempty"`
// Types that are valid to be assigned to QeReportPresent:
// *AesmServiceRequest_GetQuote_QeReport
QeReportPresent isAesmServiceRequest_GetQuote_QeReportPresent `protobuf_oneof:"qe_report_present"`
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_GetQuote) Reset() { *m = AesmServiceRequest_GetQuote{} }
......@@ -160,9 +164,26 @@ func (m *AesmServiceRequest_GetQuote) GetReport() []byte {
return nil
}
func (m *AesmServiceRequest_GetQuote) GetQuoteType() uint32 {
type isAesmServiceRequest_GetQuote_QuoteTypePresent interface {
isAesmServiceRequest_GetQuote_QuoteTypePresent()
}
type AesmServiceRequest_GetQuote_QuoteType struct {
QuoteType uint32 `protobuf:"varint,2,opt,name=quote_type,json=quoteType,proto3,oneof"`
}
func (*AesmServiceRequest_GetQuote_QuoteType) isAesmServiceRequest_GetQuote_QuoteTypePresent() {}
func (m *AesmServiceRequest_GetQuote) GetQuoteTypePresent() isAesmServiceRequest_GetQuote_QuoteTypePresent {
if m != nil {
return m.QuoteType
return m.QuoteTypePresent
}
return nil
}
func (m *AesmServiceRequest_GetQuote) GetQuoteType() uint32 {
if x, ok := m.GetQuoteTypePresent().(*AesmServiceRequest_GetQuote_QuoteType); ok {
return x.QuoteType
}
return 0
}
......@@ -195,9 +216,26 @@ func (m *AesmServiceRequest_GetQuote) GetBufSize() uint32 {
return 0
}
func (m *AesmServiceRequest_GetQuote) GetQeReport() bool {
type isAesmServiceRequest_GetQuote_QeReportPresent interface {
isAesmServiceRequest_GetQuote_QeReportPresent()
}
type AesmServiceRequest_GetQuote_QeReport struct {
QeReport bool `protobuf:"varint,7,opt,name=qe_report,json=qeReport,proto3,oneof"`
}
func (*AesmServiceRequest_GetQuote_QeReport) isAesmServiceRequest_GetQuote_QeReportPresent() {}
func (m *AesmServiceRequest_GetQuote) GetQeReportPresent() isAesmServiceRequest_GetQuote_QeReportPresent {
if m != nil {
return m.QeReport
return m.QeReportPresent
}
return nil
}
func (m *AesmServiceRequest_GetQuote) GetQeReport() bool {
if x, ok := m.GetQeReportPresent().(*AesmServiceRequest_GetQuote_QeReport); ok {
return x.QeReport
}
return false
}
......@@ -209,6 +247,14 @@ func (m *AesmServiceRequest_GetQuote) GetTimeout() uint32 {
return 0
}
// XXX_OneofWrappers is for the internal use of the proto package.
func (*AesmServiceRequest_GetQuote) XXX_OneofWrappers() []interface{} {
return []interface{}{
(*AesmServiceRequest_GetQuote_QuoteType)(nil),
(*AesmServiceRequest_GetQuote_QeReport)(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"`
......@@ -500,36 +546,37 @@ func init() {
}
var fileDescriptor_85fe23d8fdbcfe93 = []byte{
// 484 bytes of a gzipped FileDescriptorProto
// 508 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x4d, 0x6f, 0xd3, 0x40,
0x10, 0x95, 0x69, 0x9d, 0x3a, 0x53, 0xa7, 0x45, 0x43, 0x40, 0x26, 0x08, 0x14, 0xf5, 0x14, 0x40,
0x84, 0x02, 0x57, 0x2e, 0x1c, 0x00, 0x21, 0x71, 0x61, 0x13, 0x89, 0xaf, 0x83, 0xe5, 0xa4, 0x13,
0x67, 0x45, 0xe2, 0xb5, 0xf7, 0xa3, 0x52, 0x7b, 0xe4, 0xc0, 0xbf, 0xe0, 0x5f, 0xf1, 0x83, 0x90,
0x77, 0x9d, 0xc8, 0x49, 0x70, 0xc9, 0xcd, 0xef, 0x69, 0xdf, 0xd3, 0xcc, 0x9b, 0x27, 0x03, 0x26,
0xa4, 0x96, 0xcf, 0x14, 0xc9, 0x4b, 0x3e, 0xa5, 0x61, 0x2e, 0x85, 0x16, 0x18, 0x96, 0x5c, 0x5c,
0x71, 0x67, 0xbf, 0x7d, 0xc0, 0x37, 0xa4, 0x96, 0x23, 0x87, 0x19, 0x15, 0x86, 0x94, 0xc6, 0x6f,
0x70, 0x9a, 0x92, 0xfe, 0x44, 0xe3, 0x44, 0xa6, 0xa4, 0x3f, 0x64, 0x33, 0x11, 0x79, 0x7d, 0x6f,
0x70, 0xfc, 0xf2, 0x7c, 0x58, 0x97, 0x0f, 0x77, 0xa5, 0xc3, 0xf7, 0x9b, 0x3a, 0xb6, 0x6d, 0x84,
0x6f, 0x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, 0x6c, 0xe5, 0x76, 0x5d, 0xa5, 0xbf, 0x6c, 0x56, 0xba, 0x0b, 0x4d, 0x12, 0x82, 0x0b,
0x9d, 0x43, 0x87, 0x19, 0x90, 0x27, 0xaf, 0xf4, 0x9d, 0x28, 0x8f, 0xc8, 0x3c, 0x4b, 0x85, 0xc1,
0x9b, 0xb0, 0x1b, 0x96, 0x3d, 0xcd, 0x8f, 0xde, 0xb0, 0xd2, 0xff, 0x7f, 0x7b, 0x76, 0xa1, 0x99,
0x96, 0xd9, 0x38, 0xcc, 0x00, 0xbc, 0x57, 0xad, 0xa5, 0xf1, 0x2b, 0x4b, 0xe9, 0xbd, 0xda, 0xa8,
0x53, 0xad, 0xb5, 0xd2, 0x41, 0x15, 0xd6, 0x1a, 0x8c, 0x5b, 0xfa, 0x47, 0xf7, 0xf2, 0x4f, 0x00,
0x00, 0x00, 0xff, 0xff, 0x78, 0xa8, 0xff, 0xa7, 0xfe, 0x04, 0x00, 0x00,
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册