]>
git.proxmox.com Git - swtpm.git/blob - tests/_test_tpm2_probe
3 # For the license, see the LICENSE file in the root directory.
6 ROOT
=${abs_top_builddir:-$(pwd)/..}
7 TESTDIR
=${abs_top_testdir:-$(dirname "$0")}
9 VTPM_NAME
="vtpm-test-tpm2-probe"
10 SWTPM_DEV_NAME
="/dev/${VTPM_NAME}"
11 export TPM_PATH
=$
(mktemp
-d)
12 STATE_FILE
=$TPM_PATH/tpm2-00.permall
13 VOLATILE_STATE_FILE
=$TPM_PATH/tpm2-00.volatilestate
14 SWTPM_INTERFACE
=${SWTPM_INTERFACE:-cuse}
15 SWTPM_CMD_UNIX_PATH
=${TPM_PATH}/unix-cmd.sock
16 SWTPM_CTRL_UNIX_PATH
=${TPM_PATH}/unix-ctrl.sock
21 if [ -n "$pid" ]; then
29 [ "${SWTPM_INTERFACE}" == "cuse" ] && source ${TESTDIR}/test_cuse
30 source ${TESTDIR}/common
32 rm -f $STATE_FILE $VOLATILE_STATE_FILE 2>/dev
/null
34 run_swtpm
${SWTPM_INTERFACE} --tpm2
36 ps aux |
grep $SWTPM |
grep -v grep
40 echo "Error: ${SWTPM_INTERFACE} TPM did not start."
44 if [ "${SWTPM_INTERFACE}" != "cuse" ]; then
45 run_swtpm_ioctl
${SWTPM_INTERFACE} --stop
47 echo "Error: Could not stop the ${SWTPM_INTERFACE} TPM"
52 # Open access to the TPM
53 swtpm_open_cmddev
${SWTPM_INTERFACE} 100
55 # Before TPM_INIT: Read PCR 17 -- this gives a fatal error
56 # length CC count hashalg sz
57 RES
=$
(swtpm_cmd_tx
${SWTPM_INTERFACE} '\x80\x01\x00\x00\x00\x14\x00\x00\x01\x7e\x00\x00\x00\x01\x00\x0b\x03\x00\x00\x02')
58 exp
=' 80 01 00 00 00 0a 00 00 01 01'
59 if [ "$RES" != "$exp" ]; then
60 echo "Error: Before TPM_INIT: Did not get expected result from TPM_PCRRead(17)"
67 run_swtpm_ioctl
${SWTPM_INTERFACE} -i
69 echo "Error: Could not initialize the ${SWTPM_INTERFACE} TPM."
73 # Read PCR 17 -- this should give TPM_INVALID_POSTINIT
74 swtpm_open_cmddev
${SWTPM_INTERFACE} 100
75 RES
=$
(swtpm_cmd_tx
${SWTPM_INTERFACE} '\x80\x01\x00\x00\x00\x14\x00\x00\x01\x7e\x00\x00\x00\x01\x00\x0b\x03\x00\x00\x02')
76 exp
=' 80 01 00 00 00 0a 00 00 01 00'
77 if [ "$RES" != "$exp" ]; then
78 echo "Error: Did not get expected result from TPM_PCRRead(17)"