-
Notifications
You must be signed in to change notification settings - Fork 172
Open
Description
I have used IBM TPM simulator to create TPM 1.2 device with taken-ownership, ek/platform certs created and NV is locked. Also, I have tried to run TPM 1.2 TestReadEKCert test https://github.com/google/go-tpm/blob/main/tpm/tpm_test.go#L152 . However, i have got an error:
root@vboxuser:/home/vboxuser/go-tpm# mkdir /home/vboxuser/tpm-test/test3
root@vboxuser:/home/vboxuser/go-tpm# swtpm_setup --tpm-state /home/vboxuser/tpm-test/test3 --createek --take-ownership --ownerpass 12345 --srkpass 54321 --create-ek-cert --create-platform-cert --lock-nvram --logfile /home/vboxuser/tpm-test/test3/swtpm.log
root@vboxuser:/home/vboxuser/go-tpm# sudo swtpm_cuse -n tpm0 --log file=/home/vboxuser/tpm-test/test3/swtpm.log --pid file=/home/vboxuser/tpm-test/test3/swtpm.pid --tpmstate dir=/home/vboxuser/tpm-test/test3 --flags not-need-init,startup-clear
root@vboxuser:/home/vboxuser/go-tpm# sudo swtpm_bios --tpm-device /dev/tpm0 -ea -cs -u -n
root@vboxuser:/home/vboxuser/go-tpm# ps -fax | tail -n 3
103183 ? Ssl 0:01 /usr/libexec/upowerd
103207 ? Ss 0:00 gpg-agent --homedir /var/lib/fwupd/gnupg --use-standard-socket --daemon
114995 ? Ss 0:00 swtpm_cuse -n tpm0 --log file=/home/vboxuser/tpm-test/test3/swtpm.log --pid file=/home/vboxuser/tpm-test/test3/swtpm.pid --tpmstate dir=/home/vboxuser/tpm-test/test3 --flags not-need-init,startup-clear
root@vboxuser:/home/vboxuser/go-tpm# export TPM_OWNER_AUTH=12345
root@vboxuser:/home/vboxuser/go-tpm# go test -run TestReadEKCert ./...
? github.com/google/go-tpm/examples/tpm-clear [no test files]
? github.com/google/go-tpm/examples/tpm-genaik [no test files]
? github.com/google/go-tpm/examples/tpm-keys [no test files]
? github.com/google/go-tpm/examples/tpm-sign [no test files]
? github.com/google/go-tpm/examples/tpm-takeownership [no test files]
? github.com/google/go-tpm/examples/tpm2-ekcert [no test files]
? github.com/google/go-tpm/examples/tpm2-nvread [no test files]
? github.com/google/go-tpm/examples/tpm2-seal-unseal [no test files]
ok github.com/google/go-tpm/legacy/tpm2 0.010s [no tests to run]
ok github.com/google/go-tpm/legacy/tpm2/credactivation 0.015s [no tests to run]
ok github.com/google/go-tpm/legacy/tpm2/test 0.015s [no tests to run]
--- FAIL: TestReadEKCert (0.00s)
tpm_test.go:159: Unable to read EKCert from NVRAM: failed to read from NVRAM: non-pointer value "tpm.responseAuth" passed to UnpackBuf
FAIL
FAIL github.com/google/go-tpm/tpm 0.015s
ok github.com/google/go-tpm/tpm2 0.012s [no tests to run]
ok github.com/google/go-tpm/tpm2/test 0.016s [no tests to run]
? github.com/google/go-tpm/tpm2/test/testvectors [no test files]
? github.com/google/go-tpm/tpm2/transport [no test files]
ok github.com/google/go-tpm/tpm2/transport/linuxtpm 0.014s [no tests to run]
ok github.com/google/go-tpm/tpm2/transport/linuxudstpm 0.015s [no tests to run]
? github.com/google/go-tpm/tpm2/transport/simulator [no test files]
ok github.com/google/go-tpm/tpm2/transport/tcp 0.016s [no tests to run]
? github.com/google/go-tpm/tpm2/transport/test [no test files]
ok github.com/google/go-tpm/tpmutil 0.008s [no tests to run]
? github.com/google/go-tpm/tpmutil/mssim [no test files]
FAILIn nvReadValue function https://github.com/google/go-tpm/blob/main/tpm/commands.go#L214 there is a typo to add responseAuth as an output args when commandAuth is passed. It should be passed as a pointer to the struct (it is required by tpmutil.UnpackBuf function https://github.com/google/go-tpm/blob/main/tpmutil/encoding.go#L200 ).
When commandAuth is passed as a pointer to the struct then the test is OK.
root@vboxuser:/home/vboxuser/go-tpm# go test -run TestReadEKCert ./...
? github.com/google/go-tpm/examples/tpm-clear [no test files]
? github.com/google/go-tpm/examples/tpm-genaik [no test files]
? github.com/google/go-tpm/examples/tpm-keys [no test files]
? github.com/google/go-tpm/examples/tpm-sign [no test files]
? github.com/google/go-tpm/examples/tpm-takeownership [no test files]
? github.com/google/go-tpm/examples/tpm2-ekcert [no test files]
? github.com/google/go-tpm/examples/tpm2-nvread [no test files]
? github.com/google/go-tpm/examples/tpm2-seal-unseal [no test files]
ok github.com/google/go-tpm/legacy/tpm2 0.026s [no tests to run]
ok github.com/google/go-tpm/legacy/tpm2/credactivation 0.031s [no tests to run]
ok github.com/google/go-tpm/legacy/tpm2/test 0.043s [no tests to run]
ok github.com/google/go-tpm/tpm 0.083s
ok github.com/google/go-tpm/tpm2 0.018s [no tests to run]
ok github.com/google/go-tpm/tpm2/test 0.053s [no tests to run]
? github.com/google/go-tpm/tpm2/test/testvectors [no test files]
? github.com/google/go-tpm/tpm2/transport [no test files]
ok github.com/google/go-tpm/tpm2/transport/linuxtpm 0.021s [no tests to run]
ok github.com/google/go-tpm/tpm2/transport/linuxudstpm 0.029s [no tests to run]
? github.com/google/go-tpm/tpm2/transport/simulator [no test files]
ok github.com/google/go-tpm/tpm2/transport/tcp 0.021s [no tests to run]
? github.com/google/go-tpm/tpm2/transport/test [no test files]
ok github.com/google/go-tpm/tpmutil 0.011s [no tests to run]
? github.com/google/go-tpm/tpmutil/mssim [no test files]Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels