ptm_hdata *data;
ptm_getstate *pgs;
ptm_setstate *pss;
+ ptm_loc *pl;
size_t out_len = 0;
TPM_RESULT res;
PTM_CAP_SHUTDOWN |
PTM_CAP_STOP |
PTM_CAP_GET_TPMESTABLISHED |
+ PTM_CAP_SET_LOCALITY |
PTM_CAP_RESET_TPMESTABLISHED |
PTM_CAP_HASHING |
PTM_CAP_GET_STATEBLOB |
out_len = sizeof(re->u.resp);
break;
+ case CMD_SET_LOCALITY:
+ if (n < (ssize_t)sizeof(pl->u.req.loc)) /* rw */
+ goto err_bad_input;
+
+ pl = (ptm_loc *)input.body;
+ if (pl->u.req.loc > 4) {
+ res = TPM_BAD_LOCALITY;
+ } else {
+ res = TPM_SUCCESS;
+ *locality = pl->u.req.loc;
+ }
+
+ *res_p = htobe32(res);
+ out_len = sizeof(re->u.resp);
+ break;
+
case CMD_HASH_START:
if (!*tpm_running)
goto err_not_running;
sed -n '/^ /p' | \
tail -n1 > $RESP_PATH
res="$(cat $RESP_PATH)"
-exp=" 00 00 00 00 00 00 07 f7"
+exp=" 00 00 00 00 00 00 07 ff"
if [ "$res" != "$exp" ]; then
echo "Error: Unexpected response from CMD_GET_CAPABILITY:"
echo " actual : $res"
sed -n '/^ /p' | \
tail -n1 > $RESP_PATH
res="$(cat $RESP_PATH)"
-exp=" 00 00 00 00 00 00 07 f7"
+exp=" 00 00 00 00 00 00 07 ff"
if [ "$res" != "$exp" ]; then
echo "Error: Socket TPM: Unexpected response from CMD_GET_CAPABILITY:"
echo " actual : $res"
fi
+# Reset PCR 20 while in locality 0 -- should not work
+exec 100<>/dev/tcp/localhost/65530
+echo -en '\x00\xC1\x00\x00\x00\x0F\x00\x00\x00\xC8\x00\x03\x00\x00\x10' >&100
+RES=$(cat <&100 | od -t x1 -A n)
+exp=' 00 c4 00 00 00 0a 00 00 00 33'
+if [ "$RES" != "$exp" ]; then
+ echo "Error: Trying to reset PCR 20 in locality 0 returned unexpected result"
+ echo "expected: $exp"
+ echo "received: $RES"
+ exit 1
+fi
+
+# In locality 2 we can reset PCR 20
+# Set the localoty on the TPM: CMD_SET_LOCALITY = 00 00 00 05 <locality>
+echo -en '\x00\x00\x00\x05\x02' > $CMD_PATH
+socat -x -t10 FILE:$CMD_PATH,rdonly UNIX-CONNECT:$SOCK_PATH 2>&1 | \
+ sed -n '/^ /p' | \
+ tail -n1 > $RESP_PATH
+res="$(cat $RESP_PATH)"
+exp=" 00 00 00 00"
+if [ "$res" != "$exp" ]; then
+ echo "Error: Socket TPM: Unexpected response from CMD_SET_LOCALITY:"
+ echo " actual : $res"
+ echo " expected: $exp"
+ exit 1
+fi
+
+# Reset PCR 20 while in locality 2 -- has to work
+exec 100<>/dev/tcp/localhost/65530
+echo -en '\x00\xC1\x00\x00\x00\x0F\x00\x00\x00\xC8\x00\x03\x00\x00\x10' >&100
+RES=$(cat <&100 | od -t x1 -A n)
+exp=' 00 c4 00 00 00 0a 00 00 00 00'
+if [ "$RES" != "$exp" ]; then
+ echo "Error: Could not reset PCR 20 in locality 2"
+ echo "expected: $exp"
+ echo "received: $RES"
+ exit 1
+fi
+
+
# Send shutdown command to the TPM: CMD_SHUTDOWN = 00 00 00 03
echo -en '\x00\x00\x00\x03' > $CMD_PATH
socat -x -t10 FILE:$CMD_PATH,rdonly UNIX-CONNECT:$SOCK_PATH 2>&1 | \