Stefan Berger | b21373d | 2018-03-07 14:45:06 -0500 | [diff] [blame] | 1 | /* |
| 2 | * QTest TPM utilities |
| 3 | * |
| 4 | * Copyright (c) 2018 IBM Corporation |
| 5 | * |
| 6 | * Authors: |
| 7 | * Stefan Berger <stefanb@linux.vnet.ibm.com> |
| 8 | * |
| 9 | * This work is licensed under the terms of the GNU GPL, version 2 or later. |
| 10 | * See the COPYING file in the top-level directory. |
| 11 | */ |
| 12 | |
| 13 | #ifndef TESTS_TPM_UTIL_H |
| 14 | #define TESTS_TPM_UTIL_H |
| 15 | |
Stefan Berger | b21373d | 2018-03-07 14:45:06 -0500 | [diff] [blame] | 16 | #include "io/channel-socket.h" |
| 17 | |
| 18 | typedef void (tx_func)(QTestState *s, |
| 19 | const unsigned char *req, size_t req_size, |
| 20 | unsigned char *rsp, size_t rsp_size); |
| 21 | |
| 22 | void tpm_util_crb_transfer(QTestState *s, |
| 23 | const unsigned char *req, size_t req_size, |
| 24 | unsigned char *rsp, size_t rsp_size); |
Stefan Berger | 7066385 | 2018-05-30 13:44:41 -0400 | [diff] [blame] | 25 | void tpm_util_tis_transfer(QTestState *s, |
| 26 | const unsigned char *req, size_t req_size, |
| 27 | unsigned char *rsp, size_t rsp_size); |
Stefan Berger | b21373d | 2018-03-07 14:45:06 -0500 | [diff] [blame] | 28 | |
| 29 | void tpm_util_startup(QTestState *s, tx_func *tx); |
| 30 | void tpm_util_pcrextend(QTestState *s, tx_func *tx); |
| 31 | void tpm_util_pcrread(QTestState *s, tx_func *tx, |
| 32 | const unsigned char *exp_resp, size_t exp_resp_size); |
| 33 | |
Marc-André Lureau | e2f246a | 2018-10-03 17:21:29 +0400 | [diff] [blame] | 34 | bool tpm_util_swtpm_has_tpm2(void); |
| 35 | |
Stefan Berger | b21373d | 2018-03-07 14:45:06 -0500 | [diff] [blame] | 36 | gboolean tpm_util_swtpm_start(const char *path, GPid *pid, |
| 37 | SocketAddress **addr, GError **error); |
| 38 | void tpm_util_swtpm_kill(GPid pid); |
| 39 | |
Stefan Berger | b1e4b7c | 2018-05-30 12:12:50 -0400 | [diff] [blame] | 40 | void tpm_util_migrate(QTestState *who, const char *uri); |
| 41 | |
| 42 | void tpm_util_migration_start_qemu(QTestState **src_qemu, |
| 43 | QTestState **dst_qemu, |
| 44 | SocketAddress *src_tpm_addr, |
| 45 | SocketAddress *dst_tpm_addr, |
Stefan Berger | ea71a33 | 2018-05-30 14:31:12 -0400 | [diff] [blame] | 46 | const char *miguri, |
| 47 | const char *ifmodel); |
Stefan Berger | b1e4b7c | 2018-05-30 12:12:50 -0400 | [diff] [blame] | 48 | |
| 49 | void tpm_util_wait_for_migration_complete(QTestState *who); |
| 50 | |
Stefan Berger | b21373d | 2018-03-07 14:45:06 -0500 | [diff] [blame] | 51 | #endif /* TESTS_TPM_UTIL_H */ |