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 ¶
- func OpenTPM(path string) (io.ReadWriteCloser, error)
- func Pack(elts ...interface{}) ([]byte, error)
- func Unpack(b []byte, elts ...interface{}) (int, error)
- func UnpackBuf(buf io.Reader, elts ...interface{}) error
- func UseTPM12LengthPrefixSize()
- func UseTPM20LengthPrefixSize()
- type Command
- type Handle
- type RawBytes
- type ResponseCode
- type Tag
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 ¶
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 ¶
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 ¶
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 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.
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. |