Created libtpmtss library handling access to v1.2 and v2.0 TPMs
[strongswan.git] / src / libtpmtss / tpm_tss.h
1 /*
2 * Copyright (C) 2016 Andreas Steffen
3 * HSR Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup tpm_tss tpm_tss
18 * @{ @ingroup libtpmtss
19 */
20
21 #ifndef TPM_TSS_H_
22 #define TPM_TSS_H_
23
24 #include <library.h>
25
26 typedef enum tpm_version_t tpm_version_t;
27 typedef struct tpm_tss_t tpm_tss_t;
28
29 /**
30 * TPM Versions
31 */
32 enum tpm_version_t {
33 TPM_VERSION_ANY,
34 TPM_VERSION_1_2,
35 TPM_VERSION_2_0,
36 };
37
38 /**
39 * TPM access via TSS public interface
40 */
41 struct tpm_tss_t {
42
43 /**
44 * Get TPM version supported by TSS
45 *
46 * @return TPM version
47 */
48 tpm_version_t (*get_version)(tpm_tss_t *this);
49
50 /**
51 * Generate AIK key pair bound to TPM (TPM 1.2 only)
52 *
53 * @param ca_modulus RSA modulus of CA public key
54 * @param aik_blob AIK private key blob
55 * @param aik_pubkey AIK public key
56 * @return TRUE if AIK key generation succeeded
57 */
58 bool (*generate_aik)(tpm_tss_t *this, chunk_t ca_modulus,
59 chunk_t *aik_blob, chunk_t *aik_pubkey,
60 chunk_t *identity_req);
61
62 /**
63 * Get public key from TPM using its object handle (TPM 2.0 only)
64 *
65 * @param handle key object handle
66 * @return public key in PKCS#1 format
67 */
68 chunk_t (*get_public)(tpm_tss_t *this, uint32_t handle);
69
70 /**
71 * Destroy a tpm_tss_t.
72 */
73 void (*destroy)(tpm_tss_t *this);
74 };
75
76 /**
77 * Create a tpm_tss instance.
78 *
79 * @param version TPM version that must be supported by TSS
80 */
81 tpm_tss_t *tpm_tss_probe(tpm_version_t version);
82
83 #endif /** TPM_TSS_H_ @}*/