qemu-patch-raspberry4/tests/tpm-util.h
Stefan Berger b21373d071 test: Add test cases that use the external swtpm with CRB interface
Add a test program for testing the CRB with the external swtpm.

The 1st test case extends a PCR and reads back the value and compares
it against an expected return packet.

The 2nd test case repeats the 1st test case and then migrates the
external swtpm's state along with the VM state to a destination
QEMU and swtpm and checks that the PCR has the expected value now.

The test cases require 'swtpm' to be installed on the system and
in the PATH and 'swtpm' must support the --tpm2 option. If this is
not the case, the test will be skipped.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2018-05-25 22:47:27 -04:00

37 lines
1.1 KiB
C

/*
* QTest TPM utilities
*
* Copyright (c) 2018 IBM Corporation
*
* Authors:
* Stefan Berger <stefanb@linux.vnet.ibm.com>
*
* This work is licensed under the terms of the GNU GPL, version 2 or later.
* See the COPYING file in the top-level directory.
*/
#ifndef TESTS_TPM_UTIL_H
#define TESTS_TPM_UTIL_H
#include "qemu/osdep.h"
#include "io/channel-socket.h"
typedef void (tx_func)(QTestState *s,
const unsigned char *req, size_t req_size,
unsigned char *rsp, size_t rsp_size);
void tpm_util_crb_transfer(QTestState *s,
const unsigned char *req, size_t req_size,
unsigned char *rsp, size_t rsp_size);
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);
gboolean tpm_util_swtpm_start(const char *path, GPid *pid,
SocketAddress **addr, GError **error);
void tpm_util_swtpm_kill(GPid pid);
#endif /* TESTS_TPM_UTIL_H */