Skip to content

Commit

Permalink
tcti: Add '/dev/tcm0' to default conf
Browse files Browse the repository at this point in the history
A standard similar to TPM has been released in China, called TCM(Trusted Cryptography Module), and
its device path is /dev/tcm0. The TCM standard is compatible with TPM,
and TSS can be used to manage its device path.
  • Loading branch information
jouyouyun committed Oct 16, 2023
1 parent d0632da commit 6dcffa7
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 4 deletions.
9 changes: 5 additions & 4 deletions doc/tcti.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ flowchart TD
2. `libtss2-tcti-tabrmd.so`
3. `libtss2-tcti-device.so.0:/dev/tpmrm0`
4. `libtss2-tcti-device.so.0:/dev/tpm0`
5. `libtss2-tcti-swtpm.so`
6. `libtss2-tcti-mssim.so`
5. `libtss2-tcti-device.so.0:/dev/tcm0`
6. `libtss2-tcti-swtpm.so`
7. `libtss2-tcti-mssim.so`

Where:

Expand All @@ -115,7 +116,7 @@ Where:
## tcti-device

To put it simply, tcti-device writes to and reads from a file, typically
`/dev/tpm0` or `/dev/tpmrm0`. The character devices are provided by the Linux
`/dev/tpm0` or `/dev/tpmrm0` or `/dev/tcm0`. The character devices are provided by the Linux
kernel module `tpm_tis`. If no files like these are present, verify that the
kernel module is loaded (`lsmod`) and load it if necessary (`modprobe tpm_tis`).

Expand All @@ -133,7 +134,7 @@ flowchart TD

**`conf`**

* path to the character device, typically `/dev/tpm0` or `/dev/tpmrm0`
* path to the character device, typically `/dev/tpm0` or `/dev/tpmrm0` or `/dev/tcm0`

## tcti-tbs

Expand Down
1 change: 1 addition & 0 deletions src/tss2-esys/esys_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* Library libtss2-tcti-tabrmd.so (tabrmd)
* Device /dev/tpmrm0 (kernel resident resource manager)
* Device /dev/tpm0 (hardware TPM)
* Device /dev/tcm0 (hardware TCM)
* TCP socket localhost:2321 (TPM simulator)
* @param esys_context [out] The ESYS_CONTEXT.
* @param tcti [in] The TCTI context used to connect to the TPM (may be NULL).
Expand Down
1 change: 1 addition & 0 deletions src/tss2-tcti/tcti-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ static char *default_conf[] = {
#else
"/dev/tpmrm0",
"/dev/tpm0",
"/dev/tcm0",
#endif /* __VX_WORKS__ */
};

Expand Down
5 changes: 5 additions & 0 deletions src/tss2-tcti/tctildr-dl.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ struct {
.conf = "/dev/tpm0",
.description = "Access libtss2-tcti-device.so.0 with /dev/tpm0",
},
{
.file = "libtss2-tcti-device.so.0",
.conf = "/dev/tcm0",
.description = "Access libtss2-tcti-device.so.0 with /dev/tcm0",
},
{
.file = "libtss2-tcti-swtpm.so.0",
.description = "Access to libtss2-tcti-swtpm.so",
Expand Down
10 changes: 10 additions & 0 deletions src/tss2-tcti/tctildr-nodl.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ struct {
.conf = "/dev/tpm0",
.description = "Access to /dev/tpm0",
},
{
.names = {
"libtss2-tcti-device.so.0",
"libtss2-tcti-device.so",
"device",
},
.init = Tss2_Tcti_Device_Init,
.conf = "/dev/tcm0",
.description = "Access to /dev/tcm0",
},
#endif /* TCTI_DEVICE */
#endif /* _WIN32 */
#ifdef TCTI_SWTPM
Expand Down
13 changes: 13 additions & 0 deletions test/unit/tctildr-dl.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,19 @@ test_tcti_fail_all (void **state)
expect_value(__wrap_dlopen, flags, RTLD_NOW);
will_return(__wrap_dlopen, NULL);

/* Skip over libtss2-tcti-device.so, /dev/tcm0 */
expect_string(__wrap_dlopen, filename, "libtss2-tcti-device.so.0");
expect_value(__wrap_dlopen, flags, RTLD_NOW);
will_return(__wrap_dlopen, NULL);
expect_string(__wrap_dlopen, filename,
"libtss2-tcti-libtss2-tcti-device.so.0.so.0");
expect_value(__wrap_dlopen, flags, RTLD_NOW);
will_return(__wrap_dlopen, NULL);
expect_string(__wrap_dlopen, filename,
"libtss2-tcti-libtss2-tcti-device.so.0.so");
expect_value(__wrap_dlopen, flags, RTLD_NOW);
will_return(__wrap_dlopen, NULL);

/* Skip over libtss2-tcti-swtpm.so */
expect_string(__wrap_dlopen, filename, "libtss2-tcti-swtpm.so.0");
expect_value(__wrap_dlopen, flags, RTLD_NOW);
Expand Down
3 changes: 3 additions & 0 deletions test/unit/tctildr-nodl.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ test_tctildr_get_default_all_fail (void **state)
TSS2_TCTI_CONTEXT *tcti_ctx = NULL;

#define TEST_RC 0x65203563
/* device:/dev/tcm0 */
will_return(__wrap_tcti_from_init, tcti_ctx);
will_return(__wrap_tcti_from_init, TEST_RC);
/* device:/dev/tpm0 */
will_return (__wrap_tcti_from_init, tcti_ctx);
will_return (__wrap_tcti_from_init, TEST_RC);
Expand Down

0 comments on commit 6dcffa7

Please sign in to comment.