tpmutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2019 License: Apache-2.0 Imports: 8 Imported by: 150

Documentation

Overview

Package tpmutil provides common utility functions for both TPM 1.2 and TPM 2.0 devices.

Users should call either UseTPM12LengthPrefixSize or UseTPM20LengthPrefixSize before using this package, depending on their type of TPM device.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenTPM

func OpenTPM(path string) (io.ReadWriteCloser, error)

OpenTPM opens a channel to the TPM at the given path. If the file is a device, then it treats it like a normal TPM device, and if the file is a Unix domain socket, then it opens a connection to the socket.

func Pack

func Pack(elts ...interface{}) ([]byte, error)

Pack encodes a set of elements into a single byte array, using encoding/binary. This means that all the elements must be encodeable according to the rules of encoding/binary.

It has one difference from encoding/binary: it encodes byte slices with a prepended length, to match how the TPM encodes variable-length arrays. If you wish to add a byte slice without length prefix, use RawBytes.

func Unpack

func Unpack(b []byte, elts ...interface{}) (int, error)

Unpack is a convenience wrapper around UnpackBuf. Unpack returns the number of bytes read from b to fill elts and error, if any.

func UnpackBuf

func UnpackBuf(buf io.Reader, elts ...interface{}) error

UnpackBuf recursively unpacks types from a reader just as encoding/binary does under binary.BigEndian, but with one difference: it unpacks a byte slice by first reading an integer with lengthPrefixSize bytes, then reading that many bytes. It assumes that incoming values are pointers to values so that, e.g., underlying slices can be resized as needed.

func UseTPM12LengthPrefixSize

func UseTPM12LengthPrefixSize()

UseTPM12LengthPrefixSize makes Pack/Unpack use TPM 1.2 encoding for byte arrays.

func UseTPM20LengthPrefixSize

func UseTPM20LengthPrefixSize()

UseTPM20LengthPrefixSize makes Pack/Unpack use TPM 2.0 encoding for byte arrays.

Types

type Command

type Command uint32

Command is an identifier of a TPM command.

type Handle

type Handle uint32

A Handle is a reference to a TPM object.

type RawBytes

type RawBytes []byte

RawBytes is for Pack and RunCommand arguments that are already encoded. Compared to []byte, RawBytes will not be prepended with slice length during encoding.

type ResponseCode

type ResponseCode uint32

ResponseCode is a response code returned by TPM.

const RCSuccess ResponseCode = 0x000

RCSuccess is response code for successful command. Identical for TPM 1.2 and 2.0.

func RunCommand

func RunCommand(rw io.ReadWriter, tag Tag, cmd Command, in ...interface{}) ([]byte, ResponseCode, error)

RunCommand executes cmd with given tag and arguments. Returns TPM response body (without response header) and response code from the header. Returned error may be nil if response code is not RCSuccess; caller should check both.

type Tag

type Tag uint16

Tag is a command tag.

Directories

Path Synopsis
Package mssim implements the Microsoft simulator TPM2 Transmission Interface The Microsoft simulator TPM Command Transmission Interface (TCTI) is a remote procedure interface donated to the TPM2 Specification by Microsoft.
Package mssim implements the Microsoft simulator TPM2 Transmission Interface The Microsoft simulator TPM Command Transmission Interface (TCTI) is a remote procedure interface donated to the TPM2 Specification by Microsoft.
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.
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.

Jump to

Keyboard shortcuts

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