]>
git.ipfire.org Git - thirdparty/strongswan.git/blob - src/libtpmtss/tpm_tss.c
2 * Copyright (C) 2016 Andreas Steffen
4 * Copyright (C) secunet Security Networks AG
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 #include "tpm_tss_tss2.h"
19 #include "tpm_tss_trousers.h"
22 * Register plugins if built statically
24 #ifdef STATIC_PLUGIN_CONSTRUCTORS
25 #include "plugin_constructors.c"
29 * Reference counter for library initialization
31 static refcount_t libtpmtss_ref
= 0;
34 * Described in header.
36 bool libtpmtss_init(void)
38 if (ref_cur(&libtpmtss_ref
) || tpm_tss_tss2_init())
40 ref_get(&libtpmtss_ref
);
47 * Described in header.
49 void libtpmtss_deinit(void)
51 if (ref_cur(&libtpmtss_ref
) && ref_put(&libtpmtss_ref
))
53 tpm_tss_tss2_deinit();
57 typedef tpm_tss_t
*(*tpm_tss_create
)(void);
62 tpm_tss_t
*tpm_tss_probe(tpm_version_t version
)
64 tpm_tss_create stacks
[] = {
66 tpm_tss_trousers_create
,
71 for (i
= 0; i
< countof(stacks
); i
++)
76 if (version
== TPM_VERSION_ANY
|| version
== tpm
->get_version(tpm
))