swtpm: Display the --print-states capability and document it

Display the --print-states capability in the --print-capabilites
output as cmdarg-print-states.

Document availability in the man page.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2021-10-06 18:13:01 -04:00 committed by Stefan Berger
parent 2e3745db08
commit e6cbc55df6
4 changed files with 33 additions and 3 deletions

View File

@ -304,6 +304,7 @@ may contain the following:
"cmdarg-seccomp",
"cmdarg-key-fd",
"cmdarg-pwd-fd",
"cmdarg-print-states",
"nvram-backend-dir",
"nvram-backend-file",
"tpm-send-command-header",
@ -347,6 +348,10 @@ The I<--key> option supports the I<fd=> parameter.
The I<--key> option supports the I<pwdfd=> parameter.
=item B<cmdarg-print-states>
The I<--print-states> option is supported.
=item B<nvram-backend-dir>
The I<--tpmstate> option supports the I<backend-uri=dir://...> and
@ -370,6 +375,30 @@ rsa-keysize verbs is shown then only RSA 2048 bit keys are supported.
=back
=item B<--print-states>
This option allows to print out the TPM 1.2 or TPM 2 state blobs
that are currently stored in a storage backend. This option requires
that the storage backend be specified using the I<--tpmstate> option
and if TPM 2 state blobs are supposed to be shown, the I<--tpm2>
option must be passed.
The following shows the JSON output of this option. It indicates that
the 'permall' and 'volatile' states are available.
{
"type": "swtpm",
"states": [
{
"name": "permall",
"size": 6013
}, {
"name": "volatile",
"size": 1087
}
]
}
=item B<-h|--help>
Display usage info.

View File

@ -143,7 +143,7 @@ int capabilities_print_json(bool cusetpm)
"{ "
"\"type\": \"swtpm\", "
"\"features\": [ "
"%s%s%s%s%s%s%s%s%s%s"
"%s%s%s%s%s%s%s%s%s%s%s"
" ], "
"\"version\": \"" VERSION "\" "
"}",
@ -154,6 +154,7 @@ int capabilities_print_json(bool cusetpm)
cmdarg_seccomp,
true ? "\"cmdarg-key-fd\", " : "",
true ? "\"cmdarg-pwd-fd\", " : "",
true ? "\"cmdarg-print-states\", " : "",
nvram_backend_dir,
nvram_backend_file,
keysizecaps ? keysizecaps : ""

View File

@ -25,7 +25,7 @@ if [ "${SWTPM_IFACE}" != "cuse" ]; then
noncuse='"tpm-send-command-header", "flags-opt-startup", '
fi
exp='\{ "type": "swtpm", "features": \[ "tpm-1.2",( "tpm-2.0",)? '${noncuse}${seccomp}'"cmdarg-key-fd", "cmdarg-pwd-fd", "nvram-backend-dir", "nvram-backend-file" \], "version": "[^"]*" \}'
exp='\{ "type": "swtpm", "features": \[ "tpm-1.2",( "tpm-2.0",)? '${noncuse}${seccomp}'"cmdarg-key-fd", "cmdarg-pwd-fd", "cmdarg-print-states", "nvram-backend-dir", "nvram-backend-file" \], "version": "[^"]*" \}'
if ! [[ ${msg} =~ ${exp} ]]; then
echo "Unexpected response from ${SWTPM_IFACE} TPM to --print-capabilities:"
echo "Actual : ${msg}"

View File

@ -26,7 +26,7 @@ if [ "${SWTPM_IFACE}" != "cuse" ]; then
fi
# The rsa key size reporting is variable, so use a regex
exp='\{ "type": "swtpm", "features": \[( "tpm-1.2",)? "tpm-2.0", '${noncuse}${seccomp}'"cmdarg-key-fd", "cmdarg-pwd-fd", "nvram-backend-dir", "nvram-backend-file"(, "rsa-keysize-1024")?(, "rsa-keysize-2048")?(, "rsa-keysize-3072")? \], "version": "[^"]*" \}'
exp='\{ "type": "swtpm", "features": \[( "tpm-1.2",)? "tpm-2.0", '${noncuse}${seccomp}'"cmdarg-key-fd", "cmdarg-pwd-fd", "cmdarg-print-states", "nvram-backend-dir", "nvram-backend-file"(, "rsa-keysize-1024")?(, "rsa-keysize-2048")?(, "rsa-keysize-3072")? \], "version": "[^"]*" \}'
if ! [[ ${msg} =~ ${exp} ]]; then
echo "Unexpected response from ${SWTPM_IFACE} TPM to --print-capabilities:"
echo "Actual : ${msg}"