libtpmtss: Retrieve TPM 1.2 version info
[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 * Get TPM version info (TPM 1.2 only)
52 *
53 * @return TPM version info struct
54 */
55 chunk_t (*get_version_info)(tpm_tss_t *this);
56
57 /**
58 * Generate AIK key pair bound to TPM (TPM 1.2 only)
59 *
60 * @param ca_modulus RSA modulus of CA public key
61 * @param aik_blob AIK private key blob
62 * @param aik_pubkey AIK public key
63 * @return TRUE if AIK key generation succeeded
64 */
65 bool (*generate_aik)(tpm_tss_t *this, chunk_t ca_modulus,
66 chunk_t *aik_blob, chunk_t *aik_pubkey,
67 chunk_t *identity_req);
68
69 /**
70 * Get public key from TPM using its object handle (TPM 2.0 only)
71 *
72 * @param handle key object handle
73 * @return public key in PKCS#1 format
74 */
75 chunk_t (*get_public)(tpm_tss_t *this, uint32_t handle);
76
77 /**
78 * Destroy a tpm_tss_t.
79 */
80 void (*destroy)(tpm_tss_t *this);
81 };
82
83 /**
84 * Create a tpm_tss instance.
85 *
86 * @param version TPM version that must be supported by TSS
87 */
88 tpm_tss_t *tpm_tss_probe(tpm_version_t version);
89
90 #endif /** TPM_TSS_H_ @}*/