gizhw:tpm
a TPM 2.0 through the kernel's resource manager (/dev/tpmrm0): commands are built as bytes (big-endian, the TPM's wire format) and replies are checked and parsed. The TPM command codes and the layouts are the TCG TPM 2.0 specification's. Every call is on a Handle of gizhw:device.
import * as Tpm from "gizhw:tpm";Types
Property
type Property = { property: i64; value: i64; }A TPM property (TPM_CAP_TPM_PROPERTIES): its code and value.
property:i64value:i64
Pcr
type Pcr = { hash: i64; digest: bytes; }The PCR digest the reply gives for one PCR (the first of the selection), and the selection's hash algorithm.
hash:i64digest:bytes
Functions
command
function command(code: u64, body: bytes): bytesA command: the header (tag, total size, code, all big-endian) and its parameters.
Effects: fail.
getRandomCommand
function getRandomCommand(n: i64): bytesTPM2_GetRandom: n random bytes.
Effects: fail.
getCapabilityCommand
function getCapabilityCommand(capability: i64, property: i64, count: i64): bytesTPM2_GetCapability for capability, from property, up to count values.
Effects: fail.
pcrReadCommand
function pcrReadCommand(pcr: i64): bytesTPM2_PCR_Read of one PCR, in the SHA-256 bank: the selection is one PCR bit in a 3-byte bitmap.
Effects: fail.
reply
function reply(data: bytes): bytes throws stringThe body of a reply, or the TPM's response code as the error.
Effects: fail.
send
function send(h: Device.Handle, cmd: bytes): bytes throws stringSends a command and gives the reply body.
Effects: fail, io.
parseRandom
function parseRandom(body: bytes): bytesThe random bytes of a TPM2_GetRandom reply body (a 2-byte size, then the bytes).
Effects: fail.
getRandom
function getRandom(h: Device.Handle, n: i64): bytes throws stringRandom bytes from the TPM behind h.
Effects: fail, io.
parseProperties
function parseProperties(body: bytes): Vec<Property>The TPM properties in a TPM2_GetCapability reply body (more-data flag, capability, count, then code and value pairs).
Effects: fail.
properties
function properties(h: Device.Handle, count: i64): Vec<Property> throws stringThe TPM properties from the TPM behind h.
Effects: fail, io.
parsePcr
function parsePcr(body: bytes): PcrThe first digest of a TPM2_PCR_Read reply body: the update counter, the selection, then the digests.
Effects: fail.
pcrRead
function pcrRead(h: Device.Handle, pcr: i64): Pcr throws stringThe digest of one PCR from the TPM behind h.
Effects: fail, io.
open
function open(sys: System, d: Device.Device): Device.Handle throws stringThe handle on the TPM's resource manager (/dev/tpmrmN), read-write.
Effects: fail, io.
tpms
function tpms(sys: System): Vec<Device.Device> throws IoErrorThe TPMs the tpm class has.
Effects: fail, io.