tbs

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Rendered for windows/amd64

Overview

Package tbs provides an low-level interface directly mapping to Windows Tbs.dll system library commands: https://docs.microsoft.com/en-us/windows/desktop/TBS/tpm-base-services-portal Public field descriptions contain links to the high-level Windows documentation.

Index

Constants

View Source
const (
	// https://docs.microsoft.com/en-us/windows/desktop/api/Tbs/ns-tbs-tdtbs_context_params2
	// OR flags to use multiple.
	RequestRaw   Flag = 1 << iota // Add flag to request raw context
	IncludeTPM12                  // Add flag to support TPM 1.2
	IncludeTPM20                  // Add flag to support TPM 2

	TPMVersion12 Version = 1 // For TPM 1.2 applications
	TPMVersion20 Version = 2 // For TPM 2 applications or applications using multiple TPM versions

	// https://docs.microsoft.com/en-us/windows/desktop/tbs/command-scheduling
	// https://docs.microsoft.com/en-us/windows/desktop/api/Tbs/nf-tbs-tbsip_submit_command#parameters
	LowPriority    CommandPriority = 100 // For low priority application use
	NormalPriority CommandPriority = 200 // For normal priority application use
	HighPriority   CommandPriority = 300 // For high priority application use
	SystemPriority CommandPriority = 400 // For system tasks that access the TPM

)

Command parameters: https://github.com/tpn/winsdk-10/blob/master/Include/10.0.10240.0/shared/tbs.h

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandPriority

type CommandPriority uint32

CommandPriority is used to determine which pending command to submit whenever the TPM is free.

type Context

type Context uintptr

Context references the current TPM context

func CreateContext

func CreateContext(version Version, flag Flag) (Context, error)

CreateContext creates a new TPM context: https://docs.microsoft.com/en-us/windows/desktop/api/Tbs/nf-tbs-tbsi_context_create

func (Context) Close

func (context Context) Close() error

Close closes an existing TPM context: https://docs.microsoft.com/en-us/windows/desktop/api/Tbs/nf-tbs-tbsip_context_close

func (Context) GetTCGLog

func (context Context) GetTCGLog(logBuffer []byte) (uint32, error)

GetTCGLog gets the system event log, returning the number of bytes written to logBuffer. If logBuffer is nil, the size of the TCG log is returned. ErrInsufficientBuffer is returned if the logBuffer is too short. On failure, the returned length is unspecified. https://docs.microsoft.com/en-us/windows/desktop/api/Tbs/nf-tbs-tbsi_get_tcg_log

func (Context) SubmitCommand

func (context Context) SubmitCommand(
	priority CommandPriority,
	commandBuffer []byte,
	responseBuffer []byte,
) (uint32, error)

SubmitCommand sends commandBuffer to the TPM, returning the number of bytes written to responseBuffer. ErrInsufficientBuffer is returned if the responseBuffer is too short. ErrInvalidOutputPointer is returned if the responseBuffer is nil. On failure, the returned length is unspecified. https://docs.microsoft.com/en-us/windows/desktop/api/Tbs/nf-tbs-tbsip_submit_command

type DeviceInfo added in v0.2.0

type DeviceInfo struct {
	StructVersion    uint32
	TPMVersion       Version
	TPMInterfaceType uint32
	TPMImpRevision   uint32
}

DeviceInfo is TPM_DEVICE_INFO from tbs.h

func GetDeviceInfo added in v0.2.0

func GetDeviceInfo() (*DeviceInfo, error)

GetDeviceInfo gets the DeviceInfo of the current TPM: https://docs.microsoft.com/en-us/windows/win32/api/tbs/nf-tbs-tbsi_getdeviceinfo

type Error

type Error uint32

Error is the return type of all functions in this package.

const (
	ErrInternalError          Error = 0x80284001
	ErrBadParameter           Error = 0x80284002
	ErrInvalidOutputPointer   Error = 0x80284003
	ErrInvalidContext         Error = 0x80284004
	ErrInsufficientBuffer     Error = 0x80284005
	ErrIOError                Error = 0x80284006
	ErrInvalidContextParam    Error = 0x80284007
	ErrServiceNotRunning      Error = 0x80284008
	ErrTooManyTBSContexts     Error = 0x80284009
	ErrTooManyResources       Error = 0x8028400A
	ErrServiceStartPending    Error = 0x8028400B
	ErrPPINotSupported        Error = 0x8028400C
	ErrCommandCanceled        Error = 0x8028400D
	ErrBufferTooLarge         Error = 0x8028400E
	ErrTPMNotFound            Error = 0x8028400F
	ErrServiceDisabled        Error = 0x80284010
	ErrNoEventLog             Error = 0x80284011
	ErrAccessDenied           Error = 0x80284012
	ErrProvisioningNotAllowed Error = 0x80284013
	ErrPPIFunctionUnsupported Error = 0x80284014
	ErrOwnerauthNotFound      Error = 0x80284015
)

TBS Return Codes: https://docs.microsoft.com/en-us/windows/desktop/TBS/tbs-return-codes

func (Error) Error

func (err Error) Error() string

type Flag

type Flag uint32

Flag indicates TPM versions that are supported by the application.

type Version

type Version uint32

Version of TPM being used by the application.

Jump to

Keyboard shortcuts

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