internal

package
v0.0.0-...-efffb57 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: BSD-3-Clause Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Commit string
View Source
var DEF_CONFIG_ORDER = []string{
	"/usr/lib/sota/conf.d",
	"/var/sota/sota.toml",
	"/etc/sota/conf.d/",
}
View Source
var ErrNoWritableFound = errors.New("no writable TOML file found")
View Source
var NotModifiedError = errors.New("Config unchanged on server")

Functions

func DeleteEmptyDirs

func DeleteEmptyDirs(path string) error

Types

type App

type App struct {
	StorageDir      string
	EncryptedConfig string
	SecretsDir      string
	// contains filtered or unexported fields
}

func NewApp

func NewApp(configPaths []string, secrets_dir string, unsafeHandlers, testing bool) (*App, error)

func (*App) CallInitFunctions

func (a *App) CallInitFunctions()

func (*App) CheckIn

func (a *App) CheckIn() error

func (*App) Extract

func (a *App) Extract() error

type AppConfig

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

func (AppConfig) Get

func (c AppConfig) Get(key string) string

func (AppConfig) GetDefault

func (c AppConfig) GetDefault(key string, defval string) string

func (AppConfig) GetOrDie

func (c AppConfig) GetOrDie(key string) string

type CertRotationHandler

type CertRotationHandler struct {
	State CertRotationState
	// contains filtered or unexported fields
}

func NewCertRotationHandler

func NewCertRotationHandler(app *App, stateFile, estServer string) *CertRotationHandler

NewCertRotationHandler constructs a new handler to initiate a rotation with

func RestoreCertRotationHandler

func RestoreCertRotationHandler(app *App, stateFile string) *CertRotationHandler

RestoreCertRotationHandler will attempt to load a previous rotation attempt's state and return a handler that can process it. This function returns nil when `stateFile` does not exist

func (*CertRotationHandler) RestartServices

func (h *CertRotationHandler) RestartServices()

func (*CertRotationHandler) ResumeRotation

func (h *CertRotationHandler) ResumeRotation(online bool) error

ResumeRotation checks if we have an incomplete cert rotation. If so, it will attempt to complete this rotation. The main reason this would happen is if a power failure occurred during `.Rotate`

func (*CertRotationHandler) Rotate

func (h *CertRotationHandler) Rotate() error

func (*CertRotationHandler) Save

func (h *CertRotationHandler) Save() error

type CertRotationState

type CertRotationState struct {
	EstServer   string
	RotationId  string // A unique ID to identify this rotation operation with
	StepIdx     int
	PkeySlotIds []string // Available IDs we can use when generating a new key
	CertSlotIds []string // Available IDs we can use when saving the new cert

	// Used by estStep
	NewKey  string // Path to key or HSM slot id
	NewCert string // Path to cert or HSM slot id

	// Used by fullCfgStep
	FullConfigEncrypted string

	// Used by deviceCfgStep
	DeviceConfigUpdated bool

	// Used by finalizeStep
	Finalized bool
}

type CertRotationStep

type CertRotationStep interface {
	Name() string
	Execute(handler *CertRotationHandler) error
}

type ConfigCreateRequest

type ConfigCreateRequest struct {
	Reason string          `json:"reason"`
	Files  []ConfigFileReq `json:"files"`
	PubKey string          `json:"public-key"`
}

type ConfigFile

type ConfigFile struct {
	Value       string
	OnChanged   []string
	Unencrypted bool
}

type ConfigFileReq

type ConfigFileReq struct {
	Name        string   `json:"name"`
	Value       string   `json:"value"`
	Unencrypted bool     `json:"unencrypted"`
	OnChanged   []string `json:"on-changed,omitempty"`
}

type ConfigStruct

type ConfigStruct = map[string]*ConfigFile

func UnmarshallBuffer

func UnmarshallBuffer(c CryptoHandler, encContent []byte, decrypt bool) (ConfigStruct, error)

func UnmarshallFile

func UnmarshallFile(c CryptoHandler, encFile string, decrypt bool) (ConfigStruct, error)

type CryptoHandler

type CryptoHandler interface {
	Decrypt(value string) ([]byte, error)
	Close()
}

func NewEciesLocalHandler

func NewEciesLocalHandler(privKey crypto.PrivateKey) CryptoHandler

func NewEciesPkcs11Handler

func NewEciesPkcs11Handler(ctx *crypto11.Context, privKey crypto11.Signer) CryptoHandler

type CurrentTarget

type CurrentTarget struct {
	Name    string
	Version int
}

func LoadCurrentTarget

func LoadCurrentTarget(currentTargeFile string) (CurrentTarget, error)

type DeviceUpdate

type DeviceUpdate struct {
	NextPubKey string `json:"next_pubkey"`
}

type DgEvent

type DgEvent struct {
	CorrelationId string `json:"correlationId"`
	//Ecu           string `json:"ecu"`
	Success    bool   `json:"success"`
	TargetName string `json:"targetName"`
	Version    string `json:"version"`
	Details    string `json:"details,omitempty"`
}

type DgEventSync

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

func (*DgEventSync) NotifyCompleted

func (s *DgEventSync) NotifyCompleted(err error)

func (*DgEventSync) NotifyStarted

func (s *DgEventSync) NotifyStarted()

func (*DgEventSync) NotifyStep

func (s *DgEventSync) NotifyStep(name string, err error)

func (*DgEventSync) SetCorrelationId

func (s *DgEventSync) SetCorrelationId(corId string)

type DgEventType

type DgEventType struct {
	Id      string `json:"id"`
	Version int    `json:"version"`
}

type DgUpdateEvent

type DgUpdateEvent struct {
	Id         string      `json:"id"`
	DeviceTime string      `json:"deviceTime"`
	Event      DgEvent     `json:"event"`
	EventType  DgEventType `json:"eventType"`
}

type EciesCrypto

type EciesCrypto struct {
	PrivKey ecies.KeyProvider
	// contains filtered or unexported fields
}

func (*EciesCrypto) Close

func (ec *EciesCrypto) Close()

func (*EciesCrypto) Decrypt

func (ec *EciesCrypto) Decrypt(value string) ([]byte, error)

func (*EciesCrypto) Encrypt

func (ec *EciesCrypto) Encrypt(value string) (string, error)

type EventSync

type EventSync interface {
	NotifyStarted()
	NotifyStep(name string, err error)
	NotifyCompleted(err error)
	SetCorrelationId(corId string)
}

EventSync in an interface for sending events to device-gateway. The abstraction makes it easier to write unit tests

type NoOpEventSync

type NoOpEventSync struct{}

func (NoOpEventSync) NotifyCompleted

func (s NoOpEventSync) NotifyCompleted(err error)

func (NoOpEventSync) NotifyStarted

func (s NoOpEventSync) NotifyStarted()

func (NoOpEventSync) NotifyStep

func (s NoOpEventSync) NotifyStep(name string, err error)

func (NoOpEventSync) SetCorrelationId

func (s NoOpEventSync) SetCorrelationId(corId string)

type PrivateKeyPkcs11

type PrivateKeyPkcs11 struct {
	*ecies.PublicKey
	// contains filtered or unexported fields
}

func ImportPcks11

func ImportPcks11(ctx *crypto11.Context, privKey crypto.PrivateKey) *PrivateKeyPkcs11

func (*PrivateKeyPkcs11) GenerateShared

func (prv *PrivateKeyPkcs11) GenerateShared(pub *ecies.PublicKey) (sk []byte, err error)

func (*PrivateKeyPkcs11) Public

func (prv *PrivateKeyPkcs11) Public() *ecies.PublicKey

Jump to

Keyboard shortcuts

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