mirror of
https://github.com/stefanberger/swtpm.git
synced 2026-01-09 05:44:10 +00:00
swtpm: report 'tpm-1.2' & 'tpm-2.0' in --print-capabilities
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
ccaf99f12c
commit
da8752b1f7
@ -43,6 +43,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <libtpms/tpm_library.h>
|
||||
#include <libtpms/tpm_error.h>
|
||||
|
||||
#include "capabilities.h"
|
||||
#include "logging.h"
|
||||
@ -122,19 +123,28 @@ int capabilities_print_json(bool cusetpm)
|
||||
#else
|
||||
const char *cmdarg_seccomp = "";
|
||||
#endif
|
||||
const char *with_tpm1 = "";
|
||||
const char *with_tpm2 = "";
|
||||
char *keysizecaps = NULL;
|
||||
|
||||
ret = get_rsa_keysize_caps(&keysizecaps);
|
||||
if (ret < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (TPMLIB_ChooseTPMVersion(TPMLIB_TPM_VERSION_1_2) == TPM_SUCCESS)
|
||||
with_tpm1 = "\"tpm-1.2\", ";
|
||||
if (TPMLIB_ChooseTPMVersion(TPMLIB_TPM_VERSION_2) == TPM_SUCCESS)
|
||||
with_tpm2 = "\"tpm-2.0\", ";
|
||||
|
||||
n = asprintf(&string,
|
||||
"{ "
|
||||
"\"type\": \"swtpm\", "
|
||||
"\"features\": [ "
|
||||
"%s%s%s%s%s%s"
|
||||
"%s%s%s%s%s%s%s%s"
|
||||
" ] "
|
||||
"}",
|
||||
with_tpm1,
|
||||
with_tpm2,
|
||||
!cusetpm ? "\"tpm-send-command-header\", ": "",
|
||||
!cusetpm ? "\"flags-opt-startup\", " : "",
|
||||
cmdarg_seccomp,
|
||||
|
||||
@ -25,8 +25,8 @@ if [ "${SWTPM_IFACE}" != "cuse" ]; then
|
||||
noncuse='"tpm-send-command-header", "flags-opt-startup", '
|
||||
fi
|
||||
|
||||
exp='{ "type": "swtpm", "features": [ '${noncuse}${seccomp}'"cmdarg-key-fd", "cmdarg-pwd-fd" ] }'
|
||||
if [ "${msg}" != "${exp}" ]; then
|
||||
exp='\{ "type": "swtpm", "features": \[ "tpm-1.2",( "tpm-2.0",)? '${noncuse}${seccomp}'"cmdarg-key-fd", "cmdarg-pwd-fd" \] \}'
|
||||
if ! [[ ${msg} =~ ${exp} ]]; then
|
||||
echo "Unexpected response from ${SWTPM_IFACE} TPM 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": \[ '${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")? \] \}'
|
||||
if ! [[ ${msg} =~ ${exp} ]]; then
|
||||
echo "Unexpected response from ${SWTPM_IFACE} TPM to --print-capabilities:"
|
||||
echo "Actual : ${msg}"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user