1 /* tpm2daemon.h - Global definitions for the TPM2D
2 * Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
3 * Copyright (C) 2021 James Bottomley <James.Bottomley@HansenPartnership.com>
5 * This file is part of GnuPG.
7 * GnuPG is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
12 * GnuPG is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <https://www.gnu.org/licenses/>.
19 * SPDX-License-Identifier: GPL-3.0-or-later
25 #ifdef GPG_ERR_SOURCE_DEFAULT
26 #error GPG_ERR_SOURCE_DEFAULT already defined
28 /* FIXME: Replace this hard coded value as soon as we require a newer
30 #define GPG_ERR_SOURCE_DEFAULT 16 /* GPG_ERR_SOURCE_TPM2 */
31 #include <gpg-error.h>
35 #include "../common/util.h"
36 #include "../common/sysutils.h"
38 /* Maximum length of a digest. */
39 #define MAX_DIGEST_LEN 64
43 /* A large struct name "opt" to keep global flags. */
44 EXTERN_UNLESS_MAIN_MODULE
47 unsigned int debug; /* Debug flags (DBG_foo_VALUE). */
48 int verbose; /* Verbosity level. */
49 int quiet; /* Be as quiet as possible. */
50 unsigned long parent; /* TPM parent */
54 #define DBG_MPI_VALUE 2 /* debug mpi details */
55 #define DBG_CRYPTO_VALUE 4 /* debug low level crypto */
56 #define DBG_IPC_VALUE 1024
58 #define DBG_CRYPTO (opt.debug & DBG_CRYPTO_VALUE)
59 #define DBG_MEMORY (opt.debug & DBG_MEMORY_VALUE)
61 struct server_local_s;
63 struct server_control_s
65 /* Private data used to fire up the connection thread. We use this
66 structure do avoid an extra allocation for just a few bytes. */
71 /* Local data of the server; used only in command.c. */
72 struct server_local_s *server_local;
74 /* The application context used with this connection or NULL if none
75 associated. Note that this is shared with the other connections:
76 All connections accessing the same reader are using the same
77 application context. */
78 struct assuan_context_s *ctx;
80 /* Helper to store the value we are going to sign */
88 typedef struct app_ctx_s *app_t;
90 /*-- tpm2daemon.c --*/
91 void tpm2d_exit (int rc);
94 gpg_error_t initialize_module_command (void);
95 int tpm2d_command_handler (ctrl_t, int);
96 void send_client_notifications (app_t app, int removal);
97 void tpm2d_kick_the_loop (void);
98 int get_active_connection_count (void);
100 #endif /*TPM2DAEMON_H*/