core

package
v1.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2024 License: MPL-2.0 Imports: 44 Imported by: 2

Documentation

Overview

Package core provides the core functionality for the Coordinator object including state transition, APIs for marbles and clients, handling of manifests and the sealing functionalities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseVec added in v0.4.0

type BaseVec interface {
	prometheus.Collector

	Delete(labels prometheus.Labels) bool
	DeleteLabelValues(lvs ...string) bool
	Reset()
}

BaseVec is a vector of metrics.

type Core

type Core struct {
	rpc.UnimplementedMarbleServer
	// contains filtered or unexported fields
}

Core implements the core logic of the Coordinator.

func NewCore

func NewCore(
	dnsNames []string, qv quote.Validator, qi quote.Issuer, txHandle transactionHandle,
	recovery recovery.Recovery, zapLogger *zap.Logger, promFactory *promauto.Factory, eventlog *events.Log,
) (*Core, error)

NewCore creates and initializes a new Core object.

func NewCoreWithMocks

func NewCoreWithMocks() *Core

NewCoreWithMocks creates a new core object with quote and seal mocks for testing.

func (*Core) Activate

func (c *Core) Activate(ctx context.Context, req *rpc.ActivationReq) (res *rpc.ActivationResp, err error)

Activate implements the MarbleAPI function to authenticate a marble (implements the MarbleServer interface).

Verifies the marble's integrity and subsequently provides the marble with a certificate for authentication and application-specific parameters as defined in the Coordinator's manifest.

Parameter req needs to contain a MarbleType present in the Coordinator's manifest and a CSR with the Subject and DNSNames set with desired values.

Returns a signed certificate-key-pair and the application's parameters if the authentication was successful. Returns an error if the authentication failed.

func (*Core) AdvanceState added in v1.0.0

func (c *Core) AdvanceState(newState state.State, tx interface {
	PutState(state.State) error
	GetState() (state.State, error)
},
) error

AdvanceState advances the state of the Coordinator.

func (*Core) GenerateQuote added in v1.0.0

func (c *Core) GenerateQuote(cert []byte) error

GenerateQuote generates a quote for the Coordinator using the given certificate. If no quote can be generated due to the system not supporting SGX, no error is returned, and the Coordinator proceeds to run in simulation mode.

func (*Core) GenerateSecrets added in v1.0.0

func (c *Core) GenerateSecrets(
	secrets map[string]manifest.Secret, id uuid.UUID,
	parentCertificate *x509.Certificate, parentPrivKey *ecdsa.PrivateKey, rootPrivK *ecdsa.PrivateKey,
) (map[string]manifest.Secret, error)

GenerateSecrets generates secrets for the given manifest and parent certificate.

func (*Core) GetQuote added in v1.0.0

func (c *Core) GetQuote() []byte

GetQuote returns the quote of the Coordinator.

func (*Core) GetState added in v1.0.0

func (c *Core) GetState(ctx context.Context) (state.State, string, error)

GetState returns the current state of the Coordinator.

func (*Core) GetTLSConfig

func (c *Core) GetTLSConfig() (*tls.Config, error)

GetTLSConfig gets the core's TLS configuration.

func (*Core) GetTLSMarbleRootCertificate added in v0.4.0

func (c *Core) GetTLSMarbleRootCertificate(clientHello *tls.ClientHelloInfo) (*tls.Certificate, error)

GetTLSMarbleRootCertificate creates a TLS certificate for the Coordinator's x509 marbleRoot certificate.

This function initializes a read transaction and should not be called from other functions with ongoing transactions.

func (*Core) GetTLSRootCertificate added in v0.3.0

func (c *Core) GetTLSRootCertificate(clientHello *tls.ClientHelloInfo) (*tls.Certificate, error)

GetTLSRootCertificate creates a TLS certificate for the Coordinators self-signed x509 certificate.

This function initializes a read transaction and should not be called from other functions with ongoing transactions.

func (*Core) RequireState added in v1.0.0

func (c *Core) RequireState(ctx context.Context, states ...state.State) error

RequireState checks if the Coordinator is in one of the given states. This function locks the Core's mutex and therefore should be paired with `defer c.mux.Unlock()`.

func (*Core) Unlock added in v1.0.0

func (c *Core) Unlock()

Unlock the Core's mutex.

type CounterVec added in v0.4.0

type CounterVec interface {
	BaseVec

	GetMetricWith(labels prometheus.Labels) (prometheus.Counter, error)
	GetMetricWithLabelValues(lvs ...string) (prometheus.Counter, error)
	With(labels prometheus.Labels) prometheus.Counter
	WithLabelValues(lvs ...string) prometheus.Counter
}

CounterVec is a vector of metrics.

type NullBaseVec added in v0.4.0

type NullBaseVec struct {
	NullCollector
}

NullBaseVec implements BaseVec but does nothing.

func (NullBaseVec) Delete added in v0.4.0

func (NullBaseVec) Delete(_ prometheus.Labels) bool

Delete implements BaseVec.

func (NullBaseVec) DeleteLabelValues added in v0.4.0

func (NullBaseVec) DeleteLabelValues(_ ...string) bool

DeleteLabelValues implements BaseVec.

func (NullBaseVec) Reset added in v0.4.0

func (NullBaseVec) Reset()

Reset implements BaseVec.

type NullCollector added in v0.4.0

type NullCollector struct{}

NullCollector implements prometheus.Collector but does nothing.

func (NullCollector) Collect added in v0.4.0

func (NullCollector) Collect(chan<- prometheus.Metric)

Collect implements prometheus.Collector.

func (NullCollector) Describe added in v0.4.0

func (NullCollector) Describe(chan<- *prometheus.Desc)

Describe implements prometheus.Collector.

type NullCounter added in v0.4.0

type NullCounter struct {
	NullMetric
	NullCollector
}

NullCounter implements prometheus.Counter but does nothing.

func (NullCounter) Add added in v0.4.0

func (NullCounter) Add(float64)

Add implements prometheus.Counter.

func (NullCounter) Inc added in v0.4.0

func (NullCounter) Inc()

Inc implements prometheus.Counter.

type NullCounterVec added in v0.4.0

type NullCounterVec struct {
	NullBaseVec
}

NullCounterVec implements CounterVec but does nothing.

func (NullCounterVec) GetMetricWith added in v0.4.0

GetMetricWith implements CounterVec.

func (NullCounterVec) GetMetricWithLabelValues added in v0.4.0

func (NullCounterVec) GetMetricWithLabelValues(_ ...string) (prometheus.Counter, error)

GetMetricWithLabelValues implements CounterVec.

func (NullCounterVec) With added in v0.4.0

With implements CounterVec.

func (NullCounterVec) WithLabelValues added in v0.4.0

func (NullCounterVec) WithLabelValues(_ ...string) prometheus.Counter

WithLabelValues implements CounterVec.

type NullMetric added in v0.4.0

type NullMetric struct{}

NullMetric implements prometheus.Metric but does nothing.

func (NullMetric) Desc added in v0.4.0

func (NullMetric) Desc() *prometheus.Desc

Desc implements prometheus.Metric.

func (NullMetric) Write added in v0.4.0

func (NullMetric) Write(*dto.Metric) error

Write implements prometheus.Metric.

type QuoteError added in v0.5.1

type QuoteError struct {
	// contains filtered or unexported fields
}

QuoteError is returned when the quote could not be retrieved.

func (QuoteError) Error added in v0.5.1

func (e QuoteError) Error() string

Error returns the error message.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL