提交 245f3459 编写于 作者: Y YiLin.Li 提交者: jia zhang

rune: revise remote attestation optional configurations type

1. transfer config.RaType from string type to uint32 type.
2. rename config.RaEpidQuoteType as config.RaEpidIsLinkable.
3. set config.RaEpidIsLinkable type as uint32.
Signed-off-by: NYilin Li <YiLin.Li@linux.alibaba.com>
上级 1a6ab70a
...@@ -10,8 +10,8 @@ type Enclave struct { ...@@ -10,8 +10,8 @@ type Enclave struct {
Type string `json:"type"` Type string `json:"type"`
Path string `json:"path"` Path string `json:"path"`
Args string `json:"args,omitempty"` Args string `json:"args,omitempty"`
RaType string `json:"ra_type,omitempty"` RaType uint32 `json:"ra_type,omitempty"`
RaEpidSpid string `json:"ra_epid_spid,omitempty"` RaEpidSpid string `json:"ra_epid_spid,omitempty"`
RaEpidSubscriptionKey string `json:"ra_epid_subscription_key,omitempty"` RaEpidSubscriptionKey string `json:"ra_epid_subscription_key,omitempty"`
RaEpidQuoteType string `json:"ra_epid_quote_type,omitempty"` RaEpidIsLinkable uint32 `json:"ra_epid_is_linkable,omitempty"`
} }
...@@ -9,6 +9,8 @@ import ( ...@@ -9,6 +9,8 @@ import (
"github.com/opencontainers/runc/libcontainer/configs" "github.com/opencontainers/runc/libcontainer/configs"
"github.com/opencontainers/runc/libcontainer/intelrdt" "github.com/opencontainers/runc/libcontainer/intelrdt"
"github.com/opencontainers/runc/libenclave" "github.com/opencontainers/runc/libenclave"
"github.com/opencontainers/runc/libenclave/attestation/sgx"
"github.com/opencontainers/runc/libenclave/intelsgx"
selinux "github.com/opencontainers/selinux/go-selinux" selinux "github.com/opencontainers/selinux/go-selinux"
) )
...@@ -224,6 +226,13 @@ func (v *ConfigValidator) enclave(config *configs.Config) error { ...@@ -224,6 +226,13 @@ func (v *ConfigValidator) enclave(config *configs.Config) error {
return err return err
} }
if config.Enclave.RaType == sgx.InvalidRaType {
return fmt.Errorf("Unsupported ra_type Configuration %v!\n", config.Enclave.RaType)
}
if config.Enclave.RaEpidIsLinkable == intelsgx.InvalidQuoteSignatureType {
return fmt.Errorf("Unsupported ra_epid_is_linkable Configuration %v!\n", config.Enclave.RaEpidIsLinkable)
}
return nil return nil
} }
......
...@@ -147,7 +147,7 @@ func (p *setnsProcess) start() (err error) { ...@@ -147,7 +147,7 @@ func (p *setnsProcess) start() (err error) {
RaType: p.config.Config.Enclave.RaType, RaType: p.config.Config.Enclave.RaType,
RaEpidSpid: p.config.Config.Enclave.RaEpidSpid, RaEpidSpid: p.config.Config.Enclave.RaEpidSpid,
RaEpidSubscriptionKey: p.config.Config.Enclave.RaEpidSubscriptionKey, RaEpidSubscriptionKey: p.config.Config.Enclave.RaEpidSubscriptionKey,
RaEpidQuoteType: p.config.Config.Enclave.RaEpidQuoteType, RaEpidIsLinkable: p.config.Config.Enclave.RaEpidIsLinkable,
} }
err := utils.WriteJSON(p.messageSockPair.parent, config) err := utils.WriteJSON(p.messageSockPair.parent, config)
if err != nil { if err != nil {
...@@ -481,7 +481,7 @@ func (p *initProcess) start() (retErr error) { ...@@ -481,7 +481,7 @@ func (p *initProcess) start() (retErr error) {
RaType: p.config.Config.Enclave.RaType, RaType: p.config.Config.Enclave.RaType,
RaEpidSpid: p.config.Config.Enclave.RaEpidSpid, RaEpidSpid: p.config.Config.Enclave.RaEpidSpid,
RaEpidSubscriptionKey: p.config.Config.Enclave.RaEpidSubscriptionKey, RaEpidSubscriptionKey: p.config.Config.Enclave.RaEpidSubscriptionKey,
RaEpidQuoteType: p.config.Config.Enclave.RaEpidQuoteType, RaEpidIsLinkable: p.config.Config.Enclave.RaEpidIsLinkable,
} }
err := utils.WriteJSON(p.messageSockPair.parent, config) err := utils.WriteJSON(p.messageSockPair.parent, config)
if err != nil { if err != nil {
......
...@@ -20,6 +20,8 @@ import ( ...@@ -20,6 +20,8 @@ import (
"github.com/opencontainers/runc/libcontainer/devices" "github.com/opencontainers/runc/libcontainer/devices"
"github.com/opencontainers/runc/libcontainer/seccomp" "github.com/opencontainers/runc/libcontainer/seccomp"
libcontainerUtils "github.com/opencontainers/runc/libcontainer/utils" libcontainerUtils "github.com/opencontainers/runc/libcontainer/utils"
"github.com/opencontainers/runc/libenclave/attestation/sgx"
"github.com/opencontainers/runc/libenclave/intelsgx"
"github.com/opencontainers/runtime-spec/specs-go" "github.com/opencontainers/runtime-spec/specs-go"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
...@@ -332,9 +334,17 @@ func createEnclaveConfig(spec *specs.Spec, config *configs.Config) { ...@@ -332,9 +334,17 @@ func createEnclaveConfig(spec *specs.Spec, config *configs.Config) {
args = strings.Join(a, " ") args = strings.Join(a, " ")
} }
ra_type := filterOut(env, "ENCLAVE_RA_TYPE") raType := filterOut(env, "ENCLAVE_RA_TYPE")
if ra_type == "" { if raType == "" {
ra_type = libcontainerUtils.SearchLabels(config.Labels, "ra_type") raType = libcontainerUtils.SearchLabels(config.Labels, "ra_type")
}
var ra_type uint32
if strings.EqualFold(raType, "EPID") {
ra_type = sgx.EPID
} else if strings.EqualFold(raType, "DCAP") {
ra_type = sgx.DCAP
} else {
ra_type = sgx.InvalidRaType
} }
ra_epid_spid := filterOut(env, "ENCLAVE_RA_EPID_SPID") ra_epid_spid := filterOut(env, "ENCLAVE_RA_EPID_SPID")
...@@ -347,9 +357,17 @@ func createEnclaveConfig(spec *specs.Spec, config *configs.Config) { ...@@ -347,9 +357,17 @@ func createEnclaveConfig(spec *specs.Spec, config *configs.Config) {
ra_epid_subscription_key = libcontainerUtils.SearchLabels(config.Labels, "ra_epid_subscription_key") ra_epid_subscription_key = libcontainerUtils.SearchLabels(config.Labels, "ra_epid_subscription_key")
} }
ra_epid_quote_type := filterOut(env, "ENCLAVE_RA_EPID_SIGNATURE_TYPE") linkable := filterOut(env, "ENCLAVE_RA_EPID_IS_LINKABLE")
if ra_epid_quote_type == "" { if linkable == "" {
ra_epid_quote_type = libcontainerUtils.SearchLabels(config.Labels, "ra_epid_quote_type") linkable = libcontainerUtils.SearchLabels(config.Labels, "ra_epid_is_linkable")
}
var ra_epid_is_linkable uint32
if strings.EqualFold(linkable, "true") {
ra_epid_is_linkable = intelsgx.QuoteSignatureTypeLinkable
} else if strings.EqualFold(linkable, "false") {
ra_epid_is_linkable = intelsgx.QuoteSignatureTypeUnlinkable
} else {
ra_epid_is_linkable = intelsgx.InvalidQuoteSignatureType
} }
if etype != "" { if etype != "" {
...@@ -360,7 +378,7 @@ func createEnclaveConfig(spec *specs.Spec, config *configs.Config) { ...@@ -360,7 +378,7 @@ func createEnclaveConfig(spec *specs.Spec, config *configs.Config) {
RaType: ra_type, RaType: ra_type,
RaEpidSpid: ra_epid_spid, RaEpidSpid: ra_epid_spid,
RaEpidSubscriptionKey: ra_epid_subscription_key, RaEpidSubscriptionKey: ra_epid_subscription_key,
RaEpidQuoteType: ra_epid_quote_type, RaEpidIsLinkable: ra_epid_is_linkable,
} }
} }
} }
......
...@@ -4,8 +4,8 @@ type InitEnclaveConfig struct { ...@@ -4,8 +4,8 @@ type InitEnclaveConfig struct {
Type string `json:"type"` Type string `json:"type"`
Path string `json:"path"` Path string `json:"path"`
Args string `json:"args"` Args string `json:"args"`
RaType string `json:"ra_type"` RaType uint32 `json:"ra_type"`
RaEpidSpid string `json:"ra_epid_spid"` RaEpidSpid string `json:"ra_epid_spid"`
RaEpidSubscriptionKey string `json:"ra_epid_subscription_key"` RaEpidSubscriptionKey string `json:"ra_epid_subscription_key"`
RaEpidQuoteType string `json:"ra_epid_quote_type"` RaEpidIsLinkable uint32 `json:"ra_epid_is_linkable"`
} }
...@@ -115,6 +115,7 @@ type Quote struct { ...@@ -115,6 +115,7 @@ type Quote struct {
const ( const (
QuoteSignatureTypeUnlinkable = iota QuoteSignatureTypeUnlinkable = iota
QuoteSignatureTypeLinkable QuoteSignatureTypeLinkable
InvalidQuoteSignatureType
) )
const ( const (
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册