hwsec

package
v0.0.0-...-683b059 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BackupTPMManagerDataIfIntact

func BackupTPMManagerDataIfIntact(ctx context.Context) error

BackupTPMManagerDataIfIntact backs up a the tpm manager data if the important secrets is not cleared.

func CheckDAIsZero

func CheckDAIsZero(ctx context.Context, tpmManager *hwsec.TPMManagerClient) error

CheckDAIsZero uses tpm_manager_client to check if the dictionary attack counter is zero.

func CheckDAIsZeroForTpm1

func CheckDAIsZeroForTpm1(ctx context.Context, tpmManager *hwsec.TPMManagerClient) error

CheckDAIsZeroForTpm1 uses tpm_manager_client to check if the dictionary attack counter is zero on TPMv1.2 devices. Since there is a delay for resetting DA counter on TPMv1.2 devices, so we need to poll for DA to be reset.

func IncreaseDAForTpm1

func IncreaseDAForTpm1(ctx context.Context, tpmManager *hwsec.TPMManagerClient) error

IncreaseDAForTpm1 uses tpm_manager_client to increase the dictionary attack counter, and should be only used on TPMv1.2 devices.

func IncreaseDAWithCheckVault

func IncreaseDAWithCheckVault(ctx context.Context, cryptohome *hwsec.CryptohomeClient, mountInfo *hwsec.CryptohomeMountInfo) error

IncreaseDAWithCheckVault uses cryptohome_client to increase the dictionary attack counter, and should be only used on TPMv1.2 devices. This is currently used for generating a well-known auth failure.

func RestoreTPMManagerData

func RestoreTPMManagerData(ctx context.Context) error

RestoreTPMManagerData copies the backup file back to the location of tpm manager local data.

func SetUpVaultAndUserAsOwner

func SetUpVaultAndUserAsOwner(ctx context.Context, certpath, username, password, label string, utility *hwsec.CryptohomeClient) error

SetUpVaultAndUserAsOwner will setup a user and its vault, and setup the policy to make the user the owner of the device. Caller of this assumes the responsibility of umounting/cleaning up the vault regardless of whether the function returned an error.

Types

type AttestationDBus

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

AttestationDBus talks to attestation service via D-Bus APIs.

func NewAttestationDBus

func NewAttestationDBus(ctx context.Context) (*AttestationDBus, error)

NewAttestationDBus connects to the D-Bus and use the result object to construct AttestationDBus.

func (*AttestationDBus) ActivateAttestationKey

ActivateAttestationKey calls "ActivateAttestationKey" D-Bus Interface.

func (*AttestationDBus) CreateCertifiableKey

CreateCertifiableKey calls "CreateCertifiableKey" D-Bus Interface.

func (*AttestationDBus) CreateCertificateRequest

CreateCertificateRequest calls "CreateCertificateRequest" D-Bus Interface.

func (*AttestationDBus) CreateEnrollRequest

CreateEnrollRequest calls "CreateEnrollRequest" D-Bus Interface.

func (*AttestationDBus) Decrypt

Decrypt calls "Decrypt" D-Bus Interface.

func (*AttestationDBus) DeleteKeys

DeleteKeys calls "DeleteKeys" D-Bus Interface.

func (*AttestationDBus) Enroll

Enroll calls "Enroll" D-Bus Interface.

func (*AttestationDBus) FinishCertificateRequest

FinishCertificateRequest calls "FinishCertificateRequest" D-Bus Interface.

func (*AttestationDBus) FinishEnroll

FinishEnroll calls "FinishEnroll" D-Bus Interface.

func (*AttestationDBus) GetAttestationKeyInfo

GetAttestationKeyInfo calls "GetAttestationKeyInfo" D-Bus Interface.

func (*AttestationDBus) GetCertificate

GetCertificate calls "GetCertificate" D-Bus Interface.

func (*AttestationDBus) GetCertifiedNvIndex

GetCertifiedNvIndex calls "GetCertifiedNvIndex" D-Bus Interface.

func (*AttestationDBus) GetEndorsementInfo

GetEndorsementInfo calls "GetEndorsementInfo" D-Bus Interface.

func (*AttestationDBus) GetEnrollmentID

GetEnrollmentID calls "GetEnrollmentID" D-Bus Interface.

func (*AttestationDBus) GetEnrollmentPreparations

GetEnrollmentPreparations calls "GetEnrollmentPreparations" D-Bus Interface.

func (*AttestationDBus) GetKeyInfo

GetKeyInfo calls "GetKeyInfo" D-Bus Interface.

func (*AttestationDBus) GetStatus

GetStatus calls "GetStatus" D-Bus Interface.

func (*AttestationDBus) RegisterKeyWithChapsToken

RegisterKeyWithChapsToken calls "RegisterKeyWithChapsToken" D-Bus Interface.

func (*AttestationDBus) ResetIdentity

ResetIdentity calls "ResetIdentity" D-Bus Interface.

func (*AttestationDBus) SetKeyPayload

SetKeyPayload calls "SetKeyPayload" D-Bus Interface.

func (*AttestationDBus) Sign

Sign calls "Sign" D-Bus Interface.

func (*AttestationDBus) SignEnterpriseChallenge

SignEnterpriseChallenge calls "SignEnterpriseChallenge" D-Bus Interface.

func (*AttestationDBus) SignSimpleChallenge

SignSimpleChallenge calls "SignSimpleChallenge" D-Bus Interface.

func (*AttestationDBus) Verify

Verify calls "Verify" D-Bus Interface.

type AttestationHelperLocal

type AttestationHelperLocal struct {
	hwsec.AttestationHelper
}

AttestationHelperLocal extends the function set of hwsec.AttestationHelper

func NewAttestationHelper

func NewAttestationHelper(ctx context.Context) (*AttestationHelperLocal, error)

NewAttestationHelper creates a new hwsec.AttestationHelper instance that make use of the functions implemented by AttestationHelperLocal.

type AttestationLocalInfra

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

AttestationLocalInfra enables/disables the local server implementation on DUT.

func NewAttestationLocalInfra

func NewAttestationLocalInfra(dc *hwsec.DaemonController) *AttestationLocalInfra

NewAttestationLocalInfra creates a new AttestationLocalInfra instance, with dc used to control the D-Bus service daemons.

func (*AttestationLocalInfra) Disable

func (ali *AttestationLocalInfra) Disable(ctx context.Context) error

Disable disables the local test infra for attestation flow testing.

func (*AttestationLocalInfra) Enable

func (ali *AttestationLocalInfra) Enable(ctx context.Context) (lastErr error)

Enable enables the local test infra for attestation flow testing.

type CmdHelperLocal

type CmdHelperLocal struct {
	hwsec.CmdTPMClearHelper
	CmdHelperLocalImpl
}

CmdHelperLocal extends the function set of hwsec.CmdHelper

func NewHelper

func NewHelper(r hwsec.CmdRunner) (*CmdHelperLocal, error)

NewHelper creates a new hwsec.CmdTPMClearHelper instance that make use of the functions implemented by CmdRunnerLocal.

type CmdHelperLocalImpl

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

CmdHelperLocalImpl implements the helper functions for CmdHelperLocal

func (*CmdHelperLocalImpl) EnsureTPMIsReadyAndBackupSecrets

func (h *CmdHelperLocalImpl) EnsureTPMIsReadyAndBackupSecrets(ctx context.Context, timeout time.Duration) error

EnsureTPMIsReadyAndBackupSecrets ensures TPM readiness and then backs up tpm manager local data so we can restore important secrets if needed.

type CmdRunnerLocal

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

CmdRunnerLocal implements CmdRunner for local test.

func NewCmdRunner

func NewCmdRunner() *CmdRunnerLocal

NewCmdRunner creates a new command runner for local test.

func NewLoglessCmdRunner

func NewLoglessCmdRunner() *CmdRunnerLocal

NewLoglessCmdRunner creates a new command runner for local test, which wouldn't print logs.

func (*CmdRunnerLocal) Run

func (r *CmdRunnerLocal) Run(ctx context.Context, cmd string, args ...string) ([]byte, error)

Run implements hwsec.CmdRunner.Run.

func (*CmdRunnerLocal) RunWithCombinedOutput

func (r *CmdRunnerLocal) RunWithCombinedOutput(ctx context.Context, cmd string, args ...string) ([]byte, error)

RunWithCombinedOutput implements hwsec.CmdRunner.RunWithCombinedOutput.

type FakePCAAgent

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

FakePCAAgent performs the execution and terminiation of the fake pca agent.

func FakePCAAgentContext

func FakePCAAgentContext(ctx context.Context) *FakePCAAgent

FakePCAAgentContext creates a new FakePCAAgent where context is used when calling the commands.

func (*FakePCAAgent) Start

func (f *FakePCAAgent) Start() error

Start starts running the fake pca agent.

func (*FakePCAAgent) Stop

func (f *FakePCAAgent) Stop() error

Stop signals the fake pca agent with SIGTERM as upstart does to daemons, and waits for its termination.

type FullHelperLocal

type FullHelperLocal struct {
	hwsec.FullHelper
	CmdHelperLocalImpl
}

FullHelperLocal extends the function set of hwsec.FullHelper

func NewFullHelper

func NewFullHelper(ctx context.Context, r hwsec.CmdRunner) (*FullHelperLocal, error)

NewFullHelper creates a new hwsec.FullHelper with a local AttestationClient.

type LocalVA

type LocalVA struct{}

LocalVA implements the VA functionality by hwsec-test-va binary.

func NewLocalVA

func NewLocalVA() *LocalVA

NewLocalVA creates a new instance of LocalVA.

func (*LocalVA) GetDecodedVAChallenge

func (rc *LocalVA) GetDecodedVAChallenge(ctx context.Context) ([]byte, error)

GetDecodedVAChallenge get the VA challenge generated by hwsec-test-va.

func (*LocalVA) VerifyEncodedVAChallenge

func (rc *LocalVA) VerifyEncodedVAChallenge(ctx context.Context, signedChallenge string) error

VerifyEncodedVAChallenge asks hwsec-test-va to verify the challenge response.

type PCAAgentClient

type PCAAgentClient struct{}

PCAAgentClient delegates the request handling to the pca_agent_client command line tool.

func NewPCAAgentClient

func NewPCAAgentClient() *PCAAgentClient

NewPCAAgentClient creates a new instance of RealVA.

func (*PCAAgentClient) HandleCertificateRequest

func (rp *PCAAgentClient) HandleCertificateRequest(ctx context.Context, request string, pcaType hwsec.PCAType) (string, error)

HandleCertificateRequest calls pca_agent_client to process the certificate request.

func (*PCAAgentClient) HandleEnrollRequest

func (rp *PCAAgentClient) HandleEnrollRequest(ctx context.Context, request string, pcaType hwsec.PCAType) (string, error)

HandleEnrollRequest calls pca_agent_client to process the enroll request.

type TPMClearer

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

TPMClearer clear the TPM via crossystem, this would only work on TPM2.0.

func NewTPMClearer

func NewTPMClearer(cmdRunner hwsec.CmdRunner, daemonController *hwsec.DaemonController) *TPMClearer

NewTPMClearer creates a new TPMClearer object, where r is used to run the command internally.

func (*TPMClearer) ClearTPM

func (tc *TPMClearer) ClearTPM(ctx context.Context) error

ClearTPM soft clears the TPM.

func (*TPMClearer) PostClearTPM

func (tc *TPMClearer) PostClearTPM(ctx context.Context) error

PostClearTPM restores the system key and ensures TPM daemon is up.

func (*TPMClearer) PreClearTPM

func (tc *TPMClearer) PreClearTPM(ctx context.Context) error

PreClearTPM backups the system key.

Jump to

Keyboard shortcuts

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