google / google/go-tpm

TPM Simulator reporting unrecognised command over socket

Open
#348 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
673
Forks
188
PR merge metrics
No merged PRs in 30d

Description

NB: I am still using the tpm2 legacy commands

IBM Software TPM: tpm_server is v1682

On startup, it listens on port 2321, tpm2_startup -c is sent to start the TPM from the command line. Trace.txt contains the following messages at that point. No other information is recorded. Other commands, eg: tpm2_pcrread all work with the appropriate flag.

Output from tpm_server:

```bash
tpmsim/src$ ./tpm_server -v
LIBRARY_COMPATIBILITY_CHECK is ON
Starting ACT thread...
TPM command server listening on port 2321
Platform server listening on port 2322
Command IPv4 client accepted
Unrecognized TPM interface command 80010000
TPM command server listening on port 2321
```

tpm_server trace.txt

```
$ tail -f trace.txt
Command Code 0000017e
TPM2_PCR_Read:
Command Code 0000017e
TPM2_PCR_Read:
Command Code 0000017e
TPM2_PCR_Read:
Command Code 0000017e
TPM2_PCR_Read:
Command Code 00000144
TPM2_Startup:
```

Command to start TPM

`$ tpm2_startup -c -T mssim:host=localhost,port=2321`

The Go code contains the following. The import contains: "github.com/google/go-tpm/legacy/tpm2". I wrote a wrapper around OpenTPM to allow use on Unix and Windows (and support the use of socket + devices on the former).

```go
rwc, err := OpenTPM(tpm2device)
if err != nil {
rtn := tpm2taErrorReturn{fmt.Sprintf("no TPM %w", err.Error())}
return c.JSON(http.StatusInternalServerError, rtn)
}
defer rwc.Close()

banks := make(map[string]pcrValue)

for _, b := range pcrbanks {
pcrvs := make(map[int]string)

for i := 0; i <= 23; i++ {
pcrv, pcre := tpm2.ReadPCR(rwc, i, b)
if pcre == nil {
pcrvs[i] = hex.EncodeToString(pcrv)
}
}
banks[bankNames[b]] = pcrvs
}
```

OpenTPM is as follows:

```go
var TPMDEVICES = []string{ "/dev/tpm0", "/dev/tpmrm0", "/dev/tpm1", "/dev/tpmrm1", }

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

if slices.Contains(TPMDEVICES,path) {
return tpm2.OpenTPM(path)
} else {
return net.Dial("tcp",path)
}
}
```

The parameter to OpenTPM being passed is "0.0.0.0:2321"

tpm_simulator (as above) reports

Command IPv4 client accepted
Unrecognized TPM interface command 80010000

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.