Skip to content

Commit

Permalink
test: Make sure that when key is passed state is encrypted
Browse files Browse the repository at this point in the history
Make sure that when keyfile/keyfile-fd or pwdfile/pwdfile-fd are passed
to swtpm_setup that the resulting state is actually encrypted. We check
for encrypted state by making sure that 4-byte sequences of 0-bytes are
not there while they are there for un-encrypted state.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
  • Loading branch information
stefanberger committed Jun 27, 2019
1 parent 8a2d8bc commit 4d8cd82
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/test_tpm2_parameters
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,24 @@ for (( i=0; i<${#PARAMETERS[*]}; i++)); do
exit 1
fi

# Make sure the state is encrypted when a key was given.
# We expect sequences of 4 0-bytes in unencrypted state
# and no such sequences in encrypted state.
nullseq="$(cat $TPMDIR/tpm2-00.permall | \
od -t x1 -A n | tr -d '\n' |
grep "00 00 00 00")"
if [[ "${PARAMETERS[$i]}" =~ (keyfile|pwdfile) ]]; then
if [ -n "${nullseq}" ]; then
echo "ERROR: State file is not encrypted with" \
"parameters '${PARAMETERS[$i]}'"
fi
else
if [ -z "${nullseq}" ]; then
echo "ERROR: State must not be encrypted with" \
"parameters '${PARAMETERS[$i]}'"
fi
fi

echo "SUCCESS with parameters '${PARAMETERS[$i]}'."
done

Expand Down

0 comments on commit 4d8cd82

Please sign in to comment.