From: Arun Menon <armenon@redhat.com>
To: Stefan Berger <stefanb@linux.ibm.com>
Cc: qemu-devel@nongnu.org, marcandre.lureau@redhat.com
Subject: Re: [PATCH v2 3/6] tests: Convert string arrays to byte arrays
Date: Wed, 29 Apr 2026 18:42:50 +0530 [thread overview]
Message-ID: <afID0vZKncqbc8aY@fedora> (raw)
In-Reply-To: <20260429121743.1346635-4-stefanb@linux.ibm.com>
Hi,
On Wed, Apr 29, 2026 at 12:17:40PM +0000, Stefan Berger wrote:
> Convert the TPM command and response string arrays to byte arrays.
>
> Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
> ---
> tests/qtest/tpm-tests.c | 30 ++++++++++++++++++---------
> tests/qtest/tpm-util.c | 45 ++++++++++++++++++++++++++---------------
> 2 files changed, 49 insertions(+), 26 deletions(-)
>
> diff --git a/tests/qtest/tpm-tests.c b/tests/qtest/tpm-tests.c
> index 197714f8d9..8bd3288f80 100644
> --- a/tests/qtest/tpm-tests.c
> +++ b/tests/qtest/tpm-tests.c
> @@ -59,11 +59,16 @@ void tpm_test_swtpm_test(const char *src_tpm_path, tx_func *tx,
> tpm_util_startup(s, tx);
> tpm_util_pcrextend(s, tx);
>
> - static const unsigned char tpm_pcrread_resp[] =
> - "\x80\x01\x00\x00\x00\x3e\x00\x00\x00\x00\x00\x00\x00\x16\x00\x00"
> - "\x00\x01\x00\x0b\x03\x00\x04\x00\x00\x00\x00\x01\x00\x20\xf6\x85"
> - "\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";
> + static const unsigned char tpm_pcrread_resp[] = {
> + 0x80, 0x01, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00,
> + 0x00, 0x01, 0x00, 0x0b, 0x03, 0x00, 0x04, 0x00,
> + 0x00, 0x00, 0x00, 0x01, 0x00, 0x20, 0xf6, 0x85,
> + 0x98, 0xe5, 0x86, 0x8d, 0xe6, 0x8b, 0x97, 0x29,
> + 0x99, 0x60, 0xf2, 0x71, 0x7d, 0x17, 0x67, 0x89,
> + 0xa4, 0x2f, 0x9a, 0xae, 0xa8, 0xc7, 0xb7, 0xaa,
> + 0x79, 0xa8, 0x62, 0x56, 0xc1, 0xde
> + };
> tpm_util_pcrread(s, tx, tpm_pcrread_resp,
> sizeof(tpm_pcrread_resp));
>
> @@ -105,11 +110,16 @@ void tpm_test_swtpm_migration_test(const char *src_tpm_path,
> tpm_util_startup(src_qemu, tx);
> tpm_util_pcrextend(src_qemu, tx);
>
> - static const unsigned char tpm_pcrread_resp[] =
> - "\x80\x01\x00\x00\x00\x3e\x00\x00\x00\x00\x00\x00\x00\x16\x00\x00"
> - "\x00\x01\x00\x0b\x03\x00\x04\x00\x00\x00\x00\x01\x00\x20\xf6\x85"
> - "\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";
> + static const unsigned char tpm_pcrread_resp[] = {
> + 0x80, 0x01, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00,
> + 0x00, 0x01, 0x00, 0x0b, 0x03, 0x00, 0x04, 0x00,
> + 0x00, 0x00, 0x00, 0x01, 0x00, 0x20, 0xf6, 0x85,
> + 0x98, 0xe5, 0x86, 0x8d, 0xe6, 0x8b, 0x97, 0x29,
> + 0x99, 0x60, 0xf2, 0x71, 0x7d, 0x17, 0x67, 0x89,
> + 0xa4, 0x2f, 0x9a, 0xae, 0xa8, 0xc7, 0xb7, 0xaa,
> + 0x79, 0xa8, 0x62, 0x56, 0xc1, 0xde,
> + };
> tpm_util_pcrread(src_qemu, tx, tpm_pcrread_resp,
> sizeof(tpm_pcrread_resp));
>
> diff --git a/tests/qtest/tpm-util.c b/tests/qtest/tpm-util.c
> index 2cb2dd4796..63cd5b69db 100644
> --- a/tests/qtest/tpm-util.c
> +++ b/tests/qtest/tpm-util.c
> @@ -54,10 +54,14 @@ void tpm_util_crb_transfer(QTestState *s,
> void tpm_util_startup(QTestState *s, tx_func *tx)
> {
> unsigned char buffer[1024];
> - static const unsigned char tpm_startup[] =
> - "\x80\x01\x00\x00\x00\x0c\x00\x00\x01\x44\x00\x00";
> - static const unsigned char tpm_startup_resp[] =
> - "\x80\x01\x00\x00\x00\x0a\x00\x00\x00\x00";
> + static const unsigned char tpm_startup[] = {
> + 0x80, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00,
> + 0x01, 0x44, 0x00, 0x00
> + };
> + static const unsigned char tpm_startup_resp[] = {
> + 0x80, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00,
> + 0x00, 0x00
> + };
>
> tx(s, tpm_startup, sizeof(tpm_startup), buffer, sizeof(buffer));
>
> @@ -68,16 +72,23 @@ void tpm_util_startup(QTestState *s, tx_func *tx)
> void tpm_util_pcrextend(QTestState *s, tx_func *tx)
> {
> unsigned char buffer[1024];
> - static const unsigned char tpm_pcrextend[] =
> - "\x80\x02\x00\x00\x00\x41\x00\x00\x01\x82\x00\x00\x00\x0a\x00\x00"
> - "\x00\x09\x40\x00\x00\x09\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00"
> - "\x0b\x74\x65\x73\x74\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
> - "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
> - "\x00";
> + static const unsigned char tpm_pcrextend[] = {
> + 0x80, 0x02, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00,
> + 0x01, 0x82, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00,
> + 0x00, 0x09, 0x40, 0x00, 0x00, 0x09, 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
> + 0x0b, 0x74, 0x65, 0x73, 0x74, 0x00, 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> + 0x00
> + };
>
> - static const unsigned char tpm_pcrextend_resp[] =
> - "\x80\x02\x00\x00\x00\x13\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
> - "\x01\x00\x00";
> + static const unsigned char tpm_pcrextend_resp[] = {
> + 0x80, 0x02, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> + 0x01, 0x00, 0x00
> + };
>
> tx(s, tpm_pcrextend, sizeof(tpm_pcrextend), buffer, sizeof(buffer));
>
> @@ -89,9 +100,11 @@ void tpm_util_pcrread(QTestState *s, tx_func *tx,
> const unsigned char *exp_resp, size_t exp_resp_size)
> {
> unsigned char buffer[1024];
> - static const unsigned char tpm_pcrread[] =
> - "\x80\x01\x00\x00\x00\x14\x00\x00\x01\x7e\x00\x00\x00\x01\x00\x0b"
> - "\x03\x00\x04\x00";
> + static const unsigned char tpm_pcrread[] = {
> + 0x80, 0x01, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00,
> + 0x01, 0x7e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0b,
> + 0x03, 0x00, 0x04, 0x00
> + };
>
> tx(s, tpm_pcrread, sizeof(tpm_pcrread), buffer, sizeof(buffer));
>
> --
> 2.43.0
>
Reviewed-by: Arun Menon <armenon@redhat.com>
Regards,
Arun Menon
next prev parent reply other threads:[~2026-04-29 13:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-29 12:17 [PATCH v2 0/6] Add test case for TPM over I2C with swtpm Stefan Berger
2026-04-29 12:17 ` [PATCH v2 1/6] tests: Move TPM I2C bus read/write functions to common files Stefan Berger
2026-04-29 12:17 ` [PATCH v2 2/6] tests: Have TPM I2C read/write functions take QTestState as first parameter Stefan Berger
2026-04-29 12:17 ` [PATCH v2 3/6] tests: Convert string arrays to byte arrays Stefan Berger
2026-04-29 13:12 ` Arun Menon [this message]
2026-04-29 12:17 ` [PATCH v2 4/6] tests: Rename id of tpmdev to tpm0 Stefan Berger
2026-04-29 12:17 ` [PATCH v2 5/6] tests: Check whether the I2C master flag is set Stefan Berger
2026-04-29 13:13 ` Arun Menon
2026-04-29 12:17 ` [PATCH v2 6/6] tests: Add a TPM TIS I2C swtpm test Stefan Berger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=afID0vZKncqbc8aY@fedora \
--to=armenon@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanb@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.