@@ -65,7 +65,7 @@ void tpm_test_swtpm_test(const char *src_tpm_path, tx_func *tx,
"\x98\xe5\x86\x8d\xe6\x8b\x97\x29\x99\x60\xf2\x71\x7d\x17\x67\x89"
"\xa4\x2f\x9a\xae\xa8\xc7\xb7\xaa\x79\xa8\x62\x56\xc1\xde";
tpm_util_pcrread(s, tx, tpm_pcrread_resp,
- sizeof(tpm_pcrread_resp));
+ sizeof(tpm_pcrread_resp), 14);
qtest_end();
tpm_util_swtpm_kill(swtpm_pid);
@@ -113,13 +113,13 @@ void tpm_test_swtpm_migration_test(const char *src_tpm_path,
"\x98\xe5\x86\x8d\xe6\x8b\x97\x29\x99\x60\xf2\x71\x7d\x17\x67\x89"
"\xa4\x2f\x9a\xae\xa8\xc7\xb7\xaa\x79\xa8\x62\x56\xc1\xde";
tpm_util_pcrread(src_qemu, tx, tpm_pcrread_resp,
- sizeof(tpm_pcrread_resp));
+ sizeof(tpm_pcrread_resp), 14);
tpm_util_migrate(src_qemu, uri);
tpm_util_wait_for_migration_complete(src_qemu);
tpm_util_pcrread(dst_qemu, tx, tpm_pcrread_resp,
- sizeof(tpm_pcrread_resp));
+ sizeof(tpm_pcrread_resp), 14);
qtest_quit(dst_qemu);
qtest_quit(src_qemu);
@@ -130,7 +130,8 @@ void tpm_util_pcrextend(QTestState *s, tx_func *tx)
}
void tpm_util_pcrread(QTestState *s, tx_func *tx,
- const unsigned char *exp_resp, size_t exp_resp_size)
+ const unsigned char *exp_resp, size_t exp_resp_size,
+ off_t offset)
{
unsigned char buffer[1024];
unsigned char tpm_pcrread[] =
@@ -139,7 +140,8 @@ void tpm_util_pcrread(QTestState *s, tx_func *tx,
tx(s, tpm_pcrread, sizeof(tpm_pcrread), buffer, sizeof(buffer));
- g_assert_cmpmem(buffer, exp_resp_size, exp_resp, exp_resp_size);
+ g_assert_cmpmem(&buffer[offset], exp_resp_size - offset,
+ &exp_resp[offset], exp_resp_size - offset);
}
bool tpm_util_swtpm_has_tpm2(void)
@@ -34,7 +34,8 @@ void tpm_util_tis_transfer(QTestState *s,
void tpm_util_startup(QTestState *s, tx_func *tx);
void tpm_util_pcrextend(QTestState *s, tx_func *tx);
void tpm_util_pcrread(QTestState *s, tx_func *tx,
- const unsigned char *exp_resp, size_t exp_resp_size);
+ const unsigned char *exp_resp, size_t exp_resp_size,
+ off_t offset);
bool tpm_util_swtpm_has_tpm2(void);
Due to a change in the TPM 2 code the pcrUpdate counter in the PCRRead response is now different. The easiest way is to skip over the first 14 bytes and only compare the tail of the response. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com> --- tests/qtest/tpm-tests.c | 6 +++--- tests/qtest/tpm-util.c | 6 ++++-- tests/qtest/tpm-util.h | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-)