mirror of
https://github.com/stefanberger/swtpm.git
synced 2026-08-10 03:24:00 +00:00
swtpm*: report 'version' in --print-capabilities
The "version" field can be used to decide when capabilities are supported/reported and give some library build details. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
c48dd1e279
commit
155ccdf561
@ -141,7 +141,8 @@ int capabilities_print_json(bool cusetpm)
|
||||
"\"type\": \"swtpm\", "
|
||||
"\"features\": [ "
|
||||
"%s%s%s%s%s%s%s%s"
|
||||
" ] "
|
||||
" ], "
|
||||
"\"version\": \"" VERSION "\" "
|
||||
"}",
|
||||
with_tpm1,
|
||||
with_tpm2,
|
||||
|
||||
@ -985,8 +985,9 @@ static void capabilities_print_json()
|
||||
"\"features\": [ "
|
||||
"\"cmdarg-signkey-pwd\""
|
||||
", \"cmdarg-parentkey-pwd\""
|
||||
" ] "
|
||||
"}\n");
|
||||
" ], "
|
||||
"\"version\": \"" VERSION "\" "
|
||||
"}\n");
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@ -978,7 +978,9 @@ static int print_capabilities(char **swtpm_prg_l)
|
||||
printf("{ \"type\": \"swtpm_setup\", "
|
||||
"\"features\": [ \"cmdarg-keyfile-fd\", \"cmdarg-pwdfile-fd\", \"tpm12-not-need-root\""
|
||||
", \"cmdarg-write-ek-cert-files\""
|
||||
"%s ] }\n", param);
|
||||
"%s ], "
|
||||
"\"version\": \"" VERSION "\" "
|
||||
"}\n", param);
|
||||
|
||||
g_strfreev(keysize_strs);
|
||||
|
||||
|
||||
@ -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" \] \}'
|
||||
exp='\{ "type": "swtpm", "features": \[ "tpm-1.2",( "tpm-2.0",)? '${noncuse}${seccomp}'"cmdarg-key-fd", "cmdarg-pwd-fd" \], "version": "[^"]*" \}'
|
||||
if ! [[ ${msg} =~ ${exp} ]]; then
|
||||
echo "Unexpected response from ${SWTPM_IFACE} TPM to --print-capabilities:"
|
||||
echo "Actual : ${msg}"
|
||||
@ -43,7 +43,7 @@ if [ $? -ne 0 ]; then
|
||||
fi
|
||||
|
||||
# The are some variable parameters at the end, use regex
|
||||
exp='\{ "type": "swtpm_setup", "features": \[ "cmdarg-keyfile-fd", "cmdarg-pwdfile-fd", "tpm12-not-need-root", "cmdarg-write-ek-cert-files"(, "tpm2-rsa-keysize-2048")?(, "tpm2-rsa-keysize-3072")? \] \}'
|
||||
exp='\{ "type": "swtpm_setup", "features": \[ "cmdarg-keyfile-fd", "cmdarg-pwdfile-fd", "tpm12-not-need-root", "cmdarg-write-ek-cert-files"(, "tpm2-rsa-keysize-2048")?(, "tpm2-rsa-keysize-3072")? \], "version": "[^"]*" \}'
|
||||
if ! [[ ${msg} =~ ${exp} ]]; then
|
||||
echo "Unexpected response from ${SWTPM_SETUP} to --print-capabilities:"
|
||||
echo "Actual : ${msg}"
|
||||
@ -62,8 +62,8 @@ if [ -x "$(type -P $(echo "${SWTPM_CERT}" | cut -d" " -f1) )" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exp='{ "type": "swtpm_cert", "features": [ "cmdarg-signkey-pwd", "cmdarg-parentkey-pwd" ] }'
|
||||
if [ "${msg}" != "${exp}" ]; then
|
||||
exp='\{ "type": "swtpm_cert", "features": \[ "cmdarg-signkey-pwd", "cmdarg-parentkey-pwd" \], "version": "[^"]*" \}'
|
||||
if ! [[ "${msg}" =~ ${exp} ]]; then
|
||||
echo "Unexpected response from ${SWTPM_CERT} to --print-capabilities:"
|
||||
echo "Actual : ${msg}"
|
||||
echo "Expected : ${exp}"
|
||||
|
||||
@ -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"(, "rsa-keysize-1024")?(, "rsa-keysize-2048")?(, "rsa-keysize-3072")? \] \}'
|
||||
exp='\{ "type": "swtpm", "features": \[( "tpm-1.2",)? "tpm-2.0", '${noncuse}${seccomp}'"cmdarg-key-fd", "cmdarg-pwd-fd"(, "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}"
|
||||
@ -44,7 +44,7 @@ if [ $? -ne 0 ]; then
|
||||
fi
|
||||
|
||||
# The are some variable parameters at the end, use regex
|
||||
exp='\{ "type": "swtpm_setup", "features": \[ "cmdarg-keyfile-fd", "cmdarg-pwdfile-fd", "tpm12-not-need-root", "cmdarg-write-ek-cert-files"(, "tpm2-rsa-keysize-2048")?(, "tpm2-rsa-keysize-3072")? \] \}'
|
||||
exp='\{ "type": "swtpm_setup", "features": \[ "cmdarg-keyfile-fd", "cmdarg-pwdfile-fd", "tpm12-not-need-root", "cmdarg-write-ek-cert-files"(, "tpm2-rsa-keysize-2048")?(, "tpm2-rsa-keysize-3072")? \], "version": "[^"]*" \}'
|
||||
if ! [[ ${msg} =~ ${exp} ]]; then
|
||||
echo "Unexpected response from ${SWTPM_SETUP} to --print-capabilities:"
|
||||
echo "Actual : ${msg}"
|
||||
@ -63,8 +63,8 @@ if [ -x "$(type -P $(echo "${SWTPM_CERT}" | cut -d" " -f1) )" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exp='{ "type": "swtpm_cert", "features": [ "cmdarg-signkey-pwd", "cmdarg-parentkey-pwd" ] }'
|
||||
if [ "${msg}" != "${exp}" ]; then
|
||||
exp='\{ "type": "swtpm_cert", "features": \[ "cmdarg-signkey-pwd", "cmdarg-parentkey-pwd" \], "version": "[^"]*" \}'
|
||||
if ~ [[ "${msg}" =~ ${exp} ]]; then
|
||||
echo "Unexpected response from ${SWTPM_CERT} to --print-capabilities:"
|
||||
echo "Actual : ${msg}"
|
||||
echo "Expected : ${exp}"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user