Documentation ¶
Index ¶
- Constants
- type Algorithm
- type CauseAction
- type CauseCoordinates
- type Command
- type CommandEventLogAdd
- type CommandExtend
- type CommandInit
- type CommandLog
- type CommandLogEntry
- type CommandLogInfoProvider
- type Commands
- type Digest
- type EventLog
- type EventLogEntry
- type PCRID
- type PCRValues
- type TPM
- func (tpm *TPM) DoNotUse_ResetNoInit()
- func (tpm *TPM) IsInitialized() bool
- func (tpm *TPM) Reset()
- func (tpm *TPM) TPMEventLogAdd(ctx context.Context, pcrIndex PCRID, hashAlgo Algorithm, digest Digest, ...) error
- func (tpm *TPM) TPMExecute(ctx context.Context, cmd Command, logInfo CommandLogInfoProvider) error
- func (tpm *TPM) TPMExtend(ctx context.Context, pcrIndex PCRID, hashAlgo Algorithm, digest []byte, ...) error
- func (tpm *TPM) TPMInit(ctx context.Context, locality uint8, info CommandLogInfoProvider) error
Constants ¶
const ( // currently we support only PCR0 and PCR1 // // TODO: move this value into TPM settings PCRRegistersAmount = 2 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Algorithm ¶
Algorithm is just a type-alias.
func SupportedHashAlgos ¶
func SupportedHashAlgos() []Algorithm
SupportedHashAlgos the list of currently supported hashing algorithms.
type CauseAction ¶
CauseAction defines the Action which caused the Command.
type CauseCoordinates ¶
type CauseCoordinates = types.ActionCoordinates
CauseCoordinates defines the coordinates of the Action in a Flow which caused the Command.
type Command ¶
type Command interface { // Apply applies the changes themselves to the given *TPM (not including appending CommandLog). // // Do not use this method directly unless you know what are you doing, // use (*TPM).TPMExecute instead. Apply(context.Context, *TPM) error // LogString formats the entry for CommandLog. LogString() string }
Command is a serializable command that could be "sent" (applied) to TPM.
type CommandEventLogAdd ¶
type CommandEventLogAdd struct { CommandExtend Type tpmeventlog.EventType Data []byte }
CommandEventLogAdd is a Command which adds an entry to TPM Event Log.
func NewCommandEventLogAdd ¶
func NewCommandEventLogAdd( cmdExtend CommandExtend, evType tpmeventlog.EventType, data []byte, ) *CommandEventLogAdd
NewCommandEventLogAdd returns a new instance of CommandEventLogAdd
func (*CommandEventLogAdd) Apply ¶
func (cmd *CommandEventLogAdd) Apply(_ context.Context, tpm *TPM) error
apply implements Command.
func (*CommandEventLogAdd) LogString ¶
func (cmd *CommandEventLogAdd) LogString() string
LogString formats the entry for CommandLog.
func (*CommandEventLogAdd) String ¶
func (cmd *CommandEventLogAdd) String() string
String implements fmt.Stringer.
type CommandExtend ¶
CommandExtend implements Command to represent TPM2_PCR_Extend
Is also used (together with CommandEventLogAdd) to implement a TPM2_PCR_Event Action.
func NewCommandExtend ¶
func NewCommandExtend( pcrIdx PCRID, hashAlgo Algorithm, digest Digest, ) *CommandExtend
NewCommandExtend returns a new instance of CommandExtend.
func (*CommandExtend) Apply ¶
func (cmd *CommandExtend) Apply(_ context.Context, tpm *TPM) error
apply implements Command.
func (CommandExtend) LogString ¶
func (cmd CommandExtend) LogString() string
LogString implements Command.
func (CommandExtend) String ¶
func (cmd CommandExtend) String() string
String implements fmt.Stringer.
type CommandInit ¶
type CommandInit struct {
Locality uint8
}
CommandInit represents _TPM_init + TPM2_Startup(CLEAR).
func NewCommandInit ¶
func NewCommandInit(locality uint8) *CommandInit
NewCommandInit returns a new instance of CommandInit.
func (*CommandInit) Apply ¶
func (cmd *CommandInit) Apply(_ context.Context, tpm *TPM) error
apply implements Command.
func (*CommandInit) LogString ¶
func (cmd *CommandInit) LogString() string
LogString implements Command.
func (*CommandInit) String ¶
func (cmd *CommandInit) String() string
String implements fmt.Stringer.
type CommandLog ¶
type CommandLog []CommandLogEntry
CommandLog is a log of Command-s executed by the TPM.
func (CommandLog) Commands ¶
func (s CommandLog) Commands() Commands
Commands returns the list of raw Command-s.
type CommandLogEntry ¶
type CommandLogEntry struct { Command CauseCoordinates CauseAction }
CommandLogEntry is a log entry of a Command.
func (CommandLogEntry) String ¶
func (entry CommandLogEntry) String() string
String implements fmt.Stringer.
type CommandLogInfoProvider ¶
type CommandLogInfoProvider interface { CauseCoordinates() types.ActionCoordinates CauseAction() types.Action }
CommandLogInfoProvider is an abstract provider of additional/optional information to be added to the CommandLog.
type Commands ¶
type Commands []Command
Commands is a slice of Command-s
type EventLog ¶
type EventLog []EventLogEntry
EventLog represents TPM Event Log.
func EventLogFromParsed ¶
func EventLogFromParsed(parsed *tpmeventlog.TPMEventLog) EventLog
func (*EventLog) Add ¶
func (log *EventLog) Add(extend CommandExtend, evType tpmeventlog.EventType, data []byte)
Add appends an entry to the EventLog.
func (EventLog) RestoreCommands ¶
RestoreCommands returns a list of command logged by the EventLog.
type EventLogEntry ¶
type EventLogEntry struct { CommandExtend Type tpmeventlog.EventType Data []byte }
EventLogEntry is a single entry of EventLog.
func EventLogEntryFromParsed ¶
func EventLogEntryFromParsed(ev *tpmeventlog.Event) EventLogEntry
func (EventLogEntry) Apply ¶
func (entry EventLogEntry) Apply()
Apply is just a placeholder which forbids to use this entry directly as a Command.
func (EventLogEntry) String ¶
func (entry EventLogEntry) String() string
String implements fmt.Stringer.
type PCRID ¶
PCRID is a numeric identifier of a PCR register. For example PCR0 has ID == 0 and PCR8 has ID == 8.
type TPM ¶
type TPM struct { SupportedAlgos []Algorithm PCRValues PCRValues CommandLog CommandLog EventLog EventLog }
TPM is a TrustChain implementation which represents measured boot backed by a Trusted Platform Module (TPM).
func (*TPM) DoNotUse_ResetNoInit ¶
func (tpm *TPM) DoNotUse_ResetNoInit()
DoNotUse_ResetNoInit cleans up the state of TPM as it never received any commands, but does not set the state to a correct one.
Do no use this function unless you know what are you doing.
TODO: try to get rid of this function (or at least make it private).
func (*TPM) IsInitialized ¶
IsInitialized returns if CommandInit was ever executed.
func (*TPM) Reset ¶
func (tpm *TPM) Reset()
Reset cleans up the state of TPM as it never received any commands.
func (*TPM) TPMEventLogAdd ¶
func (tpm *TPM) TPMEventLogAdd( ctx context.Context, pcrIndex PCRID, hashAlgo Algorithm, digest Digest, evType tpmeventlog.EventType, data []byte, info CommandLogInfoProvider, ) error
TPMEventLogAdd is just a wrapper which creates CommandEventLogAdd and executes it.
func (*TPM) TPMExecute ¶
TPMExecute executes an abstract command.