manager

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

* @Author: jffan * @Date: 2024-07-31 15:01:17

  • @LastEditTime: 2024-08-21 15:21:00
  • @LastEditors: jffan
  • @FilePath: \gitee-tcas\manager\attestmanager.go

* @Description: Request encapsulation

  • @Author: jffan

  • @Date: 2024-08-15 09:16:45

  • @LastEditTime: 2024-08-19 17:03:39

  • @LastEditors: jffan

  • @FilePath: \gitee-tcas\manager\request.go

  • @Description: The type of request params

  • @Author: jffan

  • @Date: 2024-07-31 15:01:17

  • @LastEditTime: 2024-08-21 10:46:18

  • @LastEditors: jffan

  • @FilePath: \gitee-tcas\manager\response.go

  • @Description: The type of response params

  • @Author: jffan

  • @Date: 2024-07-31 15:01:17

  • @LastEditTime: 2024-08-21 10:33:18

  • @LastEditors: jffan

  • @FilePath: \gitee-tcas\manager\urls.go

  • @Description: Define the constant for the request

Index

Constants

View Source
const (
	NonceGetInterface = "/v1/nonce"
	PolicyUrl         = "/v1/policy"
	SecretUrl         = "/v1/secret"
	SecretListUrl     = "/v1/secret/list"
	NonceUrl          = "/v1/nonce"
	AttestUrl         = "/v1/attest"
	CaUrl             = "/v1/pki/ca"
	AttestCertUrl     = "/v1/attest/getcert"
	AttestSecretUrl   = "/v1/attest/getsecret"
)

The backend interface address

Variables

This section is empty.

Functions

func ParseCert

func ParseCert(certData interface{}) (*x509.Certificate, error)

func ParseTokenByPk

func ParseTokenByPk(publicKey any, tokenString string) (*jwt.Token, error)

func PrintFormatToken

func PrintFormatToken(token *jwt.Token) error

func X5cToCertPem

func X5cToCertPem(x5c []string) (*bytes.Buffer, error)

Types

type AttestCertData

type AttestCertData struct {
	X5c          []string `json:"x5c"`
	SerialNumber string   `json:"serial_number"`
}

type AttestCertInfoReq

type AttestCertInfoReq struct {
	Csr        *CertCsrInfoReq    `json:"csr"`
	AttestInfo *NodeAttestInfoReq `json:"attestInfo"`
}

type AttestCertResponse

type AttestCertResponse struct {
	HttpBaseResponse
	Data *AttestCertData `json:"data"`
}

type AttestSecretData

type AttestSecretData struct {
	HttpBaseResponse
	Secret interface{} `json:"secret"`
}

type CaResponse

type CaResponse struct {
	Keys []CaSingleResponse `json:"keys"`
}

type CaSingleResponse

type CaSingleResponse struct {
	Alg string   `json:"alg"`
	Crv string   `json:"crv"`
	Kid string   `json:"kid"`
	Kty string   `json:"kty"`
	X   string   `json:"x"`
	X5c []string `json:"x5c"`
	Y   string   `json:"y"`
}

type CertCsrInfoReq

type CertCsrInfoReq struct {
	CommonName  string   `json:"common_name"`
	Expiration  int8     `json:"expiration"`
	IPAddresses []string `json:"ip_addresses"`
}

type HttpBaseResponse

type HttpBaseResponse struct {
	Code    int16  `json:"code"`
	Message string `json:"message"`
}

type Manager

type Manager struct {
	APIEndpoint string
	TlsConfig   *tls.Config
	Collectors  map[string]collectors.EvidenceCollector
}

func New

func New(apiEndpoint, caPath string, c map[string]collectors.EvidenceCollector) (*Manager, error)

func (*Manager) AttestForCert

func (m *Manager) AttestForCert(tee, eccpemBase64key, devices, policies string, csr *CertCsrInfoReq) (*AttestCertResponse, error)

func (*Manager) AttestForSecret

func (m *Manager) AttestForSecret(tee, runtimedata, devices, policies, secretID string) (*AttestSecretData, error)

func (*Manager) AttestForToken

func (m *Manager) AttestForToken(tee, runtimedata, devices, policies string) (*TokenResponse, error)

func (*Manager) DeletePolicy

func (m *Manager) DeletePolicy(policyID string) (*PolicyDeleteResponse, error)

func (*Manager) DeleteSecret

func (m *Manager) DeleteSecret(secretID string) (*SecretDeleteResponse, error)

func (*Manager) GetNonce

func (m *Manager) GetNonce() (*NonceResponse, error)

func (*Manager) GetRootCert

func (m *Manager) GetRootCert() (*CaResponse, error)

func (*Manager) ListPolicy

func (m *Manager) ListPolicy(attestationType string) (*PolicyListResponse, error)

func (*Manager) ListSecret

func (m *Manager) ListSecret() (*SecretListResponse, error)

func (*Manager) SetPolicy

func (m *Manager) SetPolicy(name, policy, attestationType string) (*PolicySetResponse, error)

func (*Manager) SetSecret

func (m *Manager) SetSecret(name, encodeJsonData string) (*SecretSetResponse, error)

func (*Manager) UpdateSecret

func (m *Manager) UpdateSecret(id, encodeJsonData string) (*SecretSetResponse, error)

type NodeAttestInfoReq

type NodeAttestInfoReq struct {
	Report    *NodeEvidence `json:"report"`
	Nonce     string        `json:"nonce"`
	PolicyIds []string      `json:"policy_ids"`
}

type NodeEvidence

type NodeEvidence struct {
	Tee         string               `json:"tee"`
	TeeReport   string               `json:"tee_report"`
	Parameter   interface{}          `json:"parameter"`
	TrustDevice []*TrustDeviceReport `json:"trust_devices"`
	RuntimeData string               `json:"runtime_data"`
	InitData    string               `json:"init_data"`
	EventLog    string               `json:"event_log"`
}

type Nonce

type Nonce struct {
	Nonce       string    `json:"nonce,omitempty"`
	ExpiredTime time.Time `json:"expired,omitempty"`
}

type NonceResponse

type NonceResponse struct {
	HttpBaseResponse
	Data *Nonce `json:"data"`
}

type PolicyDeleteResponse

type PolicyDeleteResponse struct {
	HttpBaseResponse
	PolicyID string `json:"policy_id"`
}

type PolicyListJsonFormat

type PolicyListJsonFormat struct {
	Policies []PolicyListResData `json:"policies"`
}

type PolicyListResData

type PolicyListResData struct {
	No              int    `json:"no"`
	PolicyId        string `json:"policy_id"`
	PolicyRego      string `json:"policy_rego"`
	PolicyName      string `json:"policy_name"`
	AttestationType string `json:"attestation_type"`
	PolicyHash      string `json:"policy_hash"`
	Version         int    `json:"version"`
	CreateTime      string `json:"createTime"`
	UpdateTime      string `json:"updateTime"`
}

type PolicyListResponse

type PolicyListResponse struct {
	HttpBaseResponse
	Data []PolicyListResData `json:"data"`
}

type PolicySetResponse

type PolicySetResponse struct {
	HttpBaseResponse
	PolicyID string `json:"policy_id"`
}

type SecretDeleteResponse

type SecretDeleteResponse struct {
	HttpBaseResponse
	SecretID string `json:"secret_id"`
}

type SecretListJsonFormat

type SecretListJsonFormat struct {
	Secrets []SecretListResData `json:"secrets"`
}

type SecretListResData

type SecretListResData struct {
	Id         string `json:"id"`
	Name       string `json:"name"`
	CreateTime string `json:"createTime"`
	UpdateTime string `json:"updateTime"`
}

type SecretListResponse

type SecretListResponse struct {
	HttpBaseResponse
	Data []SecretListResData `json:"data"`
}

type SecretSetResponse

type SecretSetResponse struct {
	HttpBaseResponse
	Id string `json:"id"`
}

type SetPolicyReq

type SetPolicyReq struct {
	Name            string `json:"policy_name"`
	Policy          string `json:"policy_rego"`
	AttestationType string `json:"attestation_type"`
}

type SetSecretReq

type SetSecretReq struct {
	Name   string `json:"name"`
	Secret string `json:"secret"`
}

type TokenResponse

type TokenResponse struct {
	HttpBaseResponse
	Token string `json:"token"`
}

type TrustDeviceReport

type TrustDeviceReport struct {
	DeviceType   string      `json:"type"`
	DeviceReport string      `json:"device_report"`
	Parameter    interface{} `json:"parameter"`
}

type UpdateSecretReq

type UpdateSecretReq struct {
	Id     string `json:"id"`
	Secret string `json:"secret"`
}

Jump to

Keyboard shortcuts

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